SA-MP Forums Archive
Making a staff position help - 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: Making a staff position help (/showthread.php?tid=577318)



Making a staff position help - Oldyman - 10.06.2015

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


Re: Making a staff position help - PepsiCola23 - 10.06.2015

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

Quote:

enum pInfo
{
pInfo1,
pInfo2,
pModerator
};




Re: Making a staff position help - Oldyman - 10.06.2015

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


Re: Making a staff position help - Banana_Ghost - 11.06.2015

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.


Re: Making a staff position help - Huba - 11.06.2015

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



Re: Making a staff position help - Oldyman - 11.06.2015

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


Re: Making a staff position help - Konstantinos - 11.06.2015

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).