[Help]: makeadmin command!
#1

Hey!

I made a /makeadmin command and when I type it ingame, then it change the admin level...but if I relog and come back, then is my admin level same as it was.

Code:

pawn Код:
CMD:makeadmin(playerid, params[])
{
    new targetid;
    new level;
    new string[200];
    if(gPlayerInfo[playerid][pAdminLevel] < gCommands[MAKEADMIN])return SCM(playerid, COLOR_RED, "[ERROR]: You can't use this command!");
    if(sscanf(params, "ui", targetid, level))return SCM(playerid, COLOR_GREY, "[USAGE]: /makeadmin [playerid] [level]");
    if(!IsPlayerConnected(targetid))return SCM(playerid, COLOR_RED, "[ERROR]: This player is not connected!");
    if(level < 0 || level > 10)return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid Admin Level (0-10)!");
    gPlayerInfo[targetid][pAdminLevel] = level;
    format(string, sizeof(string), "{80FF00}[Admin]: {0000FF}%s(ID:%d) has changed %s(ID:%d)'s Admin Level to %i!", GetName(playerid), playerid, GetName(targetid), targetid, level);
    SCMToAll(COLOR_BLUE, string);
    new file[200];
    format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][pName]);
    dini_Set(file, "Name", gPlayerInfo[playerid][pName]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][pIp]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][pRegged]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][pPassword]);
    dini_IntSet(file, "Admin Level", gPlayerInfo[playerid][pAdminLevel]);
    dini_IntSet(file, "Money", GetPlayerMoney(playerid));
    dini_IntSet(file, "VIP Level", gPlayerInfo[playerid][pVipLevel]);
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    dini_Set(file, "Kills", gPlayerInfo[playerid][pKills]);
    dini_Set(file, "Deaths", gPlayerInfo[playerid][pDeaths]);
    gPlayerLogged[playerid] = 0;
    return 1;
}
Thanks
Reply
#2

Well, obviously. You are changing the person who types the command.

pawn Код:
format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][pName]);
    dini_Set(file, "Name", gPlayerInfo[playerid][pName]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][pIp]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][pRegged]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][pPassword]);
    dini_IntSet(file, "Admin Level", gPlayerInfo[playerid][pAdminLevel]);
    dini_IntSet(file, "Money", GetPlayerMoney(playerid));
    dini_IntSet(file, "VIP Level", gPlayerInfo[playerid][pVipLevel]);
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    dini_Set(file, "Kills", gPlayerInfo[playerid][pKills]);
    dini_Set(file, "Deaths", gPlayerInfo[playerid][pDeaths]);
All the playerid's should be targetid, I believe.
Reply
#3

It's still the same.
Reply
#4

Show the OnPlayerDisconnect, and the part where you load the user data.
Reply
#5

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new file[100];
    format(file, sizeof(file), PlayerFile, gPlayerInfo[playerid][pName]);
    dini_Set(file, "Name", gPlayerInfo[playerid][pName]);
    dini_Set(file, "Ip", gPlayerInfo[playerid][pIp]);
    dini_IntSet(file, "Registered", gPlayerInfo[playerid][pRegged]);
    dini_IntSet(file, "Password", gPlayerInfo[playerid][pPassword]);
    dini_IntSet(file, "Admin Level", gPlayerInfo[playerid][pAdminLevel]);
    dini_IntSet(file, "Money", GetPlayerMoney(playerid));
    dini_IntSet(file, "VIP Level", gPlayerInfo[playerid][pVipLevel]);
    dini_IntSet(file, "Score", GetPlayerScore(playerid));
    dini_Set(file, "Kills", gPlayerInfo[playerid][pKills]);
    dini_Set(file, "Deaths", gPlayerInfo[playerid][pDeaths]);
    gPlayerLogged[playerid] = 0;
    return 1;
}
Reply
#6

Anyone?
Reply
#7

Try this:
pawn Код:
//try it like this
CMD:makeadmin(playerid, params[])
{
    new targetid;
    new level;
    new string[200];
    if(gPlayerInfo[playerid][pAdminLevel] < gCommands[MAKEADMIN])return SCM(playerid, COLOR_RED, "[ERROR]: You can't use this command!");
    if(sscanf(params, "ui", targetid, level))return SCM(playerid, COLOR_GREY, "[USAGE]: /makeadmin [playerid] [level]");
    if(!IsPlayerConnected(targetid))return SCM(playerid, COLOR_RED, "[ERROR]: This player is not connected!");
    if(level < 0 || level > 10)return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid Admin Level (0-10)!");
    gPlayerInfo[targetid][pAdminLevel] = level;
    format(string, sizeof(string), "{80FF00}[FMJ NAdmin]: {0000FF}%s(ID:%d) has changed %s(ID:%d)'s Admin Level to %i!", GetName(playerid), playerid, GetName(targetid), targetid, level);
    SCMToAll(COLOR_BLUE, string);
    gPlayerLogged[playerid] = 0;
    return 1;
}
Meanwhile. Why are you writing an entire new file when you set the players admin level? i'm not too good with Dini. i've forgotten most of it. Tell me, when you use the command in game, does it actually work. Have you tried any admin commands you've made?
Reply
#8

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Try this:
pawn Код:
//try it like this
CMD:makeadmin(playerid, params[])
{
    new targetid;
    new level;
    new string[200];
    if(gPlayerInfo[playerid][pAdminLevel] < gCommands[MAKEADMIN])return SCM(playerid, COLOR_RED, "[ERROR]: You can't use this command!");
    if(sscanf(params, "ui", targetid, level))return SCM(playerid, COLOR_GREY, "[USAGE]: /makeadmin [playerid] [level]");
    if(!IsPlayerConnected(targetid))return SCM(playerid, COLOR_RED, "[ERROR]: This player is not connected!");
    if(level < 0 || level > 10)return SendClientMessage(playerid, COLOR_RED, "[ERROR]: Invalid Admin Level (0-10)!");
    gPlayerInfo[targetid][pAdminLevel] = level;
    format(string, sizeof(string), "{80FF00}[FMJ NAdmin]: {0000FF}%s(ID:%d) has changed %s(ID:%d)'s Admin Level to %i!", GetName(playerid), playerid, GetName(targetid), targetid, level);
    SCMToAll(COLOR_BLUE, string);
    gPlayerLogged[playerid] = 0;
    return 1;
}
Not working :/

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Meanwhile. Why are you writing an entire new file when you set the players admin level? i'm not too good with Dini. i've forgotten most of it. Tell me, when you use the command in game, does it actually work. Have you tried any admin commands you've made?
When I use the command ingame it's works, but when I relog, then it's still the same level as it was...Other commands are working good.
Reply
#9

Bump
Reply
#10

Try this 1

Код:
CMD:makeadmin(playerid, params[])  {
	if(IsPlayerAdmin(playerid)) { //now need to rcon login to make some 1 admin

		new
			iAdminValue,
			iTargetID;

		if(sscanf(params, "ui", iTargetID, iAdminValue)) {
			SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid] [level]");
		}
		else if(IsPlayerConnected(iTargetID)) {
			if(PlayerInfo[iTargetID][pHelper] >= 1) {
				SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot make community advisors admins!");
			}
			else {

				new
					szMessage[47 + (MAX_PLAYER_NAME * 2)];

				PlayerInfo[iTargetID][pAdmin] = iAdminValue;
				format(szMessage, sizeof(szMessage), "AdmCmd: %s has promoted %s to a level %d admin.", GetPlayerNameEx(playerid), GetPlayerNameEx(iTargetID), iAdminValue);
				ABroadCast(COLOR_LIGHTRED,szMessage, 2);
				format(szMessage, sizeof(szMessage), "You have been promoted to a level %d admin by %s.", iAdminValue, GetPlayerNameEx(playerid));
				SendClientMessageEx(iTargetID, COLOR_LIGHTBLUE, szMessage);
				format(szMessage, sizeof(szMessage), "You have promoted %s to a level %d admin.", GetPlayerNameEx(iTargetID),iAdminValue);
				SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
			}
		}
		else SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)