Hello,
I wanted an idea that how to make a thing that a timer keeps on going on and when 1 hour passes,the pInfo updates it self like if a players info is 1((PlayerInfo[playerid][leveldate])) it reaches to 2 after an hour,and so on,and when it reaches 9,players score is +1,Please don't make the whold script because i am a learner and want to learn ba ma self so just give me a idea or just provide me a small code for an example. ThAnKs. |
new n_bTimeTicks; // at top declaring new variable (global)
forward LevelByTime( ); // if we make a public function we do need a forward so add this at top
SetTimer( "LevelByTime", 1000, true ); // put this in OnGamemodeInit
public LevelByTime( ) // when the timer runs even 1000 ms it will use this public callback
{
n_bTimeTicks++; // every second it increases ++ means add 1 number every second
switch( n_bTimeTicks ) // switching time ticks
{
case 10: // 10 seconds
{
// your code - you can use foreach or a normal for-loop for all the players like this:
for( new playerid = 0; playerid < MAX_PLAYERS; playerid++ )
{
if( IsPlayerConnected( playerid ) )
{
PlayerInfo[ playerid ][ leveldate ] = 10; // you can now add any value you want if you want plus use PlayerInfo[ playerid ][ leveldate ] += 0 and minus will become -=
}
}
}
case 20: // 20 seconds
{
// your code
}
// you can use your own seconds like case 120: which means 2 minutes
}
}
forward Update(); // place this on top of your script
SetTimer("Update", 600000*6, true); // 60 minutes if I'm correct, put it under your OnGameModeInit
public Update() // place this somewhere in your script
{
for(new i=0;i<MAX_PLAYERS<i++) // goes through all players
{
Playerinfo[i][leveldate] += 1; // increases the leveldate variable by 1
if(PlayerInfo[i][leveldate] == 9) // if leveldate is 9
{
PlayerInfo[i][score] += 1; // increase player's score by 1
SetPlayerScore(i, PlayerInfo[i][score]); // set player's score to a new value
}
}
}
He mean a sort of an experience system, each 9 hour (will get bigger at the amount of score the player have) he will gain a new score point - Level. |