How do i put a command for admin only? -
dahley5 - 31.08.2011
Hello all, i was just wondering how to make a command for admins only,
i have this command for example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
SetPlayerHealth(playerid,100);// heal the player
SendClientMessage(playerid, COLOR_YELLOW, "FT Bot: "#COL_GREEN"You have been healed!");
return 1;
}
return 0;
}
Now, i would like /heal to be for admins only. I appreciate your help!
Re: How do i put a command for admin only? -
Jack_Leslie - 31.08.2011
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/heal", cmdtext, true, 10) == 0)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You are not an Admin!");
SetPlayerHealth(playerid,100);// heal the player
SendClientMessage(playerid, COLOR_YELLOW, "FT Bot: "#COL_GREEN"You have been healed!");
return 1;
}
return 0;
}
Re: How do i put a command for admin only? -
IceCube! - 31.08.2011
If your using RCON admin us
pawn Код:
if(IsPlayerAdmin(playerid));
If your using your own system use your arraay
Example
pawn Код:
if(PlayerInfo[playerid][pAdmin]);
or dont try to learn and use your Premade code above ^ with no explanation
Re: How do i put a command for admin only? -
JaTochNietDan - 31.08.2011
First of all, why do you specify a length in strcmp? It seems a little odd considering it doesn't do anything in this circumstance.
Secondly, how do you want to check for administrator? Do you want to use the standard RCON administrator stuff? If so, then use IsPlayerAdmin, for example:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/heal", cmdtext, true) == 0)
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You need to be RCON admin!"); // Check if the player is not an RCON admin and stop execution with a client message
SetPlayerHealth(playerid,100);// heal the player
SendClientMessage(playerid, COLOR_YELLOW, "FT Bot: "#COL_GREEN"You have been healed!");
return 1;
}
return 0;
}
You can read more about IsPlayerAdmin on the SA-MP Wiki:
https://sampwiki.blast.hk/wiki/IsPlayerAdmin
Edit: grr, stop posting so fast!
Re: How do i put a command for admin only? -
dahley5 - 31.08.2011
Haha yeah, it's going fast indeed.
i wanted to make it available for Admins, not for rcon.
Thanks guys for your help
Re: How do i put a command for admin only? -
Kingunit - 31.08.2011
You need to create a login + register system wich is saving the Adminlevel, so you can call that at some commands.
Re: How do i put a command for admin only? -
IceCube! - 31.08.2011
https://sampforum.blast.hk/showthread.php?tid=273088
Follow this tutorial and you should learn how to create a save system
Once that is done to check for a admin do
pawn Код:
if(PlayerInfo[playerid][pAdmin]);
Instead of using if(IsPlayerAdmin(playerid));
EDIT Expanding on what he said above ^
Re: How do i put a command for admin only? -
dahley5 - 31.08.2011
Thanks!
Re: How do i put a command for admin only? -
dahley5 - 31.08.2011
*bump* sorry for double post but, i still didn't manage to figure out how i put he admin command, because i use a GM called PPC_Trucking by powerpc603. I dont know what system he uses, i asked him but i still have no answer. so i was wondering does anyone know how i put a command as admin only for THAT GM,
thanks!
link to his thread:
https://sampforum.blast.hk/showthread.php?tid=196493
Re: How do i put a command for admin only? -
Wesley221 - 31.08.2011
If im right, the GM is using "APlayerData[playerid][PlayerLevel]".