help in sscanf
#1

Hello!

If I want to make this command:

pawn Код:
CMD:kick(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 1;
    new ID,Reason[128], string[128];
    if(sscanf(params, "us[128]", ID, Reason)) return SendClientMessage(playerid,WHITE,"USAGE: /Kick [ID] [Reason]");
    if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid,RED,"Player not found.");  
    format(string, sizeof(string),"*** %s Has been kicked by: %s. (%s)",GetName(ID),GetName(playerid),Reason);
    SendClientMessageToAll(RED,string);
    TogglePlayerControllable(ID,false);
    Kick(ID);
    return 1;
}
Integration of strcmp and sscanf, how I do it?
Thanks in advance helpers
Reply
#2

It does use sscanf...
Reply
#3

I want to combine orders with strcmp and sscanf, how I do it?
That's my question (:
Reply
#4

You cannot combine them im pretty sure of that.
Reply
#5

if you're talking about using strcmp for deciding which command was triggered then I suggest using ZCMD instead
Reply
#6

pawn Код:
if(strcmp(cmd, "/kick", true) == 0)
{
    if(!IsPlayerAdmin(playerid)) return 1;
    new ID,Reason[128], string[128];
    if(sscanf(params, "us[128]", ID, Reason)) return SendClientMessage(playerid,WHITE,"USAGE: /Kick [ID] [Reason]");
    if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid,RED,"Player not found.");  
    format(string, sizeof(string),"*** %s Has been kicked by: %s. (%s)",GetName(ID),GetName(playerid),Reason);
    SendClientMessageToAll(RED,string);
    TogglePlayerControllable(ID,false);
    Kick(ID);
    return 1;
}
But i suggest to use ZCMD or DCMD.
Reply
#7

Quote:
Originally Posted by Gazmull
Посмотреть сообщение
pawn Код:
if(strcmp(cmd, "/kick", true) == 0)
{
    if(!IsPlayerAdmin(playerid)) return 1;
    new ID,Reason[128], string[128];
    if(sscanf(params, "us[128]", ID, Reason)) return SendClientMessage(playerid,WHITE,"USAGE: /Kick [ID] [Reason]");
    if(ID == INVALID_PLAYER_ID) return SendClientMessage(playerid,RED,"Player not found.");  
    format(string, sizeof(string),"*** %s Has been kicked by: %s. (%s)",GetName(ID),GetName(playerid),Reason);
    SendClientMessageToAll(RED,string);
    TogglePlayerControllable(ID,false);
    Kick(ID);
    return 1;
}
But i suggest to use ZCMD or DCMD.
Considering that code wouldn't work at all, it would be a good idea. Normal commands in OnPlayerCommandText do not have the 'params' variable.
Reply
#8

No matter, I could finally do it (:
Thanks to everyone who tried to help (:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)