19.11.2016, 08:40
Hey guys, I am having a little issue with sscanf, I am making an event admin CMD to set the event info (position, weapons, health etc) and only the position parameter works, all the rest simply do nothing and print a string buffer overflow warning to the console
anyone ?
All those parameters shows nothing IG and warning on the console
anyone ?
PHP код:
if(!strcmp(option, "health", true))
{
new Float:hp;
if(sscanf(params, "s[10]f", option, hp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo health [amount]");
EventHealth = hp;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the new event health amount.");
return 1;
}
if(!strcmp(option, "armour", true))
{
new Float:ap;
if(sscanf(params[6], "s[10]f", option, ap)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo armour [amount]");
EventArmour = ap;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the new event armour amount.");
return 1;
}
if(!strcmp(option, "weapon", true))
{
new slot, weaponid, ammo;
if(sscanf(params, "s[10]iii", option, slot, weaponid, ammo)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo weapon [slot] [weapon] [ammo]");
if(slot < 1 || slot > 3) return SendClientMessage(playerid, COLOR_GREY, "Slots are between 1 to 3.");
if(GetWeaponSlot(weaponid) == -1) return SendClientMessage(playerid, COLOR_WHITE, "Invalid weapon ID.");
if(ammo < 1) return SendClientMessage(playerid, COLOR_GREY, "Ammo must be 1 or higher.");
new string[128], weaponname[32];
EventWeapon[slot--] = weaponid;
EventAmmo[slot--] = ammo;
GetWeaponName(weaponid, weaponname, sizeof(weaponname));
format(string, sizeof(string), "You have set the %d event weapon slot to %s with %d bullets.", slot, weaponname, ammo);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
return 1;
}
if(!strcmp(option, "text", true))
{
new text[80];
if(sscanf(params, "s[10]s[80]", option, text)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /seteventinfo text [text]");
format(EventText, sizeof(EventText), "~r~%s", text);
SendClientMessage(playerid, COLOR_LIGHTBLUE, "You have set the joining event game text.");
return 1;
}