sscanf optional param. ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf optional param. ? (
/showthread.php?tid=483011)
sscanf optional param. ? -
erminpr0 - 23.12.2013
Well I have made /unmute command, syntax is:
/unmute [playerid] [reason]
But how to make
reason' param
optional, so if player type
/unmute 7
It will send message to playerid 7
'Admin xx have unmuted you !'
And if player type
/unmute 7 do not repeat it.
Gonna send message
'Admin xx have unmuted you, reason: do not repait it.'
My unmute command:
pawn Код:
YCMD:unmute(playerid, params[], help)
{
#pragma unused help
if(PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1)
return SCM(playerid,-1,"Admins and Helpers only!");
new player, reason[128];
if(sscanf(params, "us[128]", player, reason))
return SCM(playerid, -1, "Syntax: /unmute [playerid/PartOfName] [reason]");
else if(player== INVALID_PLAYER_ID)
return SCM(playerid, -1, "* Wrong ID!");
else if(!Logged[player])
return SCM(playerid, -1, " Player not logged in yet !");
else if(!PlayerInfo[player][pMuted])
return SCM(playerid, -1, " *Player not muted !");
PlayerInfo[player][pMuted] = 0;
new string[128];
format(string, sizeof(string), " Admin %s have unmuted you. Reason: %s", RPname(playerid), reason);
SCM(player, DARKGREEN, string);
format(string, sizeof(string), " *Player %s is not muted anymore ! ", RPname(player));
SCM(playerid, YELLOW, string);
return 1;
}
Re: sscanf optional param. ? - Patrick - 23.12.2013
Just change 1 line, this code should work
pawn Код:
if(sscanf(params, "uS(No Reason)[128]", player, reason))
Re: sscanf optional param. ? -
erminpr0 - 23.12.2013
Gonna try, thanks !