Wait – that sscanf line was magic. But Alex didn't understand it. So he removed it and tried parsing manually:
// /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 samp sscanf
After fixing his commands with sscanf, Alex's server became stable. No more parsing crashes. He could do complex commands like: Wait – that sscanf line was magic
Frustrated, Alex found a forum post: "Use sscanf by ****** – it's like scanf on steroids for pawn." No more parsing crashes
public OnPlayerCommandText(playerid, cmdtext[])
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;