SA-MP Forums Archive
/makeadmin command - 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: /makeadmin command (/showthread.php?tid=278986)

Pages: 1 2


/makeadmin command - Jafet_Macario - 24.08.2011

Can someone tell me what's wrong with this command? it's freakin' me out, if I try for exemple /makeadmin 0 1338 it sends me: Invalid player id... any ideas?
pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
    if(!(PlayerInfo[playerid][pAdmin] >= 1338)) return SendClientMessage(playerid, 0xFF0000AA, " you are not authorized to use this command!");
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /makeadmin [playerid/partofname] [level 1-1338]");
    else if (value < 1 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Unknown level! Only 1 to 1338");
    else if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY,"Invalid player id");
    else
    {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "You have promoted %s to Admin level %i", tName, value);
        SCM(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "You have been promoted to Admin level %i by %s", value, pName);
        SCM(pID, COLOR_LIGHTBLUE, string);
        PlayerInfo[pID][pAdmin] = value;
    }
    return 1;
}



Respuesta: /makeadmin command - uprp - 24.08.2011

pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pName[64], file[128], string[128], level, id;
    GetPlayerName(id,(pName),sizeof(pName));
    format(file,sizeof(file), USER_FILE, pName);
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0x0,"Only admins can use this command");
    if(sscanf(params, "i", level)) return SendClientMessage(playerid,0x0,"USAGE: /makeadmin [level]");
    if(level < 0 || level > 1338) return SendClientMessage(playerid,0x0,"Max Admin Level is 1338!");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0x0,"Player not found");
    else
    {
        pInfo[id][pAdmin] = level;
        dini_IntSet(file,"pAdmin",level);
        format(string,sizeof(string),"You have just set %s Admin Level to %i", pName, level);
        SendClientMessage(playerid,0x0,string);
        }
    return true;
}
Tell me if that works, please rep if it did


Re: Respuesta: /makeadmin command - Jafet_Macario - 24.08.2011

Quote:
Originally Posted by uprp
View Post
pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pName[64], file[128], string[128], level, id;
    GetPlayerName(id,(pName),sizeof(pName));
    format(file,sizeof(file), USER_FILE, pName);
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0x0,"Only admins can use this command");
    if(sscanf(params, "i", level)) return SendClientMessage(playerid,0x0,"USAGE: /makeadmin [level]");
    if(level < 0 || level > 1338) return SendClientMessage(playerid,0x0,"Max Admin Level is 1338!");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0x0,"Player not found");
    else
    {
        pInfo[id][pAdmin] = level;
        dini_IntSet(file,"pAdmin",level);
        format(string,sizeof(string),"You have just set %s Admin Level to %i", pName, level);
        SendClientMessage(playerid,0x0,string);
        }
    return true;
}
Tell me if that works, please rep if it did
Nope, getting the same thing: Player not found


Respuesta: Re: Respuesta: /makeadmin command - uprp - 24.08.2011

Quote:
Originally Posted by Jafet_Macario
View Post
Nope, getting the same thing: Player not found
Must be your script, not the command, works fine on my test script.

Can i still get the rep? Ask a scripter to check your script.


Re: Respuesta: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by uprp
View Post
pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pName[64], file[128], string[128], level, id;
    GetPlayerName(id,(pName),sizeof(pName));
    format(file,sizeof(file), USER_FILE, pName);
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,0x0,"Only admins can use this command");
    if(sscanf(params, "i", level)) return SendClientMessage(playerid,0x0,"USAGE: /makeadmin [level]");
    if(level < 0 || level > 1338) return SendClientMessage(playerid,0x0,"Max Admin Level is 1338!");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0x0,"Player not found");
    else
    {
        pInfo[id][pAdmin] = level;
        dini_IntSet(file,"pAdmin",level);
        format(string,sizeof(string),"You have just set %s Admin Level to %i", pName, level);
        SendClientMessage(playerid,0x0,string);
        }
    return true;
}
Tell me if that works, please rep if it did
Why did you Strip it ?, Funny, People stripping codes from GF Edits, and paste it to help others.


Respuesta: Re: Respuesta: /makeadmin command - uprp - 24.08.2011

Quote:
Originally Posted by G4M3Ov3r
View Post
Why did you Strip it ?, Funny, People stripping codes from GF Edits, and paste it to help others.
strip?

I use that command for my script, which i made from scratch, and not the server in my sig.

Think before you speak.


Re: Respuesta: Re: Respuesta: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by uprp
View Post
strip?

I use that command for my script, which i made from scratch, and not the server in my sig.

Think before you speak.
Script From "Scratch", How do you know he has the same Defines ?, Example you use tName, he Uses pName.. Makes ALOT of Difference, Next time, Do it Yourself, instead of stripping it from your "scratch" script.


Re: /makeadmin command - Jafet_Macario - 24.08.2011

Any others idea? ^^


Re: /makeadmin command - PrawkC - 24.08.2011

pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
    if(PlayerInfo[playerid][pAdmin] < 1338) return SendClientMessage(playerid, 0xFF0000AA, " you are not authorized to use this command!");
    if(sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /makeadmin [playerid/partofname] [level 1-1338]");
    if(value < 1 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Unknown level! Only 1 to 1338");
    if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY,"Invalid player id");
   
    new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    GetPlayerName(pID, tName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "You have promoted %s to Admin level %i", tName, value);
    SCM(playerid, COLOR_LIGHTBLUE, string);
    format(string, sizeof(string), "You have been promoted to Admin level %i by %s", value, pName);
    SCM(pID, COLOR_LIGHTBLUE, string);
    PlayerInfo[pID][pAdmin] = value;
    return 1;
}
Try that


Re: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
    if(!(PlayerInfo[playerid][pAdmin] >= 1338)) return SendClientMessage(playerid, 0xFF0000AA, " you are not authorized to use this command!");
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /makeadmin [playerid/partofname] [level 1-1338]");
    else if (value < 1 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Unknown level! Only 1 to 1338");
    else if(IsPlayerConnected(pID)) {
    if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY,"Invalid player id");
    }
    else
    {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "You have promoted %s to Admin level %i", tName, value);
        SCM(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "You have been promoted to Admin level %i by %s", value, pName);
        SCM(pID, COLOR_LIGHTBLUE, string);
        PlayerInfo[pID][pAdmin] = value;
    }
    return 1;
}
This should work


Re: /makeadmin command - Jafet_Macario - 24.08.2011

@PrawkC - same thing

@G4M3Ov3r - When I type for exemple: /makeadmin Jafet 2, I'm getting:
Code:
You have promoted   to Admin level 2
SERVER: Unknown Command
But there is no effect... it doesn't even tell my name, You have promoted Jafet... But if I use
pawn Code:
sscanf(params,"ii", pID, value)
works but only on players ID's and I want this to work also on names... /makeadmin jafet 1338.Any ideas what can cause this?


Re: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

PHP Code:
if(sscanf(params"ui"pIDValue)) 



Re: /makeadmin command - Jafet_Macario - 24.08.2011

Ye mate, but it's not working getting Player Not Connected


Re: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

Quote:
Originally Posted by Jafet_Macario
View Post
Ye mate, but it's not working getting Player Not Connected
What do you mean by getting Player Not Connected ?


Re: /makeadmin command - PrawkC - 24.08.2011

Are you using the sscanf plugin, or the sscanf stock ?


Re: /makeadmin command - Jafet_Macario - 24.08.2011

@G4M3Ov3r - told from beggining,
pawn Code:
CMD:makeadmin(playerid, params[])
{
    new pID, value;
    if(!(PlayerInfo[playerid][pAdmin] >= 1338)) return SendClientMessage(playerid, 0xFF0000AA, " you are not authorized to use this command!");
    else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /makeadmin [playerid/partofname] [level 1-1338]");
    else if (value < 1 || value > 1338) return SendClientMessage(playerid, 0xFF0000AA, "Unknown level! Only 1 to 1338");
    else if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY,"Invalid player id");
    else
    {
        new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
        GetPlayerName(pID, tName, MAX_PLAYER_NAME);
        format(string, sizeof(string), "You have promoted %s to Admin level %i", tName, value);
        SCM(playerid, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "You have been promoted to Admin level %i by %s", value, pName);
        SCM(pID, COLOR_LIGHTBLUE, string);
        PlayerInfo[pID][pAdmin] = value;
    }
    return 1;
}
Or any another command that uses
PHP Code:
sscanf(params,"ui"example1example2
does not work, getting Invalid Player ID/ Player Not Connected

@PrawkC I'm using the plugin


Re: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

Do you have sscanf2 or sscanf ?


Re: /makeadmin command - Jafet_Macario - 24.08.2011

sscanf2


Re: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

Try this

PHP Code:
new
            
value,
            
pID;
if(
sscanf(params"ui"pIDvalue)) { 
And remove this new pID, value;


Re: /makeadmin command - =WoR=G4M3Ov3r - 24.08.2011

((Ignore the Double Post))

PHP Code:
CMD:makeadmin(playeridparams[])
{
    new
    
pID,
    
value;
    if(!(
PlayerInfo[playerid][pAdmin] >= 1338)) return SendClientMessage(playerid0xFF0000AA" you are not authorized to use this command!");
    else if (
sscanf(params"ui"pIDvalue)) return SendClientMessage(playerid0xFF0000AA"Usage: /makeadmin [playerid/partofname] [level 1-1338]");
    else if (
value || value 1338) return SendClientMessage(playerid0xFF0000AA"Unknown level! Only 1 to 1338");
    if(
IsPlayerConnected(pID)) {
    if(
pID == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_GREY,"Invalid player id");
    {
        new 
pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128];
        
GetPlayerName(playeridpNameMAX_PLAYER_NAME);
        
GetPlayerName(pIDtNameMAX_PLAYER_NAME);
        
format(stringsizeof(string), "You have promoted %s to Admin level %i"tNamevalue);
        
SCM(playeridCOLOR_LIGHTBLUEstring);
        
format(stringsizeof(string), "You have been promoted to Admin level %i by %s"valuepName);
        
SCM(pIDCOLOR_LIGHTBLUEstring);
        
PlayerInfo[pID][pAdmin] = value;
    }
    return 
1;

Try this.