SA-MP Forums Archive
[Question] How to make an Admin 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Question] How to make an Admin command (/showthread.php?tid=135634)



[Question] How to make an Admin command - [AXS]Bryce - 21.03.2010

Hey its me again for like the 3rd time in one day.. lol
anyway i was wondering how do u make an a command that only admins can use?
for example a teleport:

Код:
if (strcmp("/ls", cmdtext, true, 10) == 0)
	{
    SetPlayerPos(playerid, 1544.4379,-1353.2231,329.4744);
    SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Los Santos!");
    new name[MAX_PLAYER_NAME], string[100];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[TELEPORT] %s has gone to Los Santos [/ls]", name );
    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
	return 1;



Re: [Question] How to make an Admin command - [LSR]State_Trooper - 21.03.2010

if (strcmp("/ls", cmdtext, true, 10) == 0)
{
IsPlayerAdmin(playerid))
{
SetPlayerPos(playerid, 1544.4379,-1353.2231,329.4744);
SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Los Santos!");
new name[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[TELEPORT] %s has gone to Los Santos [/ls]", name );
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
return 1;
}

I think If its wrong, Ill fix


Re: [Question] How to make an Admin command - aircombat - 21.03.2010

use this : (State_Trooper u forgot "if")
Код:
if(strcmp("/ls", cmdtext, true, 10) == 0)
  {
   if(IsPlayerAdmin(playerid))
   {
    SetPlayerPos(playerid, 1544.4379,-1353.2231,329.4744);
    SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Los Santos!");
    new name[MAX_PLAYER_NAME], string[100];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[TELEPORT] %s has gone to Los Santos [/ls]", name );
    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
    else { SendClientMessage(playerid,COLOR_LIGHTBLUE,"You Aren't Admin"); }
  return 1;
}



Re: [Question] How to make an Admin command - [AXS]Bryce - 21.03.2010

i did what you said and it gave me crap loads of errors so i did this but it says im not admin when i try the tele...
Код:
	if(strcmp(cmdtext, "/adminship", true) == 0)
	{
 	  if(IsPlayerAdmin(playerid))

     SetPlayerPos(playerid, 3203.9760,-1472.5383,16.6099);
     else SendClientMessage(playerid,COLOR_LIGHTBLUE,"You not admin, are you retarded?!");
    return 1;



Re: [Question] How to make an Admin command - [03]Garsino - 21.03.2010

pawn Код:
if (strcmp("/ls", cmdtext, true, 3) == 0)
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR, "Admins Only!");
        else
        SetPlayerPos(playerid, 1544.4379,-1353.2231,329.4744);
        SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Los Santos!");
        new name[MAX_PLAYER_NAME], string[100];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "[TELEPORT] %s has gone to Los Santos [/ls]", name );
        SendClientMessageToAll(COLOR_LIGHTBLUE, string);
        return 1;
    }



Re: [Question] How to make an Admin command - Joe Staff - 21.03.2010

That will work Garsino, but the 'else' is pointless. Not only will it only run the first command following it, but if the player isn't admin it will stop the command anyway.

pawn Код:
if (strcmp("/ls", cmdtext, true, 3) == 0)
{
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR, "Admins Only!");
  SetPlayerPos(playerid, 1544.4379,-1353.2231,329.4744);
  SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Los Santos!");
  new name[MAX_PLAYER_NAME], string[100];
  GetPlayerName(playerid, name, sizeof(name));
  format(string, sizeof(string), "[TELEPORT] %s has gone to Los Santos [/ls]", name );
  SendClientMessageToAll(COLOR_LIGHTBLUE, string);
  return 1;
}



Re: [Question] How to make an Admin command - [AXS]Bryce - 22.03.2010

aww man! it still says im not admin! does it only work if your logged in rcon or something?
I rly need to make this admin only because it would suck if players could just enter admin village and take all the weapons lol

Код:
if(strcmp(cmdtext, "/adminship", true, 10) == 0)
	{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_GREEN, "Your not admin!");
    SetPlayerPos(playerid, 3203.9760,-1472.5383,16.6099);
    return 1;



Re: [Question] How to make an Admin command - MyLife - 22.03.2010

If you use GF GameMode

You should use PlayerInfo[playerid][pAdmin]
pawn Код:
if (strcmp("/ls", cmdtext, true, 3) == 0)
{
   if(PlayerInfo[playerid][pAdmin] > 1)
  {  
    SetPlayerPos(playerid, 1544.4379,-1353.2231,329.4744);
    SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Los Santos!");
    new name[MAX_PLAYER_NAME], string[100];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "[TELEPORT] %s has gone to Los Santos [/ls]", name );
    SendClientMessageToAll(COLOR_LIGHTBLUE, string);
  }
  else
  {
   SendClientMessage(playerid, COLOR, "Admins Only!");
   }
  return 1;
}
Sorry for my lame English



Re: [Question] How to make an Admin command - [AXS]Bryce - 22.03.2010

yeah i dont use this 'gf' gamemode so i really dont know what to do here




Re: [Question] How to make an Admin command - iLcke - 22.03.2010

Код:
if (strcmp("/ls", cmdtext, true, 10) == 0)
{
if(IsPlayerAdmin(playerid))
{
SetPlayerPos(playerid, 1544.4379,-1353.2231,329.4744);
SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Los Santos!");
new name[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "[TELEPORT] %s has gone to Los Santos [/ls]", name );
SendClientMessageToAll(COLOR_LIGHTBLUE, string);
return 1;
}
SendClientMessage(playerid, COLOR_RED, "ERROR: You are not an admin!");
return 1;
}
There you go.

the command only works for rcon admins