Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

ATM trouble

Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-24-2007 17:46
I made a script for an atm and server, thanks to those who helped me...with a lot. I am running into trouble.
ATM SCRIPTS:
MAIN
CODE

integer lisID;
integer current_chan;
integer rand_chan()
{
llListenRemove(lisID);
integer rand = -llRound((llFrand(32000000 - 200000) + 20000000));
current_chan = rand;
lisID = llListen(current_chan,"","","");
return current_chan;
}

integer mode;
integer allow;
integer ok2;
integer withdraw_payment;
integer in_use;
integer eml;
integer with;
integer last_amount;

string server;
string pmode;

key user;
key last_paid;
key aiden = "2e7cd8f1-c544-493c-a3c8-4961c5bbd409"; // so you will get the money
integer user_balance;

send(string address,string message)
{
eml++;
if(eml == 6) eml = 1;

llMessageLinked(LINK_SET,eml,message,address);
}

default
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
llSetText("",<1,1,1>,1);
llSay(0,"Please say the key you recived upon purchase.");
mode = 1;
lisID = llListen(0,"",llGetOwner(),"");
}

listen(integer channel,string na,key id,string message)
{
if(mode == 1)
{
server = message;
llSay(0,"Key recieved: "+message+". Is this information correct? (Answer yes / no)");
mode = 2;
}

else if(mode == 2)
{
if(llToLower(message) == "yes")
{
llListenRemove(lisID);
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
else if(llToLower(message) == "no")
{
llOwnerSay("Please say the correct key in chat.");
mode = 1;
}
}
}

run_time_permissions(integer perm)
{
if(perm && PERMISSION_DEBIT)
{
state ok;
}
else
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
}
}

state ok
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
llMessageLinked(LINK_SET,999,(string)server,server);
ok2 = FALSE;
in_use = FALSE;
with = FALSE;
rand_chan();
eml = 0;
withdraw_payment = 1;
user = NULL_KEY;
llAllowInventoryDrop(FALSE);
llOwnerSay("Registarting with the bank server...");
send(server,"title "+(string)llGetKey());
llSetText("ATM LOADED", <1,1,1>, PI);
}

touch_start(integer num)
{
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llGetOwner(),"Please choose one option:\n1) Set withdraw payment\n--- Current withdraw payment: L$"+(string)withdraw_payment+"\n2) Load your account",["1","2"],rand_chan());
}
else if(llDetectedKey(0) != llGetOwner() && user == NULL_KEY)
{
user = llDetectedKey(0);
in_use = TRUE;
llWhisper(0,"Please hold. Checking account...");
send(server,"check "+(string)user);
}
}

listen(integer channel,string name,key id,string message)
{
if(id == llGetOwner() && channel == current_chan)
{
if(message == "2")
{
user = id;
in_use = TRUE;
llWhisper(0,"Please hold. Checking account...");
send(server,"check "+(string)user);
}

if(message == "1")
{
llDialog(id,"The withdraw amount, must be between 0 to 5.",["L$ 3","L$ 4","L$ 5","L$ 0","L$ 1","L$ 2"],rand_chan());
ok2 = TRUE;
lisID = llListen(current_chan,"",id,"");
llSetTimerEvent(15);
}

else if(ok2)
{
withdraw_payment = (integer)llGetSubString(message,2,-1);
ok2 = FALSE;
llOwnerSay("Setting withdraw charge to L$"+(string)withdraw_payment);
llListenRemove(lisID);
llSetTimerEvent(0);
}
}

if(channel == current_chan && llGetAgentSize(id) != <0,0,0>)
{
if(message == "Deposit")
{
llSetPayPrice(20,[10,50,100,500]);
llWhisper(0,"To deposit, simply pay the atm any amount of money.");
pmode = "deposit";
llSetTimerEvent(30);
}

if(message == "Done")
{
llSetPayPrice(20,[10,50,100,500]);
in_use = FALSE;
user = NULL_KEY;
llSetTimerEvent(30);
}

if(message == "Withdraw")
{
if(withdraw_payment == 0)
{
llWhisper(0,"Please say the amount you would like to withdraw in chat");
with = TRUE;
llListenRemove(lisID);
lisID = llListen(0,"",id,"");
// llOwnerSay((string)with +","+message);
return;
}
else
{
llWhisper(0,"Please pay L$"+(string)withdraw_payment+" to the atm, to withdraw.");
llSetPayPrice(0,[withdraw_payment]);
pmode = "withdraw";
}
llSetTimerEvent(30);
}
}
// llOwnerSay((string)with +","+message);
if(channel == 0 && llGetAgentSize(id) != <0,0,0> && with)
{
string temp = message;
llWhisper(0,"Requesting withdraw of L$"+(string)llAbs(llRound((integer)temp))+"...");
send(server,"withdraw "+(string)llAbs(llRound((integer)temp))+","+(string)id);
with = FALSE;
llListenRemove(lisID);
llSetTimerEvent(0);
}

llListenRemove(lisID);
}

timer()
{
ok2 = FALSE;
llListenRemove(lisID);
llSetPayPrice(20,[10,50,100,500]);
in_use = FALSE;
user = NULL_KEY;
with = FALSE;
llWhisper(0,"Time out.");
llSetTimerEvent(0);
}

link_message(integer num,integer channel,string message,key id)
{
if(channel == 50)
{
if(message == "activate")
{
lisID = llListen(0,"","","");
llOwnerSay("ATM loaded!");
}

if(message == "too high")
{
if(withdraw_payment != 0) llGiveMoney(user,withdraw_payment);
llWhisper(0,"I'm sorry, you do not have enough L$ in your account to make this kind of withdraw.");
llSetTimerEvent(1);
}

if(llGetSubString(message,0,5) == "vaild ")
{
if(last_amount != 0){ llGiveMoney(aiden,last_amount); last_amount = 0; user = last_paid;}
string temp = llGetSubString(message,6,-1);
user_balance = (integer)temp;
llDialog(user,"Your balance: L$"+temp+". Please choose one of the following options:",["Deposit","Withdraw","Done"],rand_chan());
llSetTimerEvent(60);
}

if(message == "no account" && in_use)
{
llDialog(user,"I'm sorry, but it seems you do not have an account. To open an account please pay me:\nPremium - L$10\nBetter Basic - L$7\nBasic - L$5",["Close"],1234412);
llSetPayPrice(10,[5,7,10]);
pmode = "create";
llSetTimerEvent(30);
}

else if(message == "no account" && !in_use)
{
llDialog(user,"I'm sorry, but it seems you do not have an account. To open an account please pay me:\nPremium - L$10\nBetter Basic - L$7\nBasic - L$5",["Close"],1234412);
user = last_paid;
llSetPayPrice(10,[5,7,10]);
pmode = "create";
llSetTimerEvent(30);
}
}
}

money(key id,integer amount)
{
if(id == user)
{
if(pmode == "create")
{
string type;

if(amount == 5)
{
llWhisper(0,"Opening a new basic account for "+llKey2Name(id)+"...");
type = "b";
llGiveMoney(aiden,3);
llSetTimerEvent(0);
pmode = "deposit";
}

if(amount == 7)
{
llWhisper(0,"Opening a new better basic account for "+llKey2Name(id)+"...");
type = "bb";
llGiveMoney(aiden,5);
llSetTimerEvent(0);
pmode = "deposit";
}

if(amount == 10)
{
llWhisper(0,"Opening a new premium account for "+llKey2Name(id)+"...");
type = "p";
llGiveMoney(aiden,5);
llSetTimerEvent(0);
pmode = "deposit";
}

if(amount == 10 || amount == 7 || amount == 5)
{

}
else
{
type = "";
llGiveMoney(id,amount);
llWhisper(0,"You must pay one of these amounts: L$5, L$7, L$10, to open an account");
llSetTimerEvent(15);
}

if(type != "") send(server,"create "+type+","+(string)id+","+llKey2Name(id));
}

else if(pmode == "deposit")
{
send(server,"deposit "+(string)amount+","+(string)id);
llGiveMoney(aiden,amount);
llSetTimerEvent(15);
}

else if(pmode == "withdraw")
{
if(amount == withdraw_payment)
{
llWhisper(0,"Please say the amount you would like to withdraw. For example: \"withdraw 10\".");
with = TRUE;
lisID = llListen(0,"",id,"");
}
else
{
llWhisper(0,"The amount you paid, doesn't match the withdraw charge. (L$"+(string)withdraw_payment+")");
with = FALSE;
llGiveMoney(id,amount);
}
llSetTimerEvent(15);
}
}

if(user == NULL_KEY)
{
llOwnerSay((string)user);
last_paid = id;
last_amount = amount;
send(server,"deposit "+(string)amount+","+(string)id);
llSetTimerEvent(15);
}

else if(id != user)
{
llGiveMoney(id,amount);
llWhisper(0,"ATM is in use.");
}
}
}

Send Scripts: 5 of them, but pretty much all the same.
CODE

integer lisID;
integer current_chan;
integer rand_chan()
{
llListenRemove(lisID);
integer rand = -llRound((llFrand(32000000 - 200000) + 20000000));
current_chan = rand;
lisID = llListen(current_chan,"","","");
return current_chan;
}

integer mode;
integer allow;
integer ok2;
integer withdraw_payment;
integer in_use;
integer eml;
integer with;
integer last_amount;

string server;
string pmode;

key user;
key last_paid;
key aiden = "2e7cd8f1-c544-493c-a3c8-4961c5bbd409"; // so you will get the money
integer user_balance;

send(string address,string message)
{
eml++;
if(eml == 6) eml = 1;

llMessageLinked(LINK_SET,eml,message,address);
}

default
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
llSetText("",<1,1,1>,1);
llSay(0,"Please say the key you recived upon purchase.");
mode = 1;
lisID = llListen(0,"",llGetOwner(),"");
}

listen(integer channel,string na,key id,string message)
{
if(mode == 1)
{
server = message;
llSay(0,"Key recieved: "+message+". Is this information correct? (Answer yes / no)");
mode = 2;
}

else if(mode == 2)
{
if(llToLower(message) == "yes")
{
llListenRemove(lisID);
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
else if(llToLower(message) == "no")
{
llOwnerSay("Please say the correct key in chat.");
mode = 1;
}
}
}

run_time_permissions(integer perm)
{
if(perm && PERMISSION_DEBIT)
{
state ok;
}
else
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
}
}

state ok
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
llMessageLinked(LINK_SET,999,(string)server,server);
ok2 = FALSE;
in_use = FALSE;
with = FALSE;
rand_chan();
eml = 0;
withdraw_payment = 1;
user = NULL_KEY;
llAllowInventoryDrop(FALSE);
llOwnerSay("Registarting with the bank server...");
send(server,"title "+(string)llGetKey());
llSetText("ATM LOADED", <1,1,1>, PI);
}

touch_start(integer num)
{
if(llDetectedKey(0) == llGetOwner())
{
llDialog(llGetOwner(),"Please choose one option:\n1) Set withdraw payment\n--- Current withdraw payment: L$"+(string)withdraw_payment+"\n2) Load your account",["1","2"],rand_chan());
}
else if(llDetectedKey(0) != llGetOwner() && user == NULL_KEY)
{
user = llDetectedKey(0);
in_use = TRUE;
llWhisper(0,"Please hold. Checking account...");
send(server,"check "+(string)user);
}
}

listen(integer channel,string name,key id,string message)
{
if(id == llGetOwner() && channel == current_chan)
{
if(message == "2")
{
user = id;
in_use = TRUE;
llWhisper(0,"Please hold. Checking account...");
send(server,"check "+(string)user);
}

if(message == "1")
{
llDialog(id,"The withdraw amount, must be between 0 to 5.",["L$ 3","L$ 4","L$ 5","L$ 0","L$ 1","L$ 2"],rand_chan());
ok2 = TRUE;
lisID = llListen(current_chan,"",id,"");
llSetTimerEvent(15);
}

else if(ok2)
{
withdraw_payment = (integer)llGetSubString(message,2,-1);
ok2 = FALSE;
llOwnerSay("Setting withdraw charge to L$"+(string)withdraw_payment);
llListenRemove(lisID);
llSetTimerEvent(0);
}
}

if(channel == current_chan && llGetAgentSize(id) != <0,0,0>)
{
if(message == "Deposit")
{
llSetPayPrice(20,[10,50,100,500]);
llWhisper(0,"To deposit, simply pay the atm any amount of money.");
pmode = "deposit";
llSetTimerEvent(30);
}

if(message == "Done")
{
llSetPayPrice(20,[10,50,100,500]);
in_use = FALSE;
user = NULL_KEY;
llSetTimerEvent(30);
}

if(message == "Withdraw")
{
if(withdraw_payment == 0)
{
llWhisper(0,"Please say the amount you would like to withdraw in chat");
with = TRUE;
llListenRemove(lisID);
lisID = llListen(0,"",id,"");
// llOwnerSay((string)with +","+message);
return;
}
else
{
llWhisper(0,"Please pay L$"+(string)withdraw_payment+" to the atm, to withdraw.");
llSetPayPrice(0,[withdraw_payment]);
pmode = "withdraw";
}
llSetTimerEvent(30);
}
}
// llOwnerSay((string)with +","+message);
if(channel == 0 && llGetAgentSize(id) != <0,0,0> && with)
{
string temp = message;
llWhisper(0,"Requesting withdraw of L$"+(string)llAbs(llRound((integer)temp))+"...");
send(server,"withdraw "+(string)llAbs(llRound((integer)temp))+","+(string)id);
with = FALSE;
llListenRemove(lisID);
llSetTimerEvent(0);
}

llListenRemove(lisID);
}

timer()
{
ok2 = FALSE;
llListenRemove(lisID);
llSetPayPrice(20,[10,50,100,500]);
in_use = FALSE;
user = NULL_KEY;
with = FALSE;
llWhisper(0,"Time out.");
llSetTimerEvent(0);
}

link_message(integer num,integer channel,string message,key id)
{
if(channel == 50)
{
if(message == "activate")
{
lisID = llListen(0,"","","");
llOwnerSay("ATM loaded!");
}

if(message == "too high")
{
if(withdraw_payment != 0) llGiveMoney(user,withdraw_payment);
llWhisper(0,"I'm sorry, you do not have enough L$ in your account to make this kind of withdraw.");
llSetTimerEvent(1);
}

if(llGetSubString(message,0,5) == "vaild ")
{
if(last_amount != 0){ llGiveMoney(aiden,last_amount); last_amount = 0; user = last_paid;}
string temp = llGetSubString(message,6,-1);
user_balance = (integer)temp;
llDialog(user,"Your balance: L$"+temp+". Please choose one of the following options:",["Deposit","Withdraw","Done"],rand_chan());
llSetTimerEvent(60);
}

if(message == "no account" && in_use)
{
llDialog(user,"I'm sorry, but it seems you do not have an account. To open an account please pay me:\nPremium - L$10\nBetter Basic - L$7\nBasic - L$5",["Close"],1234412);
llSetPayPrice(10,[5,7,10]);
pmode = "create";
llSetTimerEvent(30);
}

else if(message == "no account" && !in_use)
{
llDialog(user,"I'm sorry, but it seems you do not have an account. To open an account please pay me:\nPremium - L$10\nBetter Basic - L$7\nBasic - L$5",["Close"],1234412);
user = last_paid;
llSetPayPrice(10,[5,7,10]);
pmode = "create";
llSetTimerEvent(30);
}
}
}

money(key id,integer amount)
{
if(id == user)
{
if(pmode == "create")
{
string type;

if(amount == 5)
{
llWhisper(0,"Opening a new basic account for "+llKey2Name(id)+"...");
type = "b";
llGiveMoney(aiden,3);
llSetTimerEvent(0);
pmode = "deposit";
}

if(amount == 7)
{
llWhisper(0,"Opening a new better basic account for "+llKey2Name(id)+"...");
type = "bb";
llGiveMoney(aiden,5);
llSetTimerEvent(0);
pmode = "deposit";
}

if(amount == 10)
{
llWhisper(0,"Opening a new premium account for "+llKey2Name(id)+"...");
type = "p";
llGiveMoney(aiden,5);
llSetTimerEvent(0);
pmode = "deposit";
}

if(amount == 10 || amount == 7 || amount == 5)
{

}
else
{
type = "";
llGiveMoney(id,amount);
llWhisper(0,"You must pay one of these amounts: L$5, L$7, L$10, to open an account");
llSetTimerEvent(15);
}

if(type != "") send(server,"create "+type+","+(string)id+","+llKey2Name(id));
}

else if(pmode == "deposit")
{
send(server,"deposit "+(string)amount+","+(string)id);
llGiveMoney(aiden,amount);
llSetTimerEvent(15);
}

else if(pmode == "withdraw")
{
if(amount == withdraw_payment)
{
llWhisper(0,"Please say the amount you would like to withdraw. For example: \"withdraw 10\".");
with = TRUE;
lisID = llListen(0,"",id,"");
}
else
{
llWhisper(0,"The amount you paid, doesn't match the withdraw charge. (L$"+(string)withdraw_payment+")");
with = FALSE;
llGiveMoney(id,amount);
}
llSetTimerEvent(15);
}
}

if(user == NULL_KEY)
{
llOwnerSay((string)user);
last_paid = id;
last_amount = amount;
send(server,"deposit "+(string)amount+","+(string)id);
llSetTimerEvent(15);
}

else if(id != user)
{
llGiveMoney(id,amount);
llWhisper(0,"ATM is in use.");
}
}
}
Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-24-2007 17:47
Main Server Script
CODE

integer storage_num;
integer eml;
integer reciver = 50;
integer storage = 60;
integer create_account = 61;
integer add_remove_money = 62;
integer add_remove_money_control = 63;
integer check_account = 64;
integer allow;
integer ok;
integer ok2;
integer line_count;
integer total;
integer totalu;
integer count;
integer mode;
key dataRequest;

key atm;
string user;
key controler;
integer paid_amount;
key paying_user;
string c_user;
string title;
vector title_color;

list cont = [];

integer lisID;
integer current_chan;
integer rand_chan()
{
llListenRemove(lisID);
integer rand = -llRound((llFrand(32000000 - 20000000) + 20000000));
current_chan = rand;
lisID = llListen(current_chan,"","","");
return current_chan;
}

send(string address,string message)
{
eml++;
if(eml > 3) eml = 1;
llMessageLinked(LINK_SET,eml,message,address);
}

default
{
state_entry()
{
allow = FALSE;
eml = 0;
storage_num = 1;
ok = FALSE;
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}

run_time_permissions(integer perm)
{
if(perm && PERMISSION_DEBIT)
{
allow = TRUE;
llMessageLinked(LINK_SET,60,"activate 1","storage");
line_count = 0;
dataRequest = llGetNotecardLine("controllers",line_count);
}
else
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
}

touch_start(integer num)
{
if(llDetectedKey(0) == llGetOwner() || llListFindList(cont,[llDetectedName(0)]) != -1)
{

ok = FALSE;
llDialog(llDetectedKey(0),"Please choose one of the following options:\n1) Add, remove or Delete account\n2) Re-Read controllers note (Owner only)\n3) Change ATM title\n4) Rate update (Owner only)\n5) Report\n6) Take Monthly fees.",["4","5","6","1","2","3"],rand_chan());
}
}

timer()
{
if(mode == 1)
{
send(atm,"not found,"+title+","+(string)title_color);
mode = 0;
return;
}

if(mode == 1)
{
llDialog(controler,"User was not found",["Close"],123);
controler = NULL_KEY;
mode = 0;
return;
}

if(mode == 3)
{
llMessageLinked(LINK_SET,storage,"send","send not found");
llMessageLinked(LINK_SET,storage,(string)paying_user+","+(string)paid_amount,"payment");
}

llListenRemove(lisID);
ok = FALSE;
llSetTimerEvent(0);
mode = -1;
}

listen(integer channel,string name,key id,string message)
{
if(id == llGetOwner() || llListFindList(cont,[name]) != -1)
{
if(message == "1" && channel == current_chan)
{
llWhisper(0,"Please say the avatar name you would like to edit. (full name, for example: \"Unique Nerd\")");
ok = TRUE;
llListenRemove(lisID);
lisID = llListen(0,"",id,"");
llSetTimerEvent(30);
}

if(ok && channel == 0)
{
c_user = message;
controler = id;
llWhisper(0,"Searching for \""+message+"\"...");
llListenRemove(lisID);
ok = FALSE;
mode = 2;
llSetTimerEvent(3);
llMessageLinked(LINK_SET,add_remove_money_control,"f "+c_user,id);
}

if(message == "2" && id == llGetOwner() && channel == current_chan)
{
line_count = 0;
dataRequest = llGetNotecardLine("controllers",line_count);
llSetTimerEvent(30);
llListenRemove(lisID);
}

if(message == "3" && channel == current_chan)
{
llWhisper(0,"Please say the title text now on channel 1.");
ok2 = 1;
llListenRemove(lisID);
lisID = llListen(1,"",id,"");
llSetTimerEvent(30);
}

if(message == "4" && id == llGetOwner() && channel == current_chan)
{
llOwnerSay("Doing a rate adding!");
llMessageLinked(LINK_SET,add_remove_money,"add rate","");
}

if(message == "5" && channel == current_chan)
{
llWhisper(0,"Requesting report...");
llMessageLinked(LINK_SET,add_remove_money_control,"report","");
total = 0;
totalu = 0;
count = 0;
}

if(message == "6" && id == llGetOwner() && channel == current_chan)
{
llOwnerSay("Doing a payment taking.");
llMessageLinked(LINK_SET,add_remove_money,"take payment","");
}

if(ok2 == 1 && channel == 1)
{
title = message;
llWhisper(0,"New title text: "+title+". Please say title color vector (for exmaple: <1,1,1>)");
ok2 = 2;
llSetTimerEvent(30);
}

else if(ok2 == 2 && channel == 1)
{
title_color = (vector)message;
llWhisper(0,"New title color: "+message+". Title changed.");
ok2 = FALSE;
llSetTimerEvent(0);
llListenRemove(lisID);
}
}
}

dataserver(key queryID,string data)
{
if(data != EOF)
{
if((llSubStringIndex(data, "#") != 0) && (data != "") && (data != " "))
{
cont += data;

line_count++;
dataRequest = llGetNotecardLine("controllers",line_count);
}
else
{
line_count++;
dataRequest = llGetNotecardLine("controllers",line_count);
}
}
else
{
llWhisper(0,"Server loaded succesfuly.");
llWhisper(0,(string)llGetKey());
}
}

link_message(integer num,integer channel,string message,key id)
{
if(allow)
{
// llOwnerSay(llList2CSV([channel,message,id]));
if(channel == reciver)
{
if(llGetSubString(message,0,5) == "check ")
{
string temp = llGetSubString(message,6,-1);
mode = 1;
llSetTimerEvent(2);
llMessageLinked(LINK_SET,check_account,"check",temp);
atm = id;
user = temp;
}

if(message == "title")
{
send(id,"title "+title+","+(string)title_color);
}

if(llGetSubString(message,0,6) == "create ")
{
string temp = llGetSubString(message,7,-1);
list p = llCSV2List(temp);
llMessageLinked(LINK_SET,create_account,llList2String(p,0)+","+llList2String(p,2),llList2String(p,1));
atm = id;
user = llList2String(p,1);
send(id,"vaild 0,"+title+","+(string)title_color);
}

if(llGetSubString(message,0,7) == "deposit ")
{
string temp = llGetSubString(message,8,-1);
list p = llCSV2List(temp);
paid_amount = (integer)llList2String(p,0);
paying_user = (key)llList2String(p,1);
atm = id;
mode = 3;
llSetTimerEvent(3);
llMessageLinked(LINK_SET,add_remove_money,"d "+llList2String(p,0)+","+llList2String(p,1),id);
}

if(llGetSubString(message,0,8) == "withdraw ")
{
string temp = llGetSubString(message,9,-1);
list p = llCSV2List(temp);
llMessageLinked(LINK_SET,add_remove_money,"w "+llList2String(p,0)+","+llList2String(p,1),id);
}
}

if(channel == 111)
{
if(message == "stop timer")
{
mode = -1;
llSetTimerEvent(0);
}
}

if(channel == check_account)
{
if(id == "found")
{
send(atm,"vaild "+message+","+title+","+(string)title_color);
llSetTimerEvent(0);
mode = -1;
}
//llOwnerSay((string)count2);
}

if(channel == storage)
{
if(id == "payment")
{
list p = llCSV2List(message);
if((integer)llList2String(p,1) > 0)llGiveMoney((key)llList2String(p,0),(integer)llList2String(p,1));
}

if(id == "storage")
{
if(llGetSubString(message,0,8) == "activate ")
{
storage_num = (integer)llGetSubString(message,9,-1);
llMessageLinked(LINK_SET,storage,"active",(string)storage_num);
}
}

if(llGetSubString(id,0,4) == "send ")
{
send(llGetSubString(id,5,-1),message);
}

if(id == "report")
{
list p = llCSV2List(message);
total += (integer)llList2String(p,0);
totalu += (integer)llList2String(p,1);
count++;
if(count == 10)
{
llWhisper(0,"There are L$"+(string)total+" and "+(string)totalu+" users in the bank.");
total = 0;
totalu = 0;
count = 0;
}
}
}
}
}
}

Storage of Client info
CODE

string users;
list amounts;
list names;
list accounts;

integer me;
integer in_use;
integer lisID;
integer storage = 60;
integer create_account = 61;
integer add_remove_money = 62;
integer add_remove_money_control = 63;
integer check_account = 64;
string atm;

integer c_control;

add_rate()
{
if(llGetListLength(amounts) != 0)
{
integer i;
for(i=0;i<llGetListLength(amounts)+1;i++)
{
string t = llList2String(accounts,i);
integer a = (integer)llList2String(amounts,i);

if(t == "bb") amounts = llListReplaceList(amounts, [(a + (5 * llFloor((float)a / 100)))] ,i,i);
if(t == "p" && a <! 7) amounts = llListReplaceList(amounts, [(a + (10 * llFloor((float)a / 100)))] ,i,i);
}
}
}

take_payment()
{
if(llGetListLength(amounts) != 0)
{
integer i;
for(i=0;i<llGetListLength(amounts);i++)
{
string t = llList2String(accounts,i);
integer a = (integer)llList2String(amounts,i);

if(t == "bb") amounts = llListReplaceList(amounts, [(a - 7)] ,i,i);
if(t == "p") amounts = llListReplaceList(amounts, [(a - 7)] ,i,i);
}
}
}

report()
{
integer c;

if(llGetListLength(amounts) != 0)
{
integer i;
for(i=0;i<llGetListLength(amounts)+1;i++)
{
c = c + (integer)llList2String(amounts,i);
}
llMessageLinked(LINK_SET,storage,(string)c+","+(string)llGetListLength(amounts),"report");
}
else
{
llMessageLinked(LINK_SET,storage,"0,0","report");
}
}

default
{
state_entry()
{
me = (integer)llGetSubString(llGetScriptName(),8,-1);
}

link_message(integer num,integer channel,string message,key id)
{
if(channel == storage)
{
if(message == "active" && (integer)((string)id) == me) in_use = TRUE;
}

if(channel == check_account)
{
if(message == "check")
{
integer find = llSubStringIndex(users,(string)id);

if(find != -1)
{
llMessageLinked(LINK_SET,check_account,llList2String(amounts,(find - 1) / 36),"found");
llMessageLinked(LINK_SET,111,"stop timer","");
}
}
}

if(channel == create_account && in_use)
{
list p = llCSV2List(message);
users += (string)id+",";
amounts += 0;
names += llList2String(p,1);
accounts += llList2String(p,0);


if(llGetListLength(amounts) > 25)
{
in_use = FALSE;
llMessageLinked(LINK_SET,storage,"activate "+(string)(me + 1),"storage");
}
}

if(channel == add_remove_money)
{
if(message == "add rate")
{
add_rate();
}

if(message == "take payment")
{
take_payment();
}

if(llGetSubString(message,0,1) == "d ")
{
string temp = llGetSubString(message,2,-1);
list p = llCSV2List(temp);
integer add_amount = (integer)llList2String(p,0);
integer find = llSubStringIndex(users,llList2String(p,1));
if(find != -1)
{

integer c_amount = (integer)llList2String(amounts,(find - 1) / 36);

amounts = llListReplaceList(amounts,[c_amount + add_amount],(find - 1) / 36,(find - 1) / 36);
llMessageLinked(LINK_SET,storage,"vaild "+(string)(c_amount + add_amount),"send "+(string)id);
llMessageLinked(LINK_SET,111,"stop timer","");
}
}

if(llGetSubString(message,0,1) == "w ")
{
string temp = llGetSubString(message,2,-1);
list p = llCSV2List(temp);
integer low_amount = (integer)llList2String(p,0);
integer find = llSubStringIndex(users,llList2String(p,1));
integer c_amount = (integer)llList2String(amounts,(find - 1) / 36);
if(find != -1)
{
if(low_amount > c_amount)
{
llMessageLinked(LINK_SET,storage,"too high","send "+(string)id);
}
else
{
llMessageLinked(LINK_SET,111,"stop timer","");
amounts = llListReplaceList(amounts,[c_amount - low_amount],(find - 1) / 36,(find - 1) / 36);
llMessageLinked(LINK_SET,storage,"vaild "+(string)(c_amount - low_amount),"send "+(string)id);
llMessageLinked(LINK_SET,storage,llList2CSV([llList2String(p,1),low_amount]),"payment");
}
}
}
}

if(channel == add_remove_money_control)
{
if(message == "report")
{
report();
}

if(llGetSubString(message,0,1) == "f ")
{
string temp = llGetSubString(message,2,-1);
integer find = llListFindList(names,[temp]);
if(find != -1)
{
llMessageLinked(LINK_SET,111,"stop timer","");
llDialog(id,"User information:\nName: "+temp+"\nAccount type: "+llList2String(accounts,find)+
"\nAmount: L$"+llList2String(amounts,find)+
"\nSay \"add <amount>\" or \"take <amount>\" on channel 1.\nFor exmaple: \"take 5\",\nOr, you can also delete the account by saying on channel one \"delete\". Example: \"/1 delete\".",["Close"],83214);
lisID = llListen(1,"",id,"");
c_control = find;
llSetTimerEvent(30);
}
}
}
}

timer()
{
llListenRemove(lisID);
llSetTimerEvent(0);
}

listen(integer channel,string name,key id,string message)
{
if(llGetSubString(llToLower(message),0,3) == "add ")
{
string temp = llGetSubString(message,4,-1);
string name = llList2String(names,c_control);
integer amount = (integer)llList2String(amounts,c_control);
amounts = llListReplaceList(amounts,[amount + (integer)temp],c_control,c_control);
llWhisper(0,"Added L$"+temp+" to "+name+"'s account. New balance: L$"+llList2String(amounts,c_control));
llListenRemove(lisID);
llSetTimerEvent(0);
}

if(llToLower(message) == "delete")
{
amounts = llDeleteSubList(amounts,c_control,c_control);
names = llDeleteSubList(names,c_control,c_control);
accounts = llDeleteSubList(accounts,c_control,c_control);
users = llDeleteSubString(users,c_control * 36 - 36,c_control * 36);
llWhisper(0,"Account deleted.");
}

if(llGetSubString(llToLower(message),0,4) == "take ")
{
string temp = llGetSubString(message,5,-1);
string name = llList2String(names,c_control);
integer amount = (integer)llList2String(amounts,c_control);

if((integer)temp > amount)
{
llWhisper(0,"There are not enough L$ in this account to take that amount.");
}
else
{
amounts = llListReplaceList(amounts,[amount - (integer)temp],c_control,c_control);
}
llWhisper(0,"Removed L$"+temp+" from "+name+"'s account. New balance: L$"+llList2String(amounts,c_control));
llListenRemove(lisID);
llSetTimerEvent(0);
}
}
}

Server Reciever
CODE

string users;
list amounts;
list names;
list accounts;

integer me;
integer in_use;
integer lisID;
integer storage = 60;
integer create_account = 61;
integer add_remove_money = 62;
integer add_remove_money_control = 63;
integer check_account = 64;
string atm;

integer c_control;

add_rate()
{
if(llGetListLength(amounts) != 0)
{
integer i;
for(i=0;i<llGetListLength(amounts)+1;i++)
{
string t = llList2String(accounts,i);
integer a = (integer)llList2String(amounts,i);

if(t == "bb") amounts = llListReplaceList(amounts, [(a + (5 * llFloor((float)a / 100)))] ,i,i);
if(t == "p" && a <! 7) amounts = llListReplaceList(amounts, [(a + (10 * llFloor((float)a / 100)))] ,i,i);
}
}
}

take_payment()
{
if(llGetListLength(amounts) != 0)
{
integer i;
for(i=0;i<llGetListLength(amounts);i++)
{
string t = llList2String(accounts,i);
integer a = (integer)llList2String(amounts,i);

if(t == "bb") amounts = llListReplaceList(amounts, [(a - 7)] ,i,i);
if(t == "p") amounts = llListReplaceList(amounts, [(a - 7)] ,i,i);
}
}
}

report()
{
integer c;

if(llGetListLength(amounts) != 0)
{
integer i;
for(i=0;i<llGetListLength(amounts)+1;i++)
{
c = c + (integer)llList2String(amounts,i);
}
llMessageLinked(LINK_SET,storage,(string)c+","+(string)llGetListLength(amounts),"report");
}
else
{
llMessageLinked(LINK_SET,storage,"0,0","report");
}
}

default
{
state_entry()
{
me = (integer)llGetSubString(llGetScriptName(),8,-1);
}

link_message(integer num,integer channel,string message,key id)
{
if(channel == storage)
{
if(message == "active" && (integer)((string)id) == me) in_use = TRUE;
}

if(channel == check_account)
{
if(message == "check")
{
integer find = llSubStringIndex(users,(string)id);

if(find != -1)
{
llMessageLinked(LINK_SET,check_account,llList2String(amounts,(find - 1) / 36),"found");
llMessageLinked(LINK_SET,111,"stop timer","");
}
}
}

if(channel == create_account && in_use)
{
list p = llCSV2List(message);
users += (string)id+",";
amounts += 0;
names += llList2String(p,1);
accounts += llList2String(p,0);


if(llGetListLength(amounts) > 25)
{
in_use = FALSE;
llMessageLinked(LINK_SET,storage,"activate "+(string)(me + 1),"storage");
}
}

if(channel == add_remove_money)
{
if(message == "add rate")
{
add_rate();
}

if(message == "take payment")
{
take_payment();
}

if(llGetSubString(message,0,1) == "d ")
{
string temp = llGetSubString(message,2,-1);
list p = llCSV2List(temp);
integer add_amount = (integer)llList2String(p,0);
integer find = llSubStringIndex(users,llList2String(p,1));
if(find != -1)
{

integer c_amount = (integer)llList2String(amounts,(find - 1) / 36);

amounts = llListReplaceList(amounts,[c_amount + add_amount],(find - 1) / 36,(find - 1) / 36);
llMessageLinked(LINK_SET,storage,"vaild "+(string)(c_amount + add_amount),"send "+(string)id);
llMessageLinked(LINK_SET,111,"stop timer","");
}
}

if(llGetSubString(message,0,1) == "w ")
{
string temp = llGetSubString(message,2,-1);
list p = llCSV2List(temp);
integer low_amount = (integer)llList2String(p,0);
integer find = llSubStringIndex(users,llList2String(p,1));
integer c_amount = (integer)llList2String(amounts,(find - 1) / 36);
if(find != -1)
{
if(low_amount > c_amount)
{
llMessageLinked(LINK_SET,storage,"too high","send "+(string)id);
}
else
{
llMessageLinked(LINK_SET,111,"stop timer","");
amounts = llListReplaceList(amounts,[c_amount - low_amount],(find - 1) / 36,(find - 1) / 36);
llMessageLinked(LINK_SET,storage,"vaild "+(string)(c_amount - low_amount),"send "+(string)id);
llMessageLinked(LINK_SET,storage,llList2CSV([llList2String(p,1),low_amount]),"payment");
}
}
}
}

if(channel == add_remove_money_control)
{
if(message == "report")
{
report();
}

if(llGetSubString(message,0,1) == "f ")
{
string temp = llGetSubString(message,2,-1);
integer find = llListFindList(names,[temp]);
if(find != -1)
{
llMessageLinked(LINK_SET,111,"stop timer","");
llDialog(id,"User information:\nName: "+temp+"\nAccount type: "+llList2String(accounts,find)+
"\nAmount: L$"+llList2String(amounts,find)+
"\nSay \"add <amount>\" or \"take <amount>\" on channel 1.\nFor exmaple: \"take 5\",\nOr, you can also delete the account by saying on channel one \"delete\". Example: \"/1 delete\".",["Close"],83214);
lisID = llListen(1,"",id,"");
c_control = find;
llSetTimerEvent(30);
}
}
}
}

timer()
{
llListenRemove(lisID);
llSetTimerEvent(0);
}

listen(integer channel,string name,key id,string message)
{
if(llGetSubString(llToLower(message),0,3) == "add ")
{
string temp = llGetSubString(message,4,-1);
string name = llList2String(names,c_control);
integer amount = (integer)llList2String(amounts,c_control);
amounts = llListReplaceList(amounts,[amount + (integer)temp],c_control,c_control);
llWhisper(0,"Added L$"+temp+" to "+name+"'s account. New balance: L$"+llList2String(amounts,c_control));
llListenRemove(lisID);
llSetTimerEvent(0);
}

if(llToLower(message) == "delete")
{
amounts = llDeleteSubList(amounts,c_control,c_control);
names = llDeleteSubList(names,c_control,c_control);
accounts = llDeleteSubList(accounts,c_control,c_control);
users = llDeleteSubString(users,c_control * 36 - 36,c_control * 36);
llWhisper(0,"Account deleted.");
}

if(llGetSubString(llToLower(message),0,4) == "take ")
{
string temp = llGetSubString(message,5,-1);
string name = llList2String(names,c_control);
integer amount = (integer)llList2String(amounts,c_control);

if((integer)temp > amount)
{
llWhisper(0,"There are not enough L$ in this account to take that amount.");
}
else
{
amounts = llListReplaceList(amounts,[amount - (integer)temp],c_control,c_control);
}
llWhisper(0,"Removed L$"+temp+" from "+name+"'s account. New balance: L$"+llList2String(amounts,c_control));
llListenRemove(lisID);
llSetTimerEvent(0);
}
}
}

Server send
CODE

integer Key2Channel(key given, integer num_digits)
{
string known = (string)given;
integer count = llStringLength(known) - 1;
integer i;

string channel = "";

for(i = 0; i < count; i += 2)
{
channel += (string)((integer)("0x" + llGetSubString(known,i,i + 1)));

if(llStringLength(channel) >= num_digits)
i = count;
}

return (integer)channel;
}

string encrypt(string message)
{
list date = llParseString2List(llGetDate(),["-"],[]);
string k = (string)(Key2Channel(llGetKey(),7) + llList2Integer(date,2) + 126) + llDumpList2String(date,"");
string word = k+(string)llGetKey()+k;

string e = llXorBase64StringsCorrect(llStringToBase64(message),llStringToBase64(word));
return llGetSubString(e,5,-1) + llGetSubString(e,0,4);
}

string decrypt(string message)
{
list date = llParseString2List(llGetDate(),["-"],[]);
string k = (string)(Key2Channel(llGetKey(),7) + llList2Integer(date,2) + 126) + llDumpList2String(date,"");
string word = k+(string)llGetKey()+k;

string cm = llGetSubString(message,llStringLength(message) - 5,-1) +llGetSubString(message,0,llStringLength(message) - 5);

return llBase64ToString(llXorBase64StringsCorrect(cm,llStringToBase64(word)));
}

integer me;

default
{
on_rez(integer num)
{
llResetScript();
}

state_entry()
{
me = (integer)llGetSubString(llGetScriptName(),5,-1);
}

link_message(integer nu,integer channel,string message,key id)
{
if(channel == me)
{
llEmail((string)id+"@lsl.secondlife.com",encrypt(message),"");
}
}
}


I know it is a lot, but can anyone see what is wrong? I click the atm try and check my account...to no success it says checking account, but nothing after that. Looks horrid without BBC...oh well. :(
Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-24-2007 18:37
Ok I solved one of the problems
The server is now getting the message

PROBLEM #2 :p

Upon getting the message to create an account (clients script) it doesn't react
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
05-25-2007 04:30
1. I assume you're using a round-robin process farm for sending e-mails. The problem is, the send() function keeps your eml variable looping between the values 1 to 6, but it's initialised to 0. So it's possible that the first e-mail getting sent out in any given session is being lost because the link_message int component for it will be 0.

2. Remember that object-to-object e-mails have some extra material added to them - you seem to be recieving the e-mails in a seperate script (which isn't necessary), so I presume that script is removing the extra material.

3. The only way to create an account seems to be to have the system first refuse a check or deposit because the user has no account already (which sets pmode = "create";). The problem is that the server never sends a "no account" message so this can't happen.

4. Because your encrypt() method doesn't seem to use a shared key you have unfortunately compromised your security by posting the script here :(
Noah Aero
Registered User
Join date: 15 May 2007
Posts: 11
05-25-2007 06:33
I will go check on those...and I am not creating a bank, I just like to learn about SL. I spent weeks making a sploder...i haven't done anything with it :D
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
06-02-2007 12:13
in your first post you pasted the main script twice, instead of the main script and the sender, makes it a little hard to be sure what's going on.
_____________________