Help please - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Help please (
/showthread.php?tid=262200)
Help please -
bartje01 - 16.06.2011
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?
Re: Help please -
Laronic - 16.06.2011
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
PlayerInfo[playerid][seeds] = 0;
return 1;
}
Re: Help please -
Donya - 16.06.2011
Quote:
Originally Posted by CyberGhost
pawn Код:
public OnPlayerDisconnect(playerid, reason) { PlayerInfo[playerid][seeds] = 0; return 1; }
|
and OnPlayerConnect.
Re: Help please -
Calgon - 16.06.2011
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.
Re: Help please -
Donya - 16.06.2011
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.