Samp Sscanf -
new cmd[32], id, cash; if(sscanf(cmdtext, "s[32]dd", cmd, id, cash)) return SendClientMessage(playerid, -1, "Usage: /givecash [ID] [amount]"); if(strcmp(cmd, "/givecash", true) == 0) GivePlayerMoney(id, cash); GivePlayerMoney(playerid, -cash); return 1;
Alex learned: Never parse user input manually in SAMP. sscanf isn't just convenient – it's the difference between a hobby server and a reliable one. Every major RP script (like GF edit, YSI, and modern frameworks) depends on it. samp sscanf
He downloaded the plugin ( sscanf.dll on Windows, sscanf.so on Linux) and the include file. He added #include <sscanf2> to his script. He downloaded the plugin ( sscanf
new pos = strfind(cmdtext, " "); new id = strval(cmdtext[pos+1]); // ... nightmare of spaces, missing values, and crashes His first version without sscanf worked sometimes . But if a player typed /givecash 5 1000 – fine. If they typed /givecash 5 1000 – crash. If they typed /givecash 5 – crash. If they typed /givecash hello 500 – crash. nightmare of spaces, missing values, and crashes His
















- 最新
- 最热
只看作者