sscanf + PlayerInfo (pEnum) + text + zcmd = impossible?
#1

Hello..
I'm trying to make /ban command, but now i'm thinking that it's impossible with sscanf.
Here how command looks now;

pawn Код:
CMD:ban(playerid, params[])
{
    new
        i,
        reason2[64],
        name2[MAX_PLAYER_NAME],
        string[64];
    GetPlayerName(playerid, name2, sizeof(name2));
    if(PlayerInfo[playerid][admin] == 0)
        return SendClientMessage( playerid, 0xFF0000FF, "Jūs neesat admins!" );
    if( sscanf( params, "uz", i, reason2 ))
        return SendClientMessage( playerid, 0xFFFF00FF, "/ban [id] [iemesls]" );
    if( INVALID_PLAYER_ID == i)
        return SendClientMessage( playerid, 0xFF0000FF, "Nepareizs ID!" );
    SendClientMessage(i, COLOR_RED, "********************************************" );
    SendClientMessage(i, COLOR_RED, "Tu tiki nobanots no servera!" );
    format(string, sizeof(string), "Iemesls: %s, Admins: %s", reason2,name2);
    SendClientMessage(i, COLOR_RED, string );
    SendClientMessage(i, COLOR_RED, "Ja bana iemesls ir nepamatots, lūdzu dodies uz http://dd.fate.lv/" );
    SendClientMessage(i, COLOR_RED, "********************************************" );
    PlayerInfo[i][ban] = 1;
    strcat(PlayerInfo[i][banreason],reason2);
    Kick(i);
    for (new slots = GetMaxPlayers(), i2; i2 < slots; i2++)
    {
        if(!IsPlayerConnected(i2)) continue;
        SendClientMessage(i2, COLOR_RED, "********************************************" );
        format(string, sizeof(string), "%s tika izbanots no servera!", PlayerInfo[i][Name]);
        SendClientMessage(i2, COLOR_RED, string );
        format(string, sizeof(string), "Iemesls: %s, Admins: %s", reason2,name2);
        SendClientMessage(i2, COLOR_RED, string );
        SendClientMessage(i2, COLOR_RED, "********************************************" );
    }
    return true;
}
When i'm typing /ban 1 reason, nothing happens. It just prints out /ban [id] [iemesls].
So i tried an example from wiki;

pawn Код:
CMD:ban(playerid, params[])
{
    new
        id,
        reason[64];
    if (sscanf(params, "uz", id, reason)) SendClientMessage(playerid, COLOR_RED, "/ban [id] [iemesls]");
    else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Spēlētājs netika atrasts");
    else
    {
//      BanEx(id, reason);
        PlayerInfo[playerid][ban] = 1;
        SendClientMessage(playerid, COLOR_RED, reason );
        strcat(PlayerInfo[id][banreason],reason);
        format(reason, sizeof (reason), "You have been banned%s%s.", reason[0] ? (" for: ") : (""), reason);
        SendClientMessage(id, 0xFF0000AA, reason);
        SendClientMessage(playerid, 0x00FF00AA, "Player banned");
        format(reason, sizeof(reason), "Banots! Iemesls: %s", PlayerInfo[playerid][banreason]);
        SendClientMessage(playerid, COLOR_RED, reason );
    }
    return 1;
}
result:

Is it possible to put ban reason in PlayerInfo somehow?
Reply


Messages In This Thread
sscanf + PlayerInfo (pEnum) + text + zcmd = impossible? - by SaW_[VrTx] - 01.05.2011, 18:09
Re: sscanf + PlayerInfo (pEnum) + text + zcmd = impossible? - by Zh3r0 - 01.05.2011, 18:11
Re: sscanf + PlayerInfo (pEnum) + text + zcmd = impossible? - by SaW_[VrTx] - 01.05.2011, 18:25

Forum Jump:


Users browsing this thread: 2 Guest(s)