SA-MP Forums Archive
CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything (/showthread.php?tid=302023)



CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - xMichaelx - 06.12.2011

Hey,

I made this command:

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new string[128],name[MAX_PLAYER_NAME],pID,Level;
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0) return 0;
    if(j_sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_GREY,"Invalid Player Specified");
    else if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] >= 1338)
    {
        PlayerInfo[pID][pAdminLevel] = Level;
        format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
        SendClientMessageToAll(COLOR_PINK,string);
        GameTextForPlayer(pID,"Promoted",3000,4);
        return 1;
    }
    return 1;
}
Unforantly it doesnt work.

Could someone please explain why this is?

Thanks

-Michael


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - jaydon - 07.12.2011

Logged into Rcon?


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - THE_KNOWN - 07.12.2011

try:
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdminLevel] <= 1337) return 0;


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - Thresholdold - 07.12.2011

Quote:
Originally Posted by THE_KNOWN
Посмотреть сообщение
try:
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdminLevel] <= 0) return 0;
PlayerInfo[playerid][pAdminLevel] == 0...


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - THE_KNOWN - 07.12.2011

Edited.


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - Scenario - 07.12.2011

pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0)
I have tried doing something quite similar to the code above, but what seems to happen is that none of the code on that line actually works at all.

I noticed you were running an admin-check twice, you only need to do it once.


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - Thresholdold - 07.12.2011

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0)
I have tried doing something quite similar to the code above, but what seems to happen is that none of the code on that line actually works at all.

I noticed you were running an admin-check twice, you only need to do it once.
That's what I was trying to tell him xD


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - Jack_Leslie - 07.12.2011

Try:
pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] <= 0) return 1;
If not, try:
pawn Код:
if(!IsPlayerAdmin(playerid) && PlayerInfo[playerid][pAdminLevel] <= 0) return 1;
Never return 0; in a command like this, always return 1.


Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - currencyinstacks - 07.12.2011

pawn Код:
if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] < 1) return SendClientMessage(playerid, -1, "Your NOT rcon admin or admin level 1+!");
pawn Код:
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] > 0) return SendClientMessage(playerid, -1, "Your RCON admin OR admin level 1+");



Re: CMD:makeadmin(playerid,params[]) returns 0 and doesnt do anything - [MG]Dimi - 07.12.2011

pawn Код:
CMD:makeadmin(playerid,params[])
{
    new string[128],name[MAX_PLAYER_NAME],pID,Level;
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    if(!IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdminLevel] < 1) return 0;
    if(sscanf(params,"ui",pID,Level)) return SendClientMessage(playerid,COLOR_GREY,"/makeadmin <player> <level>");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_GREY,"Invalid Player Specified");
    PlayerInfo[pID][pAdminLevel] = Level;
    format(string,sizeof(string),"** ADMIN PROMOTE: %s Is Now An Administrator Level %d!",name,Level);
    SendClientMessageToAll(COLOR_PINK,string);
    GameTextForPlayer(pID,"Promoted",3000,4);
    return 1;
}
This should work.

@Jack_Leslie Wrong. If he returns 0 in command it would send message "SERVER: UNKNOWN COMMAND".