Player not connected
#1

Found that i still have problem with that Havent tested it with other ppls but i think that it wount eaven get other ppls ID. Anyways here is the code:

pawn Код:
CMD:makeadmin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 1337)
    {
        if(IsPlayerConnected(playerid))
        {
            new playername, value;
            if (sscanf(params, "ii", playername, value)) return SendClientMessage(playerid, -1, "USAGE: /makeadmin [Player-ID] [Faction-ID]");
            {
                if (playername != INVALID_PLAYER_ID)
                {
                    new string[128];
                    PlayerInfo[playerid][pAdminLevel] = value;
                    format(string, sizeof(string), "Your admin level have been set to: %f", value);
                    SendClientMessage(playername, 0x00FF00FF, string);
                }
            }
        }
        else return SendClientMessage(playerid, -1, "This player is not connected!");
    }
    else return SendClientMessage(playerid, -1, "You are not authorized to use that command!");
    return 1;
}
I wount get this message if il type ex: "/makeadmin 2 1" and value looks like 0.00000, but i typed "1" for value
Reply
#2

You never returned a value after this bit of code:
pawn Код:
if(IsPlayerAdmin(playerid))
{
    new id, factionid;
    if(sscanf(params, "ui", id, factionid)) return SendClientMessage(playerid, -1, "USAGE: /makeleader [playerid] [faction-id]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player is not connected!");

    PlayerInfo[playerid][pLeader] = factionid;

    new string[128];
    format(string, sizeof(string), "You have been promoted to Leader of %d.", PlayerInfo[playerid][pFaction]);
    SendClientMessage(id, -1, string);
   
}
So just add a return after the code
pawn Код:
if(IsPlayerAdmin(playerid))
{
    new id, factionid;
    if(sscanf(params, "ui", id, factionid)) return SendClientMessage(playerid, -1, "USAGE: /makeleader [playerid] [faction-id]");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Player is not connected!");

    PlayerInfo[playerid][pLeader] = factionid;

    new string[128];
    format(string, sizeof(string), "You have been promoted to Leader of %d.", PlayerInfo[playerid][pFaction]);
    SendClientMessage(id, -1, string);
    return 1;
}
EDIT: You got it working
Reply
#3

Bump back up, found that there still is a problem.
Reply
#4

Bump
Reply
#5

pawn Код:
CMD:makeadmin(playerid, params[])
{
    if(PlayerInfo[playerid][pAdminLevel] >= 1337)
    {
 
            new playername, value;
            if (sscanf(params, "ui", playername, value)) return SendClientMessage(playerid, -1, "USAGE: /makeadmin [Player-ID] [Faction-ID]");
            {
                if(IsPlayerConnected(playername))
                    return SendClientMessage(playerid, -1, "This player is not connected!"), false;
                   
                if (playername != INVALID_PLAYER_ID)
                {
                    new string[128];
                    PlayerInfo[playerid][pAdminLevel] = value;
                    format(string, sizeof(string), "Your admin level have been set to: %f", value);
                    SendClientMessage(playername, 0x00FF00FF, string);
                }
            }
        }
       
    }
    else
    {
        SendClientMessage(playerid, -1, "You are not authorized to use that command!");
    }
    return 1;
}
Reply
#6

pawn Код:
CMD:makeadmin( playerid, params[ ] )
{
    new playername, value;
    if( PlayerInfo[ playerid ][ pAdminLevel ] < 1337 ) return SendClientMessage( playerid, -1, "You are not authorized to use that command!" );
    if( sscanf( params, "ri", playername, value ) ) return SendClientMessage( playerid, -1, "USAGE: /makeadmin [Player-ID] [Faction-ID]" );
    if( !IsPlayerConnected( playername ) && playername == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "This player is not connected!" );
    new string[ 128 ];
    PlayerInfo[ playerid ][ pAdminLevel ] = value;
    format( string, sizeof( string ), "Your admin level have been set to: %f", value );
    SendClientMessage( playername, 0x00FF00FF, string );
    return 1;
}
Reply
#7

pawn Код:
format( string, sizeof( string ), "Your admin level have been set to: %f", value );
%f is for a float, not an integer. You you %d instead.
Reply
#8

Quote:
Originally Posted by Walsh
Посмотреть сообщение
pawn Код:
format( string, sizeof( string ), "Your admin level have been set to: %f", value );
%f is for a float, not an integer. You you %d instead.
Tnx, thats good information Didnt knew before tought u can pick one urself
Reply
#9

Quote:
Originally Posted by Dwane
Посмотреть сообщение
pawn Код:
CMD:makeadmin( playerid, params[ ] )
{
    new playername, value;
    if( PlayerInfo[ playerid ][ pAdminLevel ] < 1337 ) return SendClientMessage( playerid, -1, "You are not authorized to use that command!" );
    if( sscanf( params, "ri", playername, value ) ) return SendClientMessage( playerid, -1, "USAGE: /makeadmin [Player-ID] [Faction-ID]" );
    if( !IsPlayerConnected( playername ) && playername == INVALID_PLAYER_ID ) return SendClientMessage(playerid, -1, "This player is not connected!" );
    new string[ 128 ];
    PlayerInfo[ playerid ][ pAdminLevel ] = value;
    format( string, sizeof( string ), "Your admin level have been set to: %d", value );
    SendClientMessage( playername, 0x00FF00FF, string );
    return 1;
}
Thats quite good, but it wount define ID's or names. If il type "/makeadmin 0 1" it says "Player is not connected"
But actualy this is my ID and im currently online.
Reply
#10

bump need fast help, giving rep for solution!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)