PDA

View Full Version : Age system


rokasma
09/11/2012, 07:30 PM
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.

scottyishere
09/11/2012, 08:18 PM
Add a timer on OnGameModeInit, something like SetTimer("hourlytime",1000*60*60,true);
Then add the function:

forward hourlytime();
public hourlytime()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(CurrentXP[i]>=1000)
{
CurrentAge[i]++;
CurrentXP[i]-=1000;
}
}
}

scottyishere
09/11/2012, 08:20 PM
Add a timer on OnGameModeInit, something like SetTimer("hourlytime",1000*60*60,true);
Then add the function:

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:

[player receives XP]
if(CurrentXP[playerid]>=1000)
[stuff I did above]

FalconWingsX
09/11/2012, 08:28 PM
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.

rokasma
09/11/2012, 08:32 PM
thanks, i try it.