I'm having a problem...
I got two scripts,
The first one checks agains an MySQL database for two values, "cost" and "credits".
Th script then calculates cost - credits = total cost and sends the rsult, among some other data to be processed in another scipt.
What I need to hapend here, is:
if ( total_cost == 0)
{
Extend_no_pay();
}
else
{
Pay_then_extend();
}
If it goes to Extend_no_pay(), it should then send an message to the next script, and not continue with this script. I first thought llDie(); could help me with that, but fortunately I checked it first and saw that it will delete my object if I do that. Glad I didn't.

How ever,
if it goes to Pay_then_extend, I need to trigger the money event so that the user can pay the machine.
When the machine has been payed, it will go to the next event, which is another llHTTPRequest(), and then send message to the third script (the same as above).
I have the script working now, except for the if function to cech if Total_Cost is 0 or not.
The full script right now looks like this:
CODE
key customer_key;
integer Correct_amount;
string DO_EXP_ADD;
string server = "http://server address/";
string auth = "Auth Key";
list extend_msg;
string msg;
string Owner;
integer Portbase;
integer Cost;
integer Credits;
string Expire;
integer Total_Cost;
string Update_Friend_Credit;
string Update_Own_Credit;
key UUID;
key DO_F_CRED_ADD;
key DO_O_CRED_ADD;
key Tadao = "05c9fe42-8d89-401d-a9a5-2d82af58e16f";
default
{
state_entry()
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT);
}
link_message(integer sender_num, integer num, string extend_msg_str, key id)
{
extend_msg = llParseString2List(extend_msg_str, ["|"], []);
msg = llList2String(extend_msg,0);
if ( msg == "extend_a_friend" )
{
Owner = llList2String(extend_msg,1);
Cost = llList2Integer(extend_msg,2);
Credits = llList2Integer(extend_msg,3);
UUID = llList2Key(extend_msg,4);
Expire = llList2String(extend_msg,5);
Pbase = llList2Integer(extend_msg,6);
customer_key = llList2Key(extend_msg,7);
Total_Cost = Cost - Credits;
llInstantMessage(customer_key, "The monthly cost for " +Owner +"'s "
+"services is: $L" +(string)Cost
+" /30 days.\n"
+"The account is already credited with: " +(string)Credits
+" Lindens.\n"
+"The services expires at: " +Expire +"\n"
+"In order to update the services with another 30 days, please pay: $L" +(string)Total_Cost);
Correct_amount = Total_Cost;
Update_Friend_Credit = "?auth=" +auth
+"&action=creditupdate"
+"&uuid=" +(string)UUID
+"&credit="+(string)Correct_amount;
}
else if ( msg == "extend_your_own" )
{
Owner = llList2String(extend_msg,1);
Cost = llList2Integer(extend_msg,2);
Credits = llList2Integer(extend_msg,3);
Pbase = llList2Integer(extend_msg,4);
Expire = llList2String(extend_msg,5);
UUID = llList2Key(extend_msg,6);
Total_Cost = Cost - Credits;
llInstantMessage(UUID, "The monthly cost for " +Owner +"'s "
+"services is: $L" +(string)Cost
+" /30 days.\n"
+"The account is already credited with: " +(string)Credits
+" Lindens.\n"
+"The services expires at: " +Expire +"\n"
+"In order to update the services with another 30 days, please pay: $L" +(string)Total_Cost);
Correct_amount = Total_Cost;
Update_Own_Credit = "?auth=" +auth
+"&action=creditupdate"
+"&uuid=" +(string)UUID
+"&credit="+(string)Correct_amount;
}
}
money(key id, integer amount)
{
customer_key = id;
// If user pays correct amount, Add the money to users account
if (amount == Correct_amount)
{
if ( msg == "extend_a_friend" )
{
DO_F_CRED_ADD = llHTTPRequest(server + "api.php" + Update_Friend_Credit, [ HTTP_METHOD, "GET"], "");
}
else if ( msg == "extend_your_own" )
{
DO_O_CRED_ADD = llHTTPRequest(server +"api.php" +Update_Own_Credit, [ HTTP_METHOD, "GET"], "");
}
}
// If user pays less than total amount, pay back, and tell him/her to re-do the process.
else if ( amount < Correct_amount )
{
llInstantMessage(customer_key, "Sorry, you didn't pay the right amount. You need to pay exactly L$" +(string)Total_Cost
+"in order to update the expiry date."
+"\nYour money will be paid back shortly!");
llGiveMoney(id, amount);
}
// And in case they pay too much!
else
{
integer refund = amount - Correct_amount;
llInstantMessage(customer_key, "You paid too much. You will be refunded with L$ "
+(string)refund +"shortly.");
llGiveMoney(id, refund);
if ( msg == "extend_a_friend" )
{
DO_F_CRED_ADD = llHTTPRequest(server + "api.php" + Update_Friend_Credit, [ HTTP_METHOD, "GET"], "");
}
else if ( msg == "extend_your_own" )
{
DO_O_CRED_ADD = llHTTPRequest(server +"api.php" +Update_Own_Credit, [ HTTP_METHOD, "GET"], "");
}
}
}
http_response(key request_id, integer status, list metadata, string body)
{
if ( request_id == DO_F_CRED_ADD )
{
list HTTPReply_Upd_Cred = llParseString2List(body, ["|"], []);
string status = llList2String(HTTPReply_Upd_Cred,0);
string err_msg = llList2String(HTTPReply_Upd_Cred,1);
if ( status == "status=s" )
{
string Send_Upd_Exp_String = "?auth=" +auth
+"&action=updateexpiry"
+"&Pbase=" +(string)Pbase
+"&expiry_add=1month";
llMessageLinked(LINK_ROOT, 0, "DO_UPDATE_F|" +(string)UUID +"|" +(string)customer_key +"|" +Send_Upd_Exp_String, NULL_KEY);
}
else if ( status == "status=f" )
{
llInstantMessage(customer_key, "Something went wrong, error message given was: " +err_msg +"\n"
+"Please contact Tadao Nordenskiold ( secondlife:///app/agent/" +(string)Tadao +"/about ) for help!\n"
+" Your money will be returned shortly!");
llInstantMessage(Tadao, "Something went wrong when user " +llKey2Name(customer_key)
+" tried to update his/her or his/her friends services using method " +msg +".\n"
+"Please contact them using this link! ( secondlife:///app/agent/" +(string)customer_key +"/about ).\n"
+"The error message given was: " +err_msg);
}
}
if ( request_id == DO_O_CRED_ADD )
{
list HTTPReply_Upd_Cred = llParseString2List(body, ["|"], []);
string status = llList2String(HTTPReply_Upd_Cred,0);
string err_msg = llList2String(HTTPReply_Upd_Cred,1);
if ( status == "status=s" )
{
string Send_Upd_Exp_String = "?auth=" +auth
+"&action=updateexpiry"
+"&Pbase=" +(string)Pbase
+"&expiry_add=1month";
llMessageLinked(LINK_ROOT, 0, "DO_UPDATE_O|" +(string)UUID +"|SCRAP|" +Send_Upd_Exp_String, NULL_KEY);
}
else if ( status == "status=f" )
{
llInstantMessage(UUID, "Something went wrong, error message given was: " +err_msg +"\n"
+"Please contact Tadao Nordenskiold ( secondlife:///app/agent/" +(string)Tadao +"/about ) for help!\n"
+" Your money will be returned shortly!");
llInstantMessage(Tadao, "Something went wrong when user " +llKey2Name(customer_key)
+" tried to update his or her friends services using method " +msg +".\n"
+"Please contact them using this link! ( secondlife:///app/agent/" +(string)customer_key +"/about ).\n"
+"The error message given was: " +err_msg);
}
}
}
}