Samp Sscanf _top_ Here
public OnPlayerCommandText(playerid, cmdtext[])
Alex was 16 and proud. He had just set up his first SAMP roleplay server. Players could type /givecash [ID] [amount] to share money. His code looked simple: 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. His code looked simple: 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
// /giveitem [player] [item] [amount] if(sscanf(params, "us[24]d", target, item, amount)) return UsageMsg(); // /setweather [hour] [minute] (optional weather ID) new hour, minute, weather = -1; if(sscanf(params, "ddD(0)", hour, minute, weather)) // D(0) = optional integer, default 0
After fixing his commands with sscanf, Alex's server became stable. No more parsing crashes. He could do complex commands like: