Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Help.. Need script test

Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
12-21-2008 21:32
Can anyone please.. test this and tell me what is wrong with it?

coz it just stops after moving from one state to the other.. and dont do anything.

From: someone
//----------------------------------------------------------------------//
// ---------------------------THE FUNDER V2.0---------------------------//
// --------------------ALL COPYRIGHT'S ARE RESERVED---------------------//
// ----------------TREASURED VAMPS & CHOSEN IMMORTALS-------------------//
// ------------ABDULLAH LEMON - [email]ABDULLAH.LEMON@DOMAIN.COM[/email]----------------//
// -------------12-21-2008 MERRY X-MAS & HAPPY NEW YEAR-----------------//
// ----------------------------RC VERSION-------------------------------//
//----------------------------------------------------------------------//

list Confirm_Options = ["<-- YES -->","<-- NO -->"];
list Payment_Options = ["<-- HUD -->","<-- POTION -->","<-- BOTH -->"];

string PaymenURL = "http://www.domain.com/alt.php?";
string N2KURL = "http://w-hat.com/name2key";

vector Green = <0.0, 1.0, 0.0>;
vector White = <1.0, 1.0, 1.0>;
vector Yellow = <1.0, 1.0, 0.0>;
vector Red = <1.0, 0.0, 0.0>;
vector Blue = <0.0, 0.0, 1.0>;

integer listen_Chosen;
integer Listen_Confirm;
integer Listen_Options;
integer channel;
integer PayThis;

key ToucherID;
key CheckKEY;
key PaymentProcess;

string Confirm_Msg = "Please select whether you want to continue with the payment or cancel it";
string Payment_Msg = "Please select the payment option you want";
string Unknown_Chosen;
string PayedUserName;


// DEFAULT STATE
default
{
state_entry() {
channel = ( -1 * (integer)("0x"+llGetSubString((string)llGetKey(),-5,-1)) );
llSetText("FUNDING BOX V2.0 - READY",Green,1);
llSetColor(Green, ALL_SIDES);
}

on_rez(integer start_param) {
llResetScript();
}

touch_start(integer total_number) {
ToucherID = llDetectedKey(0);
if(!llSameGroup(llDetectedKey(0))){
llSetText("LISTENING....",White,1);
llSetColor(White, ALL_SIDES);
llWhisper(0,"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";);
llWhisper(0,"+ Welcome to the funding box V2.0";);
llWhisper(0,"+ I will listen for 30 seconds, Please speak";);
llWhisper(0,"+ the exact name of the chosen one.";);
llWhisper(0,"+ If you need any help, please contact Abdullah Lemon at";);
llWhisper(0,"+ abdullah.lemon[AT]domain.com or on IM";);
llWhisper(0,"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";);
llSetTimerEvent(30.0);
listen_Chosen = llListen( 0, "", ToucherID, "";);
}else{
llWhisper(0,"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";);
llWhisper(0,"+ Sorry, You dont have the right to use this box.";);
llWhisper(0,"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";);
}
}

listen(integer channel, string name, key id, string ChosenName) {
// Remove the listen event and timer
llListenRemove(listen_Chosen);
llSetTimerEvent(0.0);
Unknown_Chosen = ChosenName;
Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
12-21-2008 21:33
.
From: someone


// Set text to processing to inform user that data are being updated
llSetText("PLEASE WAIT, PROCESSING....",Blue,1);
llSetColor(Blue, ALL_SIDES);

// Get the user Key from the internet
CheckKEY = llHTTPRequest(N2KURL+ "?terse=1&name=" +llEscapeURL(ChosenName),[],"";);
//CheckKEY = "00000000-0000-0000-0000-000000000000";
//body = "b77aa6db-34d9-46c2-84f4-92da99a10721";
//userName = llKey2Name(body);

}

http_response(key id, integer status, list meta, string chosenName)
{

// Set text to retraiving data
llSetText("CONNECTED, RETRAIVING DATA....",Blue,1);
llSetColor(Blue, ALL_SIDES);

//Check data and see if all goes well
if(id != CheckKEY) return;
if(status == 499) llSay(0, "Request time out. Please try again.";);
else if(status != 200) llSay(0, "An unknown error occured.";);
//if(body = "00000000-0000-0000-0000-000000000000";)
else if(chosenName == "00000000-0000-0000-0000-000000000000";)
{
// Set text to user not found
llSetText("USER WAS NOT FOUND IN THE SYSTEM, REQUEST RETURNED /n NULL KEY 00000000-0000-0000-0000-000000000000 /n PLEASE NOTE THAT YOU HAVE 30 SECONDS TO CONFIRM PAYMENT",Red,1);
llSetColor(Red, ALL_SIDES);
state Confirm;
}
else
{
// Set text to data were retraived successfully and payment will go to
llSetText("PAYMENT WILL BE MADE TO "+(string)Unknown_Chosen ,Yellow,1);
llSetColor(Yellow, ALL_SIDES);
state Pay;
}
}
}

// Confirm that you want to proceed with the payment
state Confirm
{
state_entry()
{
llSetTimerEvent(30.0);
Listen_Confirm = llListen(0,"",ToucherID,"";);
llDialog(ToucherID, Confirm_Msg, Confirm_Options, channel);
}

listen(integer channel, string name, key id, string answer) {
llListenRemove(Listen_Confirm);
llSetTimerEvent(0.0);
if(answer == "<-- YES -->";)
{
// Set text to payment confirmation to the unknown user
llSetText("PAYMENT WILL BE MADE TO "+(string)Unknown_Chosen ,Yellow,1);
llSetColor(Yellow, ALL_SIDES);
state Pay;
}else{
llSetText("PAYMENT WAS CANCELED, RESETING PLEASE WAIT 5 SECONDS" ,Red,1);
llSetColor(Red, ALL_SIDES);
llSleep(5.0);
llResetScript();
}
}
}

// Pay the money.
state Pay
{
state_entry()
{
llSetTimerEvent(30.0);
Listen_Options = llListen(0,"",ToucherID,"";);
llDialog(ToucherID, Payment_Msg, Payment_Options, channel);
}

listen(integer channel2, string name, key id, string choice)
{
llListenRemove(Listen_Options);
llSetTimerEvent(0.0);
if(choice == "<-- HUD -->";)
{
PayThis = 599;
PayedUserName = llKey2Name(ToucherID);
}else if(choice == "<-- POTION -->";){
PayThis = 249;
PayedUserName = llKey2Name(ToucherID);
}else{
PayThis = 848;
PayedUserName = llKey2Name(ToucherID);
}

PaymentProcess = llHTTPRequest(PaymenURL+"addAmount=true&aviName="+llEscapeURL(PayedUserName)+"&amount="+(string)PayThis+"&aviKey="+(string)Unknown_Chosen,[],"";);
llSetText("REQUESTING PAYMENT FROM SERVER..." ,White,1);
llSetColor(White, ALL_SIDES);
}

http_response(key id, integer status, list meta, string value)
{
PaymentProcess = "b77aa6db-34d9-46c2-84f4-92da99a10721";
if(id != PaymentProcess) return;
if(status == 499) llSay(0, "Request time out. Please try again later.";);
else if(status != 200) llSay(0, "An unknown error occured.";);
else if(value == "nomoney";) llSay(0, "Sorry, the funder is empty.";);
else if(value == "low";) llSay(0, "Sorry, the funder is empty.";);
else if(value == "unauthorized";) llSay(0, "Sorry, the fraud detector has blocked you from using the system.";);
else if(value != "authorized";) llSay(0, "You have already been paid your maximum daily amount.";);
else
{
// Pay money
llGiveMoney(ToucherID, PayThis);
llWhisper(0,"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";);
llWhisper(0,"+ Thank you "+(string)PayedUserName+" for using the funding box";);
llWhisper(0,"+ You have been payed "+(string)PayThis+"L$, for "+(string)Unknown_Chosen);
llWhisper(0,"+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+";);
state default;
}
}
}
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
12-21-2008 22:47
I can see a few bugs...

//if(!llSameGroup(llDetectedKey(0))){
if(llSameGroup(ToucherID)){

Just an opinion on this one. It makes more sense to me.

You use a timer but there's no timer() event in your default state.

timer()
{
llSetTimerEvent(0.0);
llListenRemove(listen_Chosen);
llWhisper(0, "Time out!";);
}

The http_response() event should make the script restart from the beginning in case of error. (Just an cosmetic detail...) And you can use (string)NULL_KEY instead of a bunch of zeroes. (Another cosmetic detail.)

In your state confirm, you don't listen to the dialog.

//Listen_Confirm = llListen(0,"",ToucherID,"";);
Listen_Confirm = llListen(channel,"",ToucherID,"";);

And there's no timer() event to handle the time out.

The same in your state pay.

//Listen_Options = llListen(0,"",ToucherID,"";);
Listen_Options = llListen(channel,"",ToucherID,"";);

The timer() event is also missing.

In the http_response() event, remove the line:

//PaymentProcess = "b77aa6db-34d9-46c2-84f4-92da99a10721";

And put the line

state default;

out of the if/else so that the script restarts in case of success AND in case of error.

That should be it. Especially listening to the dialog should improve things... a lot! :P
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
2 things I've noticed.
12-21-2008 22:59
In states 'confirm' and 'pay' You open a listen on channel 0.
Then you open a dialog that speaks on channel 'channel' (not 0). The answer of the dialog is never heard and the states don't change.

It's also good practice to add a timer before You open a dialog. That way when the user clicks 'Ignore' You can close the open listen and go back to the default state after a set time.

edit:
I took some time to type the above. That's why Kaluura beat me to it, and with a better answer as well :).

Oh and I also just noticed You don't have PERMISSION_DEBIT set anywhere. I don't think it's possible to give money without that.
Kaluura Boa
Polygon Project
Join date: 27 Mar 2007
Posts: 194
12-21-2008 23:16
Exactly... You can't give money without PERMISSION_DEBIT... And, that, I didn't see it!
Abdullah Lemon
Lemons Estates
Join date: 2 Oct 2008
Posts: 56
12-22-2008 00:06
Thank you guys for the much appreciated help.. hehehe.. i forgot the Permission my self too :D

i'll try it once i get home from work.. and i'll tell you what happens.. hope for the best ;-)