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

评论 共4条
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称
    • 头像110
      • 小健的头像-一键开心网小健作者0
    • 头像dongsir0
      • 小健的头像-一键开心网小健作者0