Stopping every player getting something when they log in.
#1

Hello, recently come across a really really really annoying bug and have just deleted almost everything in my script to find it. (Back up of course :P) Basically if a player is in the game and they get something, then the next player who logs in also gets it. Can someone help me?
Reply
#2

If you mean that the next player with the same ID gets the same properties that the last player, then your script is most likely just not resetting some variables in OnPlayerDisconnect.
Reply
#3

Thanks for the response. No what is happening is that when I log in, and then my friend logs in, logs out, and join again they have my items. I'll try adding something to reset the variable on disconnect though and see if it works
Reply
#4

No it doesn't work Here is the code if it helps:

OnPlayerConnect
EDIT:
pawn Код:
ResetPlayerVariables(playerid);
OnPlayerDisconnect
pawn Код:
ResetPlayerVariables(playerid);
pawn Код:
stock ResetPlayerVariables(playerid)
{
    IsLogged[playerid] = 0;
    PlayerInfo[playerid][Admin] = 0;
    PlayerInfo[playerid][Survivor] = 0;
    PlayerInfo[playerid][Zombie] = 0;
    PlayerInfo[playerid][Money] = 0;
    PlayerInfo[playerid][Death] = 0;
    PlayerInfo[playerid][Infected] = 0;
    PlayerInfo[playerid][New] = 0;
    PlayerInfo[playerid][Skin] = 0;
}
Reply
#5

Quote:
Originally Posted by cloudysky
Посмотреть сообщение
Basically if a player is in the game and they get something, then the next player who logs in also gets it.
What is this "something" ?

Show how you load/save data from file/database
Reply
#6

The something is Money for example, or their skin. Anything that is saved to their account.

pawn Код:
public SaveUser(playerid)
{
    if(IsLogged[playerid] == 0) return 0;

    GetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
    GetPlayerArmour(playerid, PlayerInfo[playerid][Armour]);

    PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][Money] = GetPlayerMoney(playerid);

    dini_IntSet(Userfile, "Admin", PlayerInfo[playerid][Admin]);
    dini_IntSet(Userfile, "Survivor", PlayerInfo[playerid][Survivor]);
    dini_IntSet(Userfile, "Zombie", PlayerInfo[playerid][Zombie]);
    dini_IntSet(Userfile, "Money", PlayerInfo[playerid][Money]);
    dini_IntSet(Userfile, "Death", PlayerInfo[playerid][Death]);
    dini_IntSet(Userfile, "Infected", PlayerInfo[playerid][Infected]);
    dini_IntSet(Userfile, "New", PlayerInfo[playerid][New]);
    dini_IntSet(Userfile, "Skin", PlayerInfo[playerid][Skin]);

    if(PlayerInfo[playerid][Health] != 0) dini_FloatSet(Userfile, "Health", PlayerInfo[playerid][Health]);
    if(PlayerInfo[playerid][Armour] != 0) dini_FloatSet(Userfile, "Armour", PlayerInfo[playerid][Armour]);
    return 1;
}
pawn Код:
stock LoginUser(playerid)
{
    format(Userfile, sizeof(Userfile), "users/%s.ini", GetName(playerid));
    IsLogged[playerid] = 1;
    JustLogged[playerid] = 1;
    PlayerInfo[playerid][Admin] = dini_Int(Userfile, "Admin");
    PlayerInfo[playerid][Survivor] = dini_Int(Userfile, "Survivor");
    PlayerInfo[playerid][Zombie] = dini_Int(Userfile, "Zombie");
    PlayerInfo[playerid][Money] = dini_Int(Userfile, "Money");
    PlayerInfo[playerid][Death] = dini_Int(Userfile, "Death");
    PlayerInfo[playerid][Infected] = dini_Int(Userfile, "Infected");
    PlayerInfo[playerid][New] = dini_Int(Userfile, "New");
    PlayerInfo[playerid][Skin] = dini_Int(Userfile, "Skin");

    PlayerInfo[playerid][Health] = dini_Float(Userfile, "Health");
    PlayerInfo[playerid][Armour] = dini_Float(Userfile, "Armour");

    GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
    SetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
    SetPlayerArmour(playerid, PlayerInfo[playerid][Armour]);
    // Timers
    SaveTimer[playerid] = SetTimerEx("SaveUser", 1000, true, "i", playerid);
    return SendClientMessage(playerid, COLOUR_GREEN, "Logged in.");
}
Reply
#7

You should use this

pawn Код:
format(Userfile, sizeof(Userfile), "users/%s.ini", GetName(playerid));
in SaveUser too.
Reply
#8

i think there is some wrong code on load and save playerinfo

mademan was right !
pawn Код:
public SaveUser(playerid)
{
    if(IsLogged[playerid] == 0) return 0;
    format(Userfile, sizeof(Userfile), "users/%s.ini", GetName(playerid));
    GetPlayerHealth(playerid, PlayerInfo[playerid][Health]);
    GetPlayerArmour(playerid, PlayerInfo[playerid][Armour]);

    PlayerInfo[playerid][Skin] = GetPlayerSkin(playerid);
    PlayerInfo[playerid][Money] = GetPlayerMoney(playerid);

    dini_IntSet(Userfile, "Admin", PlayerInfo[playerid][Admin]);
    dini_IntSet(Userfile, "Survivor", PlayerInfo[playerid][Survivor]);
    dini_IntSet(Userfile, "Zombie", PlayerInfo[playerid][Zombie]);
    dini_IntSet(Userfile, "Money", PlayerInfo[playerid][Money]);
    dini_IntSet(Userfile, "Death", PlayerInfo[playerid][Death]);
    dini_IntSet(Userfile, "Infected", PlayerInfo[playerid][Infected]);
    dini_IntSet(Userfile, "New", PlayerInfo[playerid][New]);
    dini_IntSet(Userfile, "Skin", PlayerInfo[playerid][Skin]);

    if(PlayerInfo[playerid][Health] != 0) dini_FloatSet(Userfile, "Health", PlayerInfo[playerid][Health]);
    if(PlayerInfo[playerid][Armour] != 0) dini_FloatSet(Userfile, "Armour", PlayerInfo[playerid][Armour]);
    return 1;
}
Reply
#9

Quote:
Originally Posted by Horrible
Посмотреть сообщение
i think there is some wrong code on load and save playerinfo
Captain Obvious, is that you?
Reply
#10

Quote:
Originally Posted by MadeMan
Посмотреть сообщение
Captain Obvious, is that you?
honestly i dont understand

but maybe it's kind of joke
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)