Making a staff position help
#1

Greetings,
I have made a "Moderator" Staff position but i'm having an issue, I'm able to issue it and when you relog its still there aswell but when i restart the server it gets removed

i have done the following
Defined
Код HTML:
enum pInfo
{
	pModerator,
};
Making Moderator
Код HTML:
CMD:makemoderator(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 99999) {
	    SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command.");
	    return 1;
	}

	new string[128], giveplayerid;
	if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /makemoderator[playerid]");

	if(IsPlayerConnected(giveplayerid)) {
	    if(PlayerInfo[giveplayerid][pModerator] != 1) {
	        PlayerInfo[giveplayerid][pModerator] = 1;
	        format(string, sizeof(string), "You have made %s a Moderator.", GetPlayerNameEx(giveplayerid));
	        SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
	        format(string, sizeof(string), "You have been made a Moderator by %s.", GetPlayerNameEx(playerid));
	        SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
		} else {
		    PlayerInfo[giveplayerid][ppModerator] = 0;
	        format(string, sizeof(string), "You have revoked %s's Moderator", GetPlayerNameEx(giveplayerid));
	        SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
	        format(string, sizeof(string), "You have had your Moderator Status revoked by %s.",                                         GetPlayerNameEx(playerid));
	        SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
		}
	}
	return 1;
}
OnPlayerRegister [File]
Код HTML:
public OnPlayerRegister(playerid, password[])
{
	if(IsPlayerConnected(playerid))
	{
			new string3[32];
			new playername3[MAX_PLAYER_NAME];
			GetPlayerName(playerid, playername3, sizeof(playername3));
			format(string3, sizeof(string3), "users/%s.ini", playername3);
			new File: hFile = fopen(string3, io_write);
			if (hFile)
			{
				strmid(PlayerInfo[playerid][pKey], password, 0, strlen(password), 255);
				new var[156];
				format(var, 32, "Moderator=%d\n",PlayerInfo[playerid][pModerator]);fwrite(hFile, var);
			    format(var, 32, "Moderator=%d\n",PlayerInfo[playerid][pModerator]);fwrite(hFile, var);
				format(var, 32, "Moderator=%d\n",PlayerInfo[MAX_PLAYERS][pModerator]);fwrite(hFile, var);

What is the problem, and if there is a link for a tutorials of how to make as staff position or a group please link me
Reply
#2

at the last item of the enum,you don`t have to put " , ".

Quote:

enum pInfo
{
pInfo1,
pInfo2,
pModerator
};

Reply
#3

It is not the last item, i just quoted it from the script
Reply
#4

If you're talking about removing it when they quit, do
PHP код:
public OnPlayerConnect(playerid){
    
PlayerInfo[playerid][pModerator] = 0;
    return 
1;

Just reset the variable when the player you gave it to reconnects or if another playerid connects.
Reply
#5

Код:
public OnPlayerDisconnect(playerid, reason)
{
	if(PlayerInfo[playerid][pModerator] != 0) 
	{
	        PlayerInfo[playerid][pModerator] = 0;	
	}
	return 1;
}
Reply
#6

No, the problem is that when they relog its ok they still have the mod bu when i restart the server they lose it
Reply
#7

They are still moderators because variables are never reset (something as the above members said you should do).

Also you are supposed to save it to the file and on connect to load it for the player (even if the server restarts, it will still read it from the file and set it accordingly).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)