Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Busted vendor script not giving item, help please.

Phaedrus Kuroda
Pixel Pusher
Join date: 30 Jun 2004
Posts: 41
02-25-2005 11:39
So this is a modded EzVendor script that I have made to email me about purchases much like the Vendopf Vendor I like to use. I got it to email me, but it is not giving me the inventory. Any help would be greatly apreciated. Thank you.

CODE
// EZ Single Object Vendor System
// Author: Devon Cassidy
// This script is to be used by anyone in their own One Object Vendor Systems.
// Feel free to do as you please with this script.

// Phaedrus Kuroda was here

integer price = 5; //Price of the object goes here, change to whatever you want
string item = "foobox"; // Write the EXACT name of the object you want to sell
string wrong = "Sorry, that is not the correct price"; // This is the message your vendor will say when the person underpays the vendor
string over = "You have overpaid, here is your change"; //This is the message your vendor will say when a person overpays the vendor
string thank = "Thank you and enjoy your purchase"; //This is a message thanking your buyer for purchasing your object.
string address = "name@domain.com";//email address
string subject = "vendor sale";
string message = "you have sold";
default
{
on_rez(integer total_number)
{
llResetScript();
}
state_entry()
{
llWhisper(0, "Vendor systems go");
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); //Make sure you click YES when the debit dialog pops up or youll have some very unhappy customers >_<. # This insures that they will get their change back if they overpay or underpay
}
money(key id, integer amount)
{
if(amount < price)
{
llSay(0, wrong);
llGiveMoney(id, amount);
}
if(amount > price)
{
llSay(0, over);
llGiveMoney(id, amount - price);
llGiveInventory(llDetectedKey(0), item);
llEmail((string) address, (string) subject, (string) message + (string) item + " to " + llKey2Name(id));
}
if(amount = price)
{
llSay(0, thank);
llGiveInventory(llDetectedKey(0), item);
llEmail((string) address, (string) subject, (string) message + (string) item + " to " + llKey2Name(id));
}
}
}
_____________________
[witty sig goes here]
Pete Fats
Geek
Join date: 18 Apr 2003
Posts: 648
02-26-2005 00:41
Looks like this is your trouble:

if(amount = price)

Change that to if(amount == price)

= is used for assigning values to variables (x = 1), whereas == is used to compare two different values (if x == 1)

Also, as a side note, instead of using 3 if statements in the money() event, it would probably be better to use else if's for the 2nd and 3rd.

Hope this helps.

CODE
// EZ Single Object Vendor System
// Author: Devon Cassidy
// This script is to be used by anyone in their own One Object Vendor Systems.
// Feel free to do as you please with this script.

// Phaedrus Kuroda was here

integer price = 5; //Price of the object goes here, change to whatever you want
string item = "foobox"; // Write the EXACT name of the object you want to sell
string wrong = "Sorry, that is not the correct price"; // This is the message your vendor will say when the person underpays the vendor
string over = "You have overpaid, here is your change"; //This is the message your vendor will say when a person overpays the vendor
string thank = "Thank you and enjoy your purchase"; //This is a message thanking your buyer for purchasing your object.
string address = "name@domain.com";//email address
string subject = "vendor sale";
string message = "you have sold";
default
{
on_rez(integer total_number)
{
llResetScript();
}
state_entry()
{
llWhisper(0, "Vendor systems go");
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT); //Make sure you click YES when the debit dialog pops up or youll have some very unhappy customers >_<. # This insures that they will get their change back if they overpay or underpay
}
money(key id, integer amount)
{
if(amount < price)
{
llSay(0, wrong);
llGiveMoney(id, amount);
}
else if(amount > price)
{
llSay(0, over);
llGiveMoney(id, amount - price);
llGiveInventory(llDetectedKey(0), item);
llEmail((string) address, (string) subject, (string) message + (string) item + " to " + llKey2Name(id));
}
else if(amount == price)
{
llSay(0, thank);
llGiveInventory(llDetectedKey(0), item);
llEmail((string) address, (string) subject, (string) message + (string) item + " to " + llKey2Name(id));
}
}
}
_____________________