How to check if the player typed a param or if its empty?
#1

Hi there, how to check if a reason for this /kick is given?
I mean, how to make it so that if no reason is given it will send No Reason Given

pawn Код:
CMD:kick(playerid, params[])
{
    new id;
    new reason;
        if(PlayerInfo[playerid][AdminLevel] >= 1)
        {
            if(!sscanf(params, "uz", id, reason))
            {
                new string[256];
                new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerName(id, PlayerName, sizeof(PlayerName));
                format(string, sizeof(string), "Administrator %s has just kicked %s for reason %s", name, PlayerName, reason);
                ProxDetector(10000000000.0, playerid, string, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF);
                Kick(id);
                return 1;
            }
            else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /kick [PlayerId/PartOfName] (Reason)");
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
}
Reply
#2

"z" was removed, use S(string)[length] instead.
Reply
#3

z is removed,
So I have to use a BIG letter s?
and how to check if its empty or not?
Reply
#4

this
pawn Код:
CMD:kick(playerid, params[])
{
    new id;
    new reason[64];
        if(PlayerInfo[playerid][AdminLevel] >= 1)
        {
            if(!sscanf(params, "uS(no Reason given)[64]", id, reason))
            {
                new string[256];
                new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerName(id, PlayerName, sizeof(PlayerName));
                format(string, sizeof(string), "Administrator %s has just kicked %s for reason %s", name, PlayerName, reason);
                ProxDetector(10000000000.0, playerid, string, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF);
                Kick(id);
                return 1;
            }
            else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /kick [PlayerId/PartOfName] (Reason)");
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
}
Reply
#5

Quote:
Originally Posted by Babul
Посмотреть сообщение
this
pawn Код:
CMD:kick(playerid, params[])
{
    new id;
    new reason[64];
        if(PlayerInfo[playerid][AdminLevel] >= 1)
        {
            if(!sscanf(params, "uS(no Reason given)[64]", id, reason))
            {
                new string[256];
                new name[MAX_PLAYER_NAME], PlayerName[MAX_PLAYER_NAME];
                GetPlayerName(playerid, name, sizeof(name));
                GetPlayerName(id, PlayerName, sizeof(PlayerName));
                format(string, sizeof(string), "Administrator %s has just kicked %s for reason %s", name, PlayerName, reason);
                ProxDetector(10000000000.0, playerid, string, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF, 0xFF0000FF);
                Kick(id);
                return 1;
            }
            else return SendClientMessage(playerid, 0xD8D8D8FF, "USAGE: /kick [PlayerId/PartOfName] (Reason)");
        }
        else return SendClientMessage(playerid, 0xD8D8D8FF, "You are not allowed to use this command.");
}
thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)