Again problem with sscanf + zcmd
#1

pawn Код:
command(cuff, playerid, params[])
{
    new id, x_nr, string[128], giveplayerid;
    if(sscanf(params,"s",x_nr))
        return SendClientMessage(playerid, baltakrasa, "Sintakse: /cuff <on/off> <spēlētāja id/vārds>.");

    if(strcmp(params,"on",true) == 0){
    if(sscanf(params,"ru",id))
        return SendClientMessage(playerid, baltakrasa, "Sintakse: /cuff on <spēlētāja id/vārds>.");

    TogglePlayerControllable(id, 0);
    format(string, sizeof(string), "Informācija: %s tevi saslēdza rokudzelћos.", GetName(id));
    SendClientMessage(id, baltakrasa, string);
    format(string, sizeof(string), "Informācija: Tu saslēdzi %s rokudzelћos.", GetName(playerid));
    SendClientMessage(playerid, baltakrasa, string);}

    else if(strcmp(params,"off",true) == 0){
    if(sscanf(params,"ru",id))
        return SendClientMessage(playerid, baltakrasa, "Sintakse: /cuff off <spēlētāja id/vārds>.");

    TogglePlayerControllable(id, 1);
    format(string, sizeof(string), "Informācija: %s tevi atbrīvoja no rokudzelћiem.", GetName(id));
    SendClientMessage(id, baltakrasa, string);
    format(string, sizeof(string), "Informācija: Tu atbrīvoji %s no rokudzelћiem.", GetName(playerid));
    SendClientMessage(playerid, baltakrasa, string);}
    return 1;
}
When I type /cuff <on or off> <playerid> nothing happens but when I type /cuff <on or off> it freezes/unfreeze me. I need to get work /cuff <on or off> <playerid>. I want you to fix this script. It should work with /cuff <on or off> <playerid> and it needs to freeze/unfreeze typed playerid.
Reply
#2

ahhh wth is going on here?

Код:
if(strcmp(params,"on",true) == 0){
    if(sscanf(params,"ru",id))
        return SendClientMessage(playerid, baltakrasa, "Sintakse: /cuff on <spēlētāja id/vārds>.");
..
Reply
#3

It needs to appear when you type only /cuff on or /cuff of.
Reply
#4

Untested, but it should work:
pawn Код:
command(cuff, playerid, params[])
{
    new x_nr[4], string[128], giveplayerid;
    if(sscanf(params,"su",x_nr,giveplayerid)) return SendClientMessage(playerid, baltakrasa, "Sintakse: /cuff <on/off> <speletaja id/vards>.");
    if(giveplayerid != INVALID_PLAYER_ID)
    {
        if(strcmp(x_nr,"on",true) == 0)
        {
            TogglePlayerControllable(giveplayerid, 0);
            format(string, sizeof(string), "Informacija: %s tevi sasledza rokudzelћos.", GetName(id));
            SendClientMessage(giveplayerid, baltakrasa, string);
            format(string, sizeof(string), "Informacija: Tu sasledzi %s rokudzelћos.", GetName(playerid));
            SendClientMessage(playerid, baltakrasa, string);
        }
        else if(strcmp(x_nr,"off",true) == 0)
        {
            TogglePlayerControllable(giveplayerid, 1);
            format(string, sizeof(string), "Informacija: %s tevi atbrivoja no rokudzelћiem.", GetName(id));
            SendClientMessage(giveplayerid, baltakrasa, string);
            format(string, sizeof(string), "Informacija: Tu atbrivoji %s no rokudzelћiem.", GetName(playerid));
            SendClientMessage(playerid, baltakrasa, string);
        }
    } else SendClientMessage(playerid, baltakrasa, "Invalid player");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)