For a promotion for a survey I need a script that enables that an avatar can wear a promo board and doing so earns money the time the promo board (prim object) is worn.
I took a camping script and changed it to be usefull for wearing an object and earn money. However it is not working. So I hope somebody can help me?
This is what I made of it:
CODE
integer campmoney = 0; // Initial amount to grant someone upon the VERY first sit after first rez. (Think, Special bonus)
integer campadd = 4; // Payout amount
integer camptime = 600; // Payout time in seconds (Script USES this)
string camptimeM = "10"; // Payout time in minutes (Attract SAYS this)
string reciever = NULL_KEY; // key of Sitter
string _Animation;
default
{
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT ); //Ask my owner for permission to give money and assume it suceeds
llSetText("Press Wear to earn money by walking around,\nL$"+(string)campadd+" every "+camptimeM+" minutes",<0,1,0>,1); // Set the hovertext to attract mode
}
changed(integer change)
{ // something changed
if (change & CHANGED_LINK)
{ // and it was a link change
if (llGetAttached() != 0 && reciever == NULL_KEY)
{ // if Avatar key isn't empty, somebody is wearing the object
reciever = llDetectedKey(0); // store sitting avatar's key
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // Setting hovertext to current amount earned
llSetTimerEvent(camptime); // amount of time between payments in seconds
}
else if( reciever != NULL_KEY )
{ // if the avatar has gotten up
if(campmoney > 0)
{
llGiveMoney(reciever,campmoney); // give the avatar the amount of money he has earned.
reciever = NULL_KEY; // forget who the receiver was
campmoney=0; // reset earning count to 0
}
else
{
reciever = NULL_KEY; // forget who the receiver was
campmoney = 0; // reset earning count to 0
}
llSetText("Press Wear to earn money by walking around,\nL$"+(string)campadd+" every "+camptimeM+" minutes",<0,1,0>,1); // change the hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call timer(). Disable timer.
}
}
}
timer()
{
campmoney = campmoney+campadd; // current amount + xL$ per camptime
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // update hovertext with currently earned amount
if (llGetAttached() == 0)
{ // Noone's sitting on me, reset the vars
reciever = NULL_KEY; // forget who the receiver was
campmoney = 0; // reset earning count to 0
llSetText("sit here for free money,\nL$" + (string)campadd + " every "+camptimeM+" minutes",<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is wearing object, so no need to call myself anymore. Disable timer.
}
}
}CODE
Thanks for your support!
Hello