Restriction
#1

Right is there a way i can restrict a cmd to a certain player name like this if(PlayerInfo[playerid][pAdmin] but instead of admin do it for a certain name eg Craig Langdale

Any help is greatly appreciated
Reply
#2

pawn Код:
if(strcmp(PlayerInfo[playerid][pName], "Craig_Langdale")
Reply
#3

Код:
 C:\Program Files (x86)\Rockstar Games\GTA San Andreas\gamemodes\modernliferp.pwn(28075) : warning 213: tag mismatch
C:\Program Files (x86)\Rockstar Games\GTA San Andreas\gamemodes\modernliferp.pwn(28076) : error 001: expected token: ")", but found "{"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Код:
CMD:makehelper(playerid, params[])
{
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
//	if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pHelper] >= 2)
    if(strcmp(PlayerInfo[playerid][pName], "Craig_Langdale")
	{
	    new playerb, admin, string[128], string2[128];
	    if(sscanf(params, "ui", playerb, admin)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /makehelper [playerid] [level]");
		if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
		if(admin < 0 || admin > 2) return SendClientMessage(playerid, COLOR_GREY, "Helper levels are between 1 and 2.");
	    if(PlayerInfo[playerb][pHelper] != admin)
Reply
#4

Here you are:
PHP код:
if(strcmp(PlayerInfo[playerid][pName], "TheNameHere"true) == 0)
{
        
//Your code here :)

Reply
#5

Thats worked in the compiling of the script but when i go in game it says you are not authorized to use this command
Reply
#6

Can you show us the code, you created?
Reply
#7

Код:
CMD:makehelper(playerid, params[])
{
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
//	if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pHelper] >= 2)
	if(strcmp(PlayerInfo[playerid][pName], "Craig_Langdale", true) == 0)
	{
	    new playerb, admin, string[128], string2[128];
	    if(sscanf(params, "ui", playerb, admin)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /makehelper [playerid] [level]");
		if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
		if(admin < 0 || admin > 2) return SendClientMessage(playerid, COLOR_GREY, "Helper levels are between 1 and 2.");
	    if(PlayerInfo[playerb][pHelper] != admin)
	    {
	        new log[256];
		    if(PlayerInfo[playerb][pHelper] < admin)
			{
		    	format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has {33AA33}promoted {FF6347}%s to level {33AA33}%d {FF6347}helper.", NORPN(playerid), NORPN(playerb), admin);
    		    format(string2, sizeof(string2), "{FF0000}[Helper Warn]{FF6347} %s has {33AA33}promoted {FF6347}%s to level {33AA33}%d {FF6347}helper.", NORPN(playerid), NORPN(playerb), admin);
            	format(log, sizeof(log), "{FF0000}[Admin Warn]{FF6347} %s (%s) has promoted %s (%s) to level %d helper.", NORPN(playerid), RPIP(playerid), NORPN(playerb), RPIP(playerb), admin);
			}
			else if(PlayerInfo[playerb][pHelper] > admin)
			{
	  	    	format(string, sizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has {FF9900}demoted {FF6347}%s to level {FF9900}%d {FF6347}helper.", NORPN(playerid), NORPN(playerb), admin);
	  	    	format(string2, sizeof(string2), "{FF0000}[Helper Warn]{FF6347} %s has {FF9900}demoted {FF6347}%s to level {FF9900}%d {FF6347}helper.", NORPN(playerid), NORPN(playerb), admin);
	  	    	format(log, sizeof(log), "{FF0000}[Admin Warn]{FF6347} %s (%s) has demoted %s (%s) to level %d helper.", NORPN(playerid), RPIP(playerid), NORPN(playerb), RPIP(playerb), admin);
			}
			Log("logs/makehelper.log", log);
			PlayerInfo[playerb][pHelper] = admin;
			SendAdminMessage(COLOR_LIGHTRED, 1, string);
			SendHelperMessage(COLOR_LIGHTRED, 1, string2);
			if(!PlayerInfo[playerb][pHelper])
			{
			    SendClientMessage(playerb, COLOR_DARKRED, string2);
			}
		}
		else SendClientMessage(playerid, COLOR_GREY, "Player already has this helper level.");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
	}
	return 1;
}
Reply
#8

try that
PHP код:
new name[24];
GetPlayerName(playeridnamesizeof(name));
if(
strcmp(name"Craig_Langdale"true) == 0
Reply
#9

Thanks Lokii thats working now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)