allow the pot to grow with each entry
display the current prize
The code has to separate starting and finishing points.
This is the code for the starting point.
CODE
integer godchannel = -3948205;
string waypoint;
vector destination;
integer destset = FALSE;
list whomayride = [];
integer cost = 1;
integer allowedtowarp(key av)
{
integer index = llListFindList(whomayride, [av]);
if(index == -1)
{
return FALSE;
}
return TRUE;
}
addtolist(key id)
{
whomayride += id;
}
removefromlist(key id)
{
integer remove = llListFindList(whomayride, [id]);
whomayride = llDeleteSubList(whomayride, remove, remove);
}
warpPos( vector d ) //R&D by Keknehv Psaltery, ~05/25/2006
{
if ( d.z > 768 ) //Otherwise we'll get stuck hitting the ceiling
d.z = 768;
integer s = (integer)(llVecMag(d-llGetPos())/10)+1; //The number of jumps necessary
if ( s > 100 ) //Try and avoid stack/heap collisions with far away destinations
s = 100; // 1km should be plenty
integer e = (integer)( llLog( s ) / llLog( 2 ) ); //Solve '2^n=s'
list rules = [ PRIM_POSITION, d ]; //The start for the rules list
integer i;
for ( i = 0 ; i < e ; ++i ) //Start expanding the list
rules += rules;
integer r = s - (integer)llPow( 2, e );
if ( r > 0 ) //Finish it up
rules += llList2List( rules, 0, r * 2 + 1 );
llSetPrimitiveParams( rules );
}
string newObj;
default
{
state_entry()
{
llOwnerSay("Reset Confirmed");
llSetText("", <0,0,0>, 0);
llSitTarget(<-0.5,0,-0.5>, ZERO_ROTATION);
waypoint = llGetObjectDesc();
llListen(godchannel + (integer)waypoint, "", "", "");
llSetPayPrice(PAY_HIDE, [cost, PAY_HIDE, PAY_HIDE, PAY_HIDE]);
llOwnerSay("Waypoint #" + llGetObjectDesc() + ", loaded");
}
listen(integer chan, string name, key id, string msg)
{
list command = llParseString2List(msg, ["|"], []);
if(msg == "resetall")
{
llResetScript();
}
if(llList2String(command, 0) == "ping")
{
llShout(godchannel, "pong|" + (string)llGetPos());
}
if(llList2String(command, 0) == "setdest")
{
llOwnerSay("Registered");
destination = (vector)llList2String(command, 1);
destset = TRUE;
}
}
touch_start(integer touches)
{
if(llDetectedKey(0) == llGetOwner() )
{
llOwnerSay("whomayride:" + llDumpList2String(whomayride, ", "));
llOwnerSay("whomayanswer:" + llDumpList2String(whomayride, ", "));
}
}
changed(integer change) { // something changed
if (change & CHANGED_LINK) { // and it was a link change
// llSleep(0.5); // llUnSit works better with this delay
key av = llAvatarOnSitTarget();
vector ourPos = llGetPos();
if (av) { // somebody is sitting on me
if( (destset == TRUE) && (allowedtowarp(av) == TRUE))
{
warpPos(destination);
llSay(godchannel + (integer)waypoint + 1, "delivered|" + (string)av);
llSleep(1.5); // llUnSit works better with this delay
removefromlist(av);
}
else
{
llSay(0, "Please pay " + (string)cost + " to play");
}
llUnSit(av);
if(destset == TRUE)
{
warpPos(ourPos);
}
}
}
}
money(key giver, integer amount)
{
addtolist(giver);
}
}
This is the code for the finishing point.
CODE
integer prize = 10;
integer godchannel = -3948205;
integer gotresponse = TRUE;
integer objectpolled = 1;
integer objectcount = 0;
list waypoints = [];
integer gettinglocations = TRUE;
integer givinglocations = FALSE;
startscan()
{
llSetTimerEvent(5);
gotresponse = FALSE;
}
default
{
on_rez(integer num)
{
llResetScript();
}
state_entry()
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
touch_start(integer touches)
{
if(llGetOwner() != llDetectedKey(0))
{
llWhisper(0, "Please head to the starting point to play!");
return;
}
integer i;
for(i=0;i<=50;i++)
{
llShout(godchannel + i, "resetall");
}
llSleep(2);
gotresponse = TRUE;
objectpolled = 1;
objectcount = 0;
waypoints = [];
gettinglocations = TRUE;
givinglocations = FALSE;
startscan();
llListen(godchannel, "", "", "");
llShout(godchannel + objectpolled, "ping");
}
listen(integer chan, string name, key id, string msg)
{
llOwnerSay(":::::: I HEARD: " + "[" + (string)chan + "]" + name + ":" + msg);
list command = llParseString2List(msg, ["|"], []);
if(llList2String(command, 0) == "pong")
{
gotresponse = TRUE;
llOwnerSay("Registering " + name);
waypoints += llList2String(command, 1);
}
else if(llList2String(command, 0) == "delivered")
{
key winner = llList2Key(command, 1);
llShout(0, llKey2Name(winner) + " HAS WON " + (string)prize + " LINDENS!");
llGiveMoney(winner, prize);
}
}
timer()
{
if(gettinglocations == TRUE)
{
if(gotresponse == FALSE)
{
llOwnerSay("Waypoints: " + llDumpList2String(waypoints, " / "));
llListen(godchannel + objectcount + 1, "", "", "");
gettinglocations = FALSE;
givinglocations = TRUE;
}
else //means we got a response
{
objectcount = objectpolled;
objectpolled++;
gotresponse = FALSE;
llShout(godchannel + objectpolled, "ping");
llOwnerSay((string)(godchannel + objectpolled) + ": Ping");
}
}
else if(givinglocations == TRUE)
{
integer i;
llShout(godchannel + objectcount, "setdest|" + (string)llGetPos());
for(i=objectcount - 1;i>0;i--)
{
llShout(godchannel + i, "setdest|" + llList2String(waypoints, i)); //sets object i to destination i+1
llSleep(1);
}
givinglocations = FALSE;
llSetTimerEvent(0);
}
}
}
Any help would be appreciated. Thanx in advance!