Loading problem (+rep)
#1

Again, I need some help from the community.
I'm going to give an example for my bug :
When an admin connects, he logs fine but when players connects after him, they get the same stats for the admin (job, level, admin level) and all this things, the bug is coming from INI_ParseFile, I'm sure.

Here's the code
pawn Код:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], string[268];
    TogglePlayerSpectating(playerid, true);
    GetPlayerName(playerid, name, sizeof(name));
    SetSpawnInfo(playerid, pInfo[playerid][SkinID], 299, 1740.6188, -1949.9669, 14.1172, 176.0951, 0, 0, 0, 0, 0, 0);
    SetPlayerSkillLevel(playerid, 0, 5);
    INI_ParseFile(Path(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
    if(!IsRPName(name, 1))
    {
        SendClientMessage(playerid, 0xDE5454FF, "Ce nom n'est pas RP. Veuillez vous reconnecter en utilisant un nom RP.");
        SendClientMessage(playerid, 0xDE5454FF, "Essayez de choisir un nom rйaliste et utilisable dans la vie rйel. Ex: Will Smith");
        SetTimerEx("DelayedKick", 450, false, "i", playerid);

        return false;
    }
    if(pInfo[playerid][Banned] == 1)
    {
       format(string, sizeof(string), "Vous кtes banni dйfinitivement du serveur par l'administrateur %s", pInfo[playerid][AdminBan]);
       SendClientMessage(playerid, -1, string);
       format(string, sizeof(string), "La raison de votre bannisement est: %s", pInfo[playerid][BanRaison]);
       SendClientMessage(playerid, -1, string);
       format(string, sizeof(string), "Vous pouvez postuler une demande d'unban sur playtheroleplay.forumactif.com.");
       SendClientMessage(playerid, -1, string);
       SetTimerEx("Kicka", 450, false, "i", playerid);
    }
    if(fexist(Path(playerid)))
    {
       ShowPlayerDialog(playerid, dialog_Login, DIALOG_STYLE_PASSWORD, "Identification", "Tapez votre mot de passe pour se connecter.", "Connexion", "Quitter");
       PlayerPlaySound(playerid,1185,0.0,0.0,0.0);
    }

    else if(!fexist(Path(playerid)))
    {
        ShowPlayerDialog(playerid, dialog_Register, DIALOG_STYLE_INPUT, "Identification", "Tapez votre mot de passe pour s'enregistrer.", "Enregistrer", "Quitter");
        PlayerPlaySound(playerid,1185,0.0,0.0,0.0);
        //TextDrawShowForPlayer(playerid, Tuto1);*
    }

    return true;
}
I'm going to give a rep for the person who helped me.
Reply
#2

Post the dialog_Login and dialog_Register dialogs on OnDialogResponse.
Reply
#3

I have some things for you:
1. Set all your player variables to 0 [reset them] after a player first register.
Reaosn: Why? this will keep the same variable stats for the next player connected with the precedent one's id.

Example: Josh(ID: 1) enters on the server, he register, gets max admin level as he owner's brother.
then: Micheal (ID :1 ) connects and gain all of Josh stats, and then his stats are saved, when disconnect.

Trust me, I had the same problem as you when I was creating my first server, without having any knowledge of how this works. All of my scripting problems I managed to solve them by myself.
Reply
#4

Make a stock where it resets every player variable when they log into the server. Be sure to also make sure that if they crash before their account stats can load that it doesn't save, otherwise when they log into the server, all their stats will be 0.

Example:
pawn Код:
stock ResetVars(playerid)
{
    pInfo[playerid][Banned] = 0;
    pInfo[playerid][Admin] = 0;
    pInfo[playerid][Money] = 0;
    return 1;
}

//Then apply this to OnPlayerConnect

public OnPlayerConnect(playerid)
{
    ResetVars(playerid);
    //Put whatever else you have here
    return 1;
}
Then, to make sure their stats don't save if they crash before they log in.

pawn Код:
//Make a PVar after they log in that looks something like:

SetPVarInt(playerid, "LoggedIn", 1);

//Then, under OnPlayerDisconnect (to make sure their stats don't save before they can load their stats after logging in)

public OnPlayerDisconnect(playerid, reason)
{
    if(GetPVarInt(playerid, "LoggedIn") == 1 && reason != 0)
    {
        //Put whatever you use to save stats here
    }
    return 1;
}
Reply
#5

It's already been set pretty much, when a player connects, you need to reset their variables.

http://prntscr.com/4q2lnh

like that pretty much, under onplayerconnect.
Reply
#6

Okay, a few things.

1. Don't post +rep in your threads, it makes spammers and idiots reply.
2. You can not give a reputation if you have a rep less than 0.
3. A stock, as posted above is pretty well pointless, as you'll only use it once..also it's pointless to ever add the word "stock" infront of your function.
4. Your issue is that you do not reset the variables. Under OnPlayerDisconnect, set all the variables in your player array to 0. If it's a string, for example a name, add new name[MAX_PLAYER_NAME]

pInfo[playerid][Name] = name; //your variable might be different

PM me if you need further explanation.
Reply
#7

Hello everybody,
Firstly, thanks for helping me and finally, I've found the solution for this problem, I had to add a func in OnPlayerDisconnect.
Код:
2. You can not give a reputation if you have a rep less than 0.
I don't know that, thanks.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)