Help please with /setadmin
#1

hey guyz i've been tried hardly and trying to fix but i can't
this is the code
pawn Код:
if(strcmp("/setadmin", cmdtext, true, 10) == 0)
    {
        new level,playerid2,file[256],PlayerName[MAX_PLAYER_NAME],PlayerName2[MAX_PLAYER_NAME];
        new tmp2[256], Index,str[50],str2[50];
        tmp = strtok(cmdtext,Index), tmp2 = strtok(cmdtext,Index),playerid2 = strval(tmp),level = strval(tmp2);
        GetPlayerName(playerid2,PlayerName,MAX_PLAYER_NAME);
        GetPlayerName(playerid,PlayerName2,sizeof(PlayerName2));
        format(file,sizeof(file),"NewServer/Admins/%s.txt",PlayerName);
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_YELLOW,"You need be RCON to use this command!");
        if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /setlevel id level");
        if(level > 5 ) return SendClientMessage(playerid,COLOR_YELLOW,"Incorrect Level");
        if(!IsPlayerConnected(playerid2))return SendClientMessage(playerid,COLOR_YELLOW,"Player is not connected!");
        PlayerInfo[playerid][pAdminLevel] = level;
        dini_IntSet(file,"Level",level);
        format(str,sizeof(str),"* You have set %s's level to %d",PlayerName,level);
        SendClientMessage(playerid,COLOR_BLUE,str);
        format(str2,sizeof(str2),"* Admin '%s' has made you level %d",PlayerName2,level);
        SendClientMessage(playerid2,COLOR_BLUE,str);
        GameTextForPlayer(playerid2, "~r~Promoted", 5000, 3);
        return 1;
    }
and its not working when i put
pawn Код:
/setadmin
then it must say:
Код:
Usage: /setlevel id level
but it don't ,
it says : "You have set MBX97's level to 0" , why i can't choose the level either the person id ?
please fix it guyz
and thanks alot for reading
Reply
#2

Try this.

Код:
 

if(strcmp("/setadmin", cmdtext, true, 10) == 0)
    {
        new level,playerid2,file[256],PlayerName[MAX_PLAYER_NAME],PlayerName2[MAX_PLAYER_NAME];
        new tmp2[256], Index,str[50],str2[50];
        tmp = strtok(cmdtext,Index), tmp2 = strtok(cmdtext,Index),playerid2 = strval(tmp),level = strval(tmp2);
        GetPlayerName(playerid2,PlayerName,MAX_PLAYER_NAME);
        GetPlayerName(playerid,PlayerName2,sizeof(PlayerName2));
        format(file,sizeof(file),"NewServer/Admins/%s.txt",PlayerName);
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_YELLOW,"You need be RCON to use this command!");
        {
        	if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_YELLOW,"Usage: /setlevel id level");
        	{
        		if(level > 5 ) return SendClientMessage(playerid,COLOR_YELLOW,"Incorrect Level");
        		{
        			if(!IsPlayerConnected(playerid2))return SendClientMessage(playerid,COLOR_YELLOW,"Player is not connected!");
        			{
				        PlayerInfo[playerid][pAdminLevel] = level;
				        dini_IntSet(file,"Level",level);
				        format(str,sizeof(str),"* You have set %s's level to %d",PlayerName,level);
				        SendClientMessage(playerid,COLOR_BLUE,str);
				        format(str2,sizeof(str2),"* Admin '%s' has made you level %d",PlayerName2,level);
				        SendClientMessage(playerid2,COLOR_BLUE,str);
				        GameTextForPlayer(playerid2, "~r~Promoted", 5000, 3);

					}
				}
			}
		}
    }
Reply
#3

thanks but what did you change in it ??
Reply
#4

Not Working , Need help ??
Reply
#5

I suggest you to use Sscanf2 and Zcmd.
Reply
#6

pawn Код:
if( !cmdtext[ 10 ] ) return SendClientMessage( playerid, -1, "USAGE: /setlevel [ID] [Level]" );
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)