SA-MP Forums Archive
Age system - 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: Age system (/showthread.php?tid=391182)



Age system - rokasma - 09.11.2012

Hello everyone, as you can see I need help with Age system.

I will explain about system as it should be.

When you collect 1000xp you get +1 years (if you were 20 years old, and has collected 1000xp you will be 21 at the time).

Does anyone can give me an idea of ​​how to know when a player raises 1000xp on server?

How do I calculate this?

Help please

P.S. If you still don't understant what I mean, I want to make a function every time when a player rises 1000xp.


Re: Age system - scottyishere - 09.11.2012

Add a timer on OnGameModeInit, something like SetTimer("hourlytime",1000*60*60,true);
Then add the function:
pawn Code:
forward hourlytime();
public hourlytime()
{
   for(new i=0;i<MAX_PLAYERS;i++)
   {
       if(CurrentXP[i]>=1000)
       {
            CurrentAge[i]++;
            CurrentXP[i]-=1000;
       }
   }
}



Re: Age system - scottyishere - 09.11.2012

Quote:
Originally Posted by scottyishere
View Post
Add a timer on OnGameModeInit, something like SetTimer("hourlytime",1000*60*60,true);
Then add the function:
pawn Code:
forward hourlytime();
public hourlytime()
{
   for(new i=0;i<MAX_PLAYERS;i++)
   {
       if(CurrentXP[i]>=1000)
       {
            CurrentAge[i]++;
            CurrentXP[i]-=1000;
       }
   }
}
Oh, now I get it. You can do a check each time the player receives the XP. Like:
pawn Code:
[player receives XP]
if(CurrentXP[playerid]>=1000)
   [stuff I did above]



Re: Age system - FalconWingsX - 09.11.2012

Also, creating a timer that starts when a player connects, and on paytime, making sure it's above 40 minutes, and at paytime, reseting it, and at disconnect, reseting it. Since otherwise, the paytime would be easily abused.


Re: Age system - rokasma - 09.11.2012

thanks, i try it.