Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Progressive Pot/Prize Board Help Needed

Wyldchard Vanguard
Registered User
Join date: 23 Oct 2006
Posts: 32
12-12-2006 11:29
I'm trying to update a game of mine. I was wondering if anyone could help me add code that would do the folowing two things:
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!
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-12-2006 13:25
You dont say at which end you want to display the amount.

Without delving to deep into the code it would appear that the what you want to achieve can be attained by altering the code in the timer event. Just increment the prize at this point and then use a llSetText call (or something else if you prefer) to display the value.
2fast4u Nabob
SL-ice.net
Join date: 28 Dec 2005
Posts: 542
12-12-2006 14:07
It looks like someone pays the starting point object and the ending object pays a prize. The original starting point just accepts money and moves the avatar that sits on the object somewhere.

When the starting point arrives at the ending point, it tells the ending point that the avatar has been delivered and pays L$10.

This looks like a teleporter for which one pays. I have modified the script to have the end point keep track of how much it has been paid. The end point also pays out the amount in the pot when it gets the 'delivered' message and clears the pot.

This means that the first person that pays and gets delivered gets the pot. All others that paid get nothing.

Make sure that you understand the following statement......

** Use of this code is at your own risk...I am not responsible for any damage or loss of any kind.**


It should be quite clear that you are using this code at your own risk.

You should know that as it is written now, there is the possibility that someone can manipulate this to get it to pay them even though they have paid nothing...this opens the possibility of loosing all of your L$.

This problem is caused by the complete lack of security in the original script - I just added to what was already there. Moreover, since this code is now public, anyone can read through the code and can easily discover the flaw.

I highly recommend that you get someone to secure this for you.

*** I have not tested this in-world. ***

* Again .... Use of this code is at your own risk...I am not responsible for any damage or loss of any kind. *


Code for the Starting object:
** Use of this code is at your own risk...I am not responsible for any damage or loss of any kind.**

CODE


// ** Use of this code is at your own risk...not responsible for any damage or loss of any kind.**

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");
totalInPot = 0;
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);
llShout(godchannel, "paid|" + (string)amount);
}

}

// ** Use of this code is at your own risk...not responsible for any damage or loss of any kind.**



Code for the Endig point:
** Use of this code is at your own risk...not responsible for any damage or loss of any kind.**

CODE

// ** Use of this code is at your own risk...not responsible for any damage or loss of any kind.**

integer prize = 0;

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);
prize = 0;
}
else if(llList2String(commnad,0) == "paid")
{
prize += (integer)llList2String(command,1);
llSetText("There is L$" + (string)prize + " in the pot",<0.0,1.0,0.0>,1.0);
}
}

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);
}
}
}

// ** Use of this code is at your own risk...not responsible for any damage or loss of any kind.**



Good luck
Wyldchard Vanguard
Registered User
Join date: 23 Oct 2006
Posts: 32
Security Concerns
12-12-2006 18:06
From: someone

You dont say at which end you want to display the amount.

Without delving to deep into the code it would appear that the what you want to achieve can be attained by altering the code in the timer event. Just increment the prize at this point and then use a llSetText call (or something else if you prefer) to display the value.


I wanted to display the code at the beginning of the game.

From: someone

It should be quite clear that you are using this code at your own risk.

You should know that as it is written now, there is the possibility that someone can manipulate this to get it to pay them even though they have paid nothing...this opens the possibility of loosing all of your L$.

This problem is caused by the complete lack of security in the original script - I just added to what was already there. Moreover, since this code is now public, anyone can read through the code and can easily discover the flaw.

I highly recommend that you get someone to secure this for you.


Thx for helping with the code. I'm going to try it out.

Actually, those two points are just two of a series of points.

The security actually is in the "X" numbers of points placed between those two points. The first point as you pointed out is just a "collector" point. The final point is just a payment point.

It will only pay out based on information it receives from the points within istself and the first one.

I know it might sound confusing but you may stop by in game and see my project.
http://slurl.com/secondlife/Walleye/204/1/103/?u=9a1ac7d5a179853d661c479b7b347718