Help please
#1

Hey all. I want to give people seeds. I have this on a timer.

pawn Код:
public GiveSeeds(playerid)
{
    PlayerInfo[playerid][seeds] ++;
    format(String,sizeof(String),"Youґve gained a seed. You now have %d seeds",PlayerInfo[playerid][seeds]);
    SendClientMessage(playerid,COLOR_YELLOW,String);
    SendClientMessage(playerid,COLOR_ORANGE,"You'll gain a seed each 15 minutes");
}
Now when I have 50 seeds and someone comes online he has 50 seeds as well. How can I fix this?
Reply
#2

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    PlayerInfo[playerid][seeds] = 0;
    return 1;
}
Reply
#3

Quote:
Originally Posted by CyberGhost
Посмотреть сообщение
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    PlayerInfo[playerid][seeds] = 0;
    return 1;
}
and OnPlayerConnect.
Reply
#4

Quote:
Originally Posted by Donya
Посмотреть сообщение
and OnPlayerConnect.
If a variable is reset to 0 when a player disconnects, a reset back to 0 when a player connects is obsolete. Default values for integers are always 0, so you're doing the exact same thing twice for no valid reason.
Reply
#5

hmm, but why not put it in onplayerconnect only?

Default values for integers are 0 yes, you are right in all ways, but sometimes variables get mixed up, it has happened to me all the time, thats why i put it in onplayerconnect.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)