SA-MP Forums Archive
[Help]: makeadmin command! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [Help]: makeadmin command! (/showthread.php?tid=439489)



[Help]: makeadmin command! - Areax - 25.05.2013

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


Re: [Help]: makeadmin command! - Kindred - 25.05.2013

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.


Re: [Help]: makeadmin command! - Areax - 25.05.2013

It's still the same.


Re: [Help]: makeadmin command! - DobbysGamertag - 25.05.2013

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


Re: [Help]: makeadmin command! - Areax - 25.05.2013

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;
}



Re: [Help]: makeadmin command! - Areax - 25.05.2013

Anyone?


Re: [Help]: makeadmin command! - DobbysGamertag - 25.05.2013

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?


Re: [Help]: makeadmin command! - Areax - 25.05.2013

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.


Re: [Help]: makeadmin command! - Areax - 25.05.2013

Bump


Re: [Help]: makeadmin command! - kosa451 - 25.05.2013

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;
}