Skip to content

Commit

Permalink
Updated Web Commands NPC so it doesn't only run once (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akkarinage authored Jul 9, 2023
1 parent 9a63c58 commit 99b0c43
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions data/npc/web_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,26 @@
//= commands every 2 seconds.
//===== Additional Comments: =================================
//= 1.0 First Version.
//= 1.1 Fixed code to prevent single-run senarios.
//============================================================

- script Commands -1,{
OnInit:
start:
initnpctimer;
end;
initnpctimer;
end;

OnTimer2000:
set $@nb2,query_sql("SELECT COUNT(*) FROM cp_commands WHERE done=0",$@count);
if($@count != 0) {
set $@nb,query_sql("SELECT command,id,account_id FROM cp_commands WHERE done=0",$@command$,$@id,$@account_id);
if(compare($@command$,"@")) {
attachrid($@account_id[0]);
atcommand $@command$[0];
} else charcommand $@command$[0];
query_sql("UPDATE cp_commands SET done='1' WHERE command='"+$@command$[0]+"' AND id='"+$@id[0]+"'");
} else
finish:
stopnpctimer;
goto start;
}
.@nb2 = query_sql("SELECT COUNT(*) FROM cp_commands WHERE done=0",.@count);
if(.@count != 0) {
.@nb = query_sql("SELECT command,id,account_id FROM cp_commands WHERE done=0 ORDER BY id LIMIT 1",.@command$,.@id,.@account_id);
if(compare(.@command$,"@")) {
attachrid(.@account_id[0]);
atcommand .@command$[0];
} else charcommand .@command$[0];
query_sql("UPDATE cp_commands SET done='1' WHERE command='"+.@command$[0]+"' AND id='"+.@id[0]+"'");
.@nb = 0; .@nb2 = 0; .@count = 0; .@command$ = 0; .@id = 0; .@account_id = 0;
}
stopnpctimer;
goto start;
}

0 comments on commit 99b0c43

Please sign in to comment.