2 sscanf in same command ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Server (
https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (
https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: 2 sscanf in same command ? (
/showthread.php?tid=608529)
2 sscanf in same command ? -
Metharon - 02.06.2016
How can i do this kind of a command .. for some reason the printf isn't called but the showsyntax is.
pawn Код:
CMD:aevent(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 3) return 1;
new option[256];
if(sscanf(params, "s[256]", option))
{
ShowSyntax(playerid, "/aevent <Option>");
SCM(playerid, COLOR_SERVER, "Options: {FFFFFF}Heal, Armour, GiveGun, Disarm, Respawn,(Un)Freeze, Repair, Nos");
return 1;
}
if(strcmp(option,"heal",true) == 0)
{
new amount;
if(sscanf(params, "i", amount)) return ShowSyntax(playerid, "/aevent heal <Value>");
printf("Chemat");
foreach(new i : Player)
{
printf("intrat");
if (FindNear(60.0, playerid, i))
{
SetPlayerHealth(i, amount);
format(strglobal, sizeof(strglobal), "(Admin Event) {FFFFFF}%s set your health to %d.0", GetName(playerid), amount);
SCM(i, COLOR_LIGHTRED, strglobal);
}
}
}
return 1;
}
Re: 2 sscanf in same command ? -
Konstantinos - 02.06.2016
You can either use:
pawn Код:
if (!sscanf(params, "'heal'f", amount)
{
// code..
}
but that will not ignore the case of the letters and neither will show the usage for heal option. Another way is this:
PHP код:
if (isnull(params))
{
ShowSyntax(playerid, "/aevent <Option>");
SCM(playerid, COLOR_SERVER, "Options: {FFFFFF}Heal, Armour, GiveGun, Disarm, Respawn,(Un)Freeze, Repair, Nos");
return 1;
}
if (!strcmp(params, "heal", true, 4))
{
new
Float: amount;
if (sscanf(params[4], "f", amount)) return print("/aevent heal <Value>");
foreach(new i : Player)
{
if (FindNear(60.0, playerid, i))
{
SetPlayerHealth(i, amount);
format(strglobal, sizeof(strglobal), "(Admin Event) {FFFFFF}%s set your health to %.1f", GetName(playerid), amount);
SCM(i, COLOR_LIGHTRED, strglobal);
}
}
}
else if (!strcmp(params, "armour", true, 6))
{
new
Float: amount;
if (sscanf(params[6], "f", amount)) return print("/aevent armour <Value>");
// code..
}
// rest of them..
else
{
ShowSyntax(playerid, "/aevent <Option>");
SCM(playerid, COLOR_SERVER, "Options: {FFFFFF}Heal, Armour, GiveGun, Disarm, Respawn,(Un)Freeze, Repair, Nos");
}