SA-MP Forums Archive
People automatically becomes a admin. - 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: People automatically becomes a admin. (/showthread.php?tid=290981)



People automatically becomes a admin. - BetaLaxx - 17.10.2011

Код:
new INI:File = INI_Open(UserPath(playerid));
  INI_SetTag(File,"data");
  INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
  INI_WriteInt(File,"Score",GetPlayerScore(playerid));
  INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
  INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMuted]);
  INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  INI_WriteInt(File,"SRank",PlayerInfo[playerid][pSRank]);
  INI_WriteInt(File,"Captures",PlayerInfo[playerid][pCarsCaptured]);
  INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
  INI_Close(File);
any help? I don't want people to become admin but they randomly become owner, high admin or w/e


Re: People automatically becomes a admin. - JaTochNietDan - 17.10.2011

Are you resetting the values of the enumerated variables when the player disconnects? Otherwise if for example ID 0 joins and logs in and is a level 10 administrator, it will set the value in cell 0 of the array to 10. Then if that person leaves and you do not set the value of the cell 0 back to 0, the next person who connects with ID 0 will inherit that value.


Re: People automatically becomes a admin. - BetaLaxx - 18.10.2011

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Are you resetting the values of the enumerated variables when the player disconnects? Otherwise if for example ID 0 joins and logs in and is a level 10 administrator, it will set the value in cell 0 of the array to 10. Then if that person leaves and you do not set the value of the cell 0 back to 0, the next person who connects with ID 0 will inherit that value.
I think I'm Not Setting It To 0, Can you show me how do i set it to 0 and when someone logs in back he gets his level back, ?


Re: People automatically becomes a admin. - SmiT - 18.10.2011

https://sampforum.blast.hk/showthread.php?tid=273088


Re: People automatically becomes a admin. - BetaLaxx - 18.10.2011

My Onplayerdisconnect is the same i guess, Here you go:
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
  new INI:File = INI_Open(UserPath(playerid));
  INI_SetTag(File,"data");
  INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
  INI_WriteInt(File,"Score",GetPlayerScore(playerid));
  INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
  INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMuted]);
  INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  INI_WriteInt(File,"SRank",PlayerInfo[playerid][pSRank]);
  INI_WriteInt(File,"Captures",PlayerInfo[playerid][pCarsCaptured]);
  INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
  INI_Close(File);
  return 1;
}



Re: People automatically becomes a admin. - SmiT - 18.10.2011

How do you load the players data?


Re: People automatically becomes a admin. - BetaLaxx - 18.10.2011

Like This :
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Vip",PlayerInfo[playerid][pVip]);
    INI_Int("Score",PlayerInfo[playerid][pScore]);
    INI_Int("Skin",PlayerInfo[playerid][pSkin]);
    INI_Int("Mute",PlayerInfo[playerid][pMuted]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("SRank",PlayerInfo[playerid][pSRank]);
    INI_Int("Captures",PlayerInfo[playerid][pCarsCaptured]);
    INI_Int("Cookies",PlayerInfo[playerid][pCookies]);
    return 1;
}
And When Player Logs In:
pawn Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);



Re: People automatically becomes a admin. - Yamoo - 18.10.2011

pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
  INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
  INI_WriteInt(File,"Vip",PlayerInfo[playerid][pVip]);
  INI_WriteInt(File,"Score",GetPlayerScore(playerid));
  INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
  INI_WriteInt(File,"Mute",PlayerInfo[playerid][pMuted]);
  INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
  INI_WriteInt(File,"SRank",PlayerInfo[playerid][pSRank]);
  INI_WriteInt(File,"Captures",PlayerInfo[playerid][pCarsCaptured]);
  INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
    return 1;
}
That should load the data when wanted but, put something like this at your login.

pawn Код:
if(fexist(UserPath(playerid)))
    {
        INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
now;

pawn Код:
stock UserPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}



Re: People automatically becomes a admin. - JaTochNietDan - 18.10.2011

If you don't reset the variables, they will be inherted by the next person who joins with the same id, changing variables in any language is quite basic so I'm surprised I have to show you, but in OnPlayerDisconnect in your case you would just need to add:

pawn Код:
PlayerInfo[playerid][pAdmin] = 0;
Then it will be set to 0 in that cell which is the value of playerid for the next person who joins with same ID, which means he won't inherit the level of the person that just disconnected.


Re: People automatically becomes a admin. - BetaLaxx - 18.10.2011

Don't you guys think i should reset the values onplayerconnect?
pawn Код:
PlayerInfo[playerid][pAdmin] = 0;
    PlayerInfo[playerid][pVip] = 0;
    PlayerInfo[playerid][pCookies] = 0;
    PlayerInfo[playerid][pScore] = 0;
    PlayerInfo[playerid][pCash] = 0;
    PlayerInfo[playerid][pSkin] = 0;
    PlayerInfo[playerid][pMuted] = 0;
    PlayerInfo[playerid][pDeaths] = 0;
    PlayerInfo[playerid][pSRank] = 0;
    PlayerInfo[playerid][pCarsCaptured] = 0;