-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcustom_donation.txt
34 lines (32 loc) · 970 Bytes
/
custom_donation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
- script DonationUpdate -1,{
OnInit:
start:
initnpctimer;
end;
OnTimer5000:
set $@nb2,query_sql("SELECT COUNT(*) FROM test_donation WHERE status=0",$@count);
if($@count != 0) {
set $@nb,query_sql("SELECT id, account_id,donate,status FROM test_donation WHERE status='0'",$@id,$@account_id,$@donate,$@status);
for (.@i = 0; .@i < $@nb; .@i++) {
if (isloggedin($@account_id[.@i])) { // check if player online
atcommand "#cash \""+rid2name($@account_id[.@i])+"\" "+$@donate[.@i];
query_sql("UPDATE test_donation SET status='1' WHERE id='"+$@id[.@i]+"' AND account_id='"+$@account_id[.@i]+"'");
}
}
} else
finish:
stopnpctimer;
goto start;
}
SQL Table:
CREATE TABLE `test_donation` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`account_id` INT(11) NOT NULL,
`donate` INT(11) NOT NULL,
`status` INT(11) NOT NULL DEFAULT '0',
`time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
)
COLLATE='cp1251_general_ci'
ENGINE=InnoDB
AUTO_INCREMENT=24;