Could you help me, please ?
I would like to make npc script for top-up system.
When I start server and insert 'card_id' = xxxblabla,'amount' = 50,'account_id' = 200002 and status=1 in database SQL.
Which I think acooud_id 200002 can get 50 points and status change to 2
but I login account_id 200002 I can't get cashpoints. and status = 1
Is there a way to help me fix this problem?
This is my script.
- script TMPAY -1,{
//--- Check Timer
OnPCLoginEvent:
query_sql "select SUM(amount) as sum_refill_amount from truemoney where account_id='"+getcharid(3)+"' and status='1'",.@sum_refill_amount;
if (.@sum_refill_amount>0) {
set #CASHPOINTS,(#CASHPOINTS + .@sum_refill_amount);
query_sql "update truemoney set status='2' where account_id='"+getcharid(3)+"' and status='1'";
dispbottom "you got CASH "+.@sum_refill_amount+" cash";
close;
}
end;
}
- script TMPAYMONEY 111,{
//--- Check credit card every 10 second
OnTimer10000:
debugmes "asdf"; // <-- I added this line to see your timer is running or not
query_sql "select card_id,account_id,amount from truemoney where status='1' and amount>0",.card_id,.account_id,.amount;
sleep2 500;
if (getarraysize(.card_id) > 0) {
for (set .i,0; .i < getarraysize(.card_id); set .i,.i+1) {
if(attachrid(.account_id[.i])==1) {
query_sql "select status from truemoney where card_id='"+.card_id[.i]+"'",.check_refill$;
if(.check_refill$=="1") {
dispbottom "You got cash " +.amount[.i]+" Cash";
set #CASHPOINTS,(#CASHPOINTS + .amount[.i]);
query_sql "update truemoney set status='2' where card_id='"+.card_id[.i]+"'";
}
}
detachrid;
}
}
deletearray .card_id,getarraysize(.card_id);
deletearray .account_id,getarraysize(.account_id);
deletearray .amount,getarraysize(.amount);
//--- Bonus credit
query_sql "select card_id,account_id,item_id,item_name,item_amount from cutrue_item_bonus where bonus_refill='1' and item_amount>0",.idb,.account_idb,.item_id,.item_name$,.item_amount;
sleep2 500;
if (getarraysize(.idb) > 0) {
for (set .j,0; .j < getarraysize(.idb); set .j,.j+1) {
if(attachrid(.account_idb[.j])==1) {
query_sql "select bonus_refill from cutrue_item_bonus where card_id='"+.idb[.j]+"'",.check_refill$;
if(.check_refill$=="1") {
dispbottom "You got bonus Item "+.item_name$[.j]+" "+.item_amount[.j]+" ea";
getitem .item_id[.j],.item_amount[.j];
query_sql "update cutrue_item_bonus set bonus_refill='2' where card_id='"+.idb[.j]+"'";
}
}
detachrid;
}
}
deletearray .card_id,getarraysize(.idb);
deletearray .account_id,getarraysize(.account_idb);
deletearray .item_id$,getarraysize(.item_id$);
deletearray .item_name$,getarraysize(.item_name$);
deletearray .item_amount,getarraysize(.item_amount);
initnpctimer;
end;
OnInit:
initnpctimer;
end;
}