[HELP] /removeadmin
#1

Sup, I got a small problem with one f my commands, this command should remove a players admin rank and set it to 0.

Код:
	if(strcmp(cmd, "/removeadmin", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GREY, "	USAGE: /removeadmin [playerid]");
				return 1;
			}
			new para1;
			para1 = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(PlayerInfo[playerid][pAdminLevel] >= 10)
			{
			  if(IsPlayerConnected(para1))
			  {
			    if(para1 != INVALID_PLAYER_ID)
			    {
						GetPlayerName(para1, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						PlayerInfo[giveplayerid][pAdminLevel] = 0;
						format(string, sizeof(string), "AdmCmd: %s had his/her Admin Level removed by %s.", giveplayer, sendername);
						SendClientMessageToAll(COLOR_RED, string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_RED, "	Identification Error - You need admin level 10 to do this.");
				return 1;
			}
		}
		return 1;
	}
Well, it dosn't, the player got the same rank, what is wrong?

Thansk
Reply
#2

if you have /makeadmin command is only make /makeadmin ID 0
Reply
#3

Dont even have a minute, so gonna have to quik shot this, but look at this and check to be sure it points to the target, not the player executing the code:

PlayerInfo[giveplayerid][pAdminLevel] = 0;
Reply
#4

I prefer to use dcmd
Replace all dinis with your items
Ofcourse remove GetPlayerName.. and some unused strings..

My code:
Код:
dcmd_makeadmin(playerid,params[])
{
	new level, tmp[256], string[128],string2[128];
  level = strval(tmp);
	new pName[24], str[128];
	GetPlayerName(playerid, pName, sizeof(pName));
	format(str, sizeof(str),PlayerFile,pName);
	new player, name[24], bu[128];
	if(!(dini_Int(str, "AdminLevel") >= 1))
	{
		SendClientMessage(playerid, COLOR_RED, "Admins Only!");
		return 1;
	}
  if(sscanf(params,"ui",player,level))
	{
	  SendClientMessage(playerid, COLOR_4, "/makeadmin [PlayerID] [Level]");
		return 1;
	}
	if(!IsPlayerConnected(player))
	{
    SendClientMessage(playerid, COLOR_RED, "Invalid Player ID.");
  	return 1;
	}
	else  {
	GetPlayerName(player, name, sizeof(name));
	format(bu, sizeof(bu),PlayerFile,name);
	dini_IntSet(bu, "AdminLevel", level);
	format(string,sizeof(string),"You promited %s to level %d admin!",name,level);
	format(string2,sizeof(string2),"Admin %s has prometed you to level %d admin!",pName,level);
	SendClientMessage(playerid,COLOR_RED,string);
	SendClientMessage(player,COLOR_RED,string2);
	}
	return 1;
}
usage: /makeadmin [PlayerID] [LEVEL]
(/makeadmin 1 0)
Reply
#5

Quote:
Originally Posted by [69
StreetGT ]
if you have /makeadmin command is only make /makeadmin ID 0
I also got this cmd, this should work, I got this from another RP script:

Код:
	if(strcmp(cmd, "/makevip", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GREY, "	USAGE: /makevip [playerid]");
				return 1;
			}
			new para1;
			para1 = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(PlayerInfo[playerid][pAdminLevel] >= 10)
			{
			  if(IsPlayerConnected(para1))
			  {
			    if(para1 != INVALID_PLAYER_ID)
			    {
						GetPlayerName(para1, giveplayer, sizeof(giveplayer));
						GetPlayerName(playerid, sendername, sizeof(sendername));
						PlayerInfo[giveplayerid][pVIPMember] = 1;
						format(string, sizeof(string), "AdmCmd: %s has been made a VIP Member by %s.", giveplayer, sendername);
						SendClientMessageToAll(COLOR_RED, string);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_RED, "	Identification Error - You need admin level 10 to do this.");
				return 1;
			}
		}
		return 1;
	}
But this dosn't work to, it dont change the player's stats.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)