SA-MP Forums Archive
How to check if player didnt enter a reason? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to check if player didnt enter a reason? (/showthread.php?tid=140290)



How to check if player didnt enter a reason? - Torran - 08.04.2010

How would i check if a player didnt enter a reason?

pawn Код:
CMD:kick(playerid, params[])
{
    new id, reason;
    new string[128];
    if(!(BaseInfo[playerid][AdminLevel] > 1)) return SendClientMessage(playerid, COLOR_RED, "You are not an administrator with the required level");
    if(sscanf(params, "uz", id, reason)) return SendClientMessage(playerid, COLOR_RED, "Usage: /kick [PlayerID/PartOfName] [Reason]");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player not Found");
    if(BaseInfo[id][AdminLevel] > 4) return SendClientMessage(playerid, COLOR_RED, "Cannot kick the Highest Level Admin");
    if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "Cannot kick Yourself");
   
    if(WHATEVERHERE(reason)) {
        format(string, sizeof string, "Administrator %s has kicked %s with reason: no reason given", GetPlayersName(playerid), GetPlayersName(id));
        SendClientMessageToAll(COLOR_BLUE, string);
   
        Kick(id);
    } else {
        format(string, sizeof string, "Administrator %s has kicked %s with reason: %s", GetPlayersName(playerid), GetPlayersName(id), reason);
        SendClientMessageToAll(COLOR_BLUE, string);

        Kick(id);
    }
    return 1;
}
Does anyone know how i check if they didnt enter one?


Re: How to check if player didnt enter a reason? - M4S7ERMIND - 08.04.2010

z is an optional string in sscanf. You need to replace it with s.
Код:
if(sscanf(params, "us", id, reason))



Re: How to check if player didnt enter a reason? - Dreftas - 08.04.2010

Maybe

pawn Код:
if(!reason[0]) { // reason not entered
?


Re: How to check if player didnt enter a reason? - Torran - 08.04.2010

Quote:
Originally Posted by Mастерминд
z is an optional string in sscanf. You need to replace it with s.
Код:
if(sscanf(params, "us", id, reason))
Dude that wasnt my question!
I want a optional string
Quote:
Originally Posted by Dreft
Maybe

pawn Код:
if(!reason[0]) { // reason not entered
?
Maybe, Not sure, Will try ina bit



Re: How to check if player didnt enter a reason? - Hiddos - 08.04.2010

I always use if(!strlen(reason) return Blablabla)