Commands not working as expected.
#1

Commands, lots of it, based on shit
for example, me and my friend Junior were in the server.
Quote:

[01:40:50] [ADMIN PROMOTE] Vanter(1) has been promoted to be a Server Administrator

It's supposed to be Junior(1), it posted my name, with his ID.
pawn Код:
dcmd_makeadmin(playerid,params[])
{
    new string[128];
    new ID;
    new tname[MAX_PLAYER_NAME];
    GetPlayerName(ID,tname,sizeof(tname));
    if(sscanf(params,"us[100]",ID))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /makeadmin (Player Name/ID)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(PlayerInfo[ID][pAdmin] == 10)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is already a Server Administrator.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    PlayerInfo[ID][pAdmin] =10;
    format(string,sizeof(string),"[ADMIN PROMOTE] %s(%d) has been promoted to be a Server Administrator",tname,ID);
    SendClientMessageToAll(COLOR_PINK,string);

    SendClientMessage(ID,COLOR_PINK,"[ADMIN PROMOTE] You have been promoted to be a Server Administrator");

    format(string,sizeof(string),"9[ADMIN PROMOTE] %s(%d) has been promoted to be a Server Administrator",tname,ID);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);

    format(string,sizeof(string),"[ADMIN PROMOTE] %s(%d) has been promoted to be a Server Administrator",tname,ID);
    SendAdminMessage(COLOR_PINK,string);
    IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
    return 1;
}
For example, freeze.
Quote:

[01:48:00] [ADMIN FREEZE] Administrator has frozen Vanter(1). [Reason: test]

[01:48:00] [ADMIN RADIO] Administrator Vanter(0) has frozen Vanter(1). [Reason: test]

[01:48:00] <Junior> a !!!

[01:48:06] <Junior> ok

[01:48:14] [ADMIN UNFREEZE] Administrator has unfrozen Vanter(1).

[01:48:14] [ADMIN RADIO] Administrator Vanter(0) has unfrozen Vanter(1).

pawn Код:
dcmd_freeze(playerid,params[])
{
    new string[128];
    new ID;
    new cmdreason[100];
    new pname[MAX_PLAYER_NAME];
    new tname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(ID,tname,sizeof(tname));
    if(sscanf(params,"us[100]",ID,cmdreason))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /freeze (Player Name/ID) (Reason)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(IsSpawned[ID] == 0)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is not spawned in order to freeze them.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(IsFrozen[ID] == 1)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is already frozen by a Server Administrator.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    IsFrozen[ID] =1;
    TogglePlayerControllable(ID,0);
    format(string,sizeof(string),"[ADMIN FREEZE] Administrator has frozen %s(%d). [Reason: %s]",tname,ID,cmdreason);
    SendClientMessageToAll(COLOR_PINK,string);

    format(string,sizeof(string),"9[ADMIN FREEZE] Administrator has frozen %s(%d). [Reason: %s]",tname,ID,cmdreason);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);

    format(string,sizeof(string),"[ADMIN RADIO] Administrator %s(%d) has frozen %s(%d). [Reason: %s]",pname,playerid,tname,ID,cmdreason);
    SendAdminMessage(COLOR_PINK,string);
    IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
    return 1;
}

dcmd_unfreeze(playerid,params[])
{
    new string[128];
    new ID;
    new pname[MAX_PLAYER_NAME];
    new tname[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pname,sizeof(pname));
    GetPlayerName(ID,tname,sizeof(tname));
    if(sscanf(params,"uS[100]",ID))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /unfreeze (Player Name/ID)");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    if(IsFrozen[ID] == 0)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is not frozen by a Server Administrator.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    IsFrozen[ID] =0;
    TogglePlayerControllable(ID,1);
    format(string,sizeof(string),"[ADMIN UNFREEZE] Administrator has unfrozen %s(%d).",tname,ID);
    SendClientMessageToAll(COLOR_PINK,string);

    format(string,sizeof(string),"9[ADMIN UNFREEZE] Administrator has unfrozen %s(%d).",tname,ID);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);

    format(string,sizeof(string),"[ADMIN RADIO] Administrator %s(%d) has unfrozen %s(%d).",pname,playerid,tname,ID);
    SendAdminMessage(COLOR_PINK,string);
    IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
    return 1;
}
like that, but in several other commands, help?
Reply
#2

I am not entirely sure, but usually when sscanf ID bugs occur, update your plugin and include to the latest version. It might work.
Reply
#3

They are the lastest, I jst made this server 2 days ago, they're the latest..
Reply
#4

bump. anyone?
Reply
#5

This should do the trick:

pawn Код:
dcmd_makeadmin(playerid,params[])
{
    new string[128];
    new ID;
    new tname[MAX_PLAYER_NAME];
    if(sscanf(params,"i",ID))
    {
        SendClientMessage(playerid,COLOR_ERROR,"[USAGE] /makeadmin ID");
        return 1;
    }
    if(!IsPlayerConnected(ID))
    {
        format(string,sizeof(string),"[ERROR] The player ID you entered is not connected to the server.");
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    GetPlayerName(ID,tname,sizeof(tname));
    if(PlayerInfo[ID][pAdmin] == 10)
    {
        format(string,sizeof(string),"[ERROR] %s(%d) is already a Server Administrator.",tname,ID);
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    PlayerInfo[ID][pAdmin] =10;
    format(string,sizeof(string),"[ADMIN PROMOTE] %s(%d) has been promoted to be a Server Administrator",tname,ID);
    SendClientMessageToAll(COLOR_PINK,string);
    SendClientMessage(ID,COLOR_PINK,"[ADMIN PROMOTE] You have been promoted to be a Server Administrator");
    format(string,sizeof(string),"[ADMIN PROMOTE] %s(%d) has been promoted to be a Server Administrator",tname,ID);
    IRC_GroupSay(gGroupID,IRC_CHANNEL,string);
    format(string,sizeof(string),"[ADMIN PROMOTE] %s(%d) has been promoted to be a Server Administrator",tname,ID);
    SendAdminMessage(COLOR_PINK,string);
    IRC_GroupSay(gGroupID,IRC_ADMINCHANNEL,string);
    return 1;
}
Reply
#6

You didn't do anything but move GetPlayerName down a little.
let me try it
Reply
#7

Well, that's all I did indeed, but usually I define the variables, use sscanf for checking the params, and then actually try to store some data inside the variables, now what you did might be also correct(and the same), but it was just a suggestion, since your code SEEMS to me 100% correct.

That's just the way I work, if you didn't try it, then do so, and if it's the same code as yours then you have my excuses, but, once again, that's just the way I work. Makes more sense. Trying to store the name, before actually checking if the player is conected, MAKES absolutely NO sense to me. If for you storing the player's name, before checking if the specified ID IS conected makes 100% sense, then just go ahead and script that way all of your commands that involve as params a player's ID. But for me it doesn't make sense.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)