Needed an idea. :)
#1

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.
Reply
#2

Quote:
Originally Posted by TaLhA XIV
Посмотреть сообщение
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.
pawn Код:
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
    }
}
Hope this helps.

Regards,
FalconX
Reply
#3

You can use it like this:

pawn Код:
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
           }
      }
}
Reply
#4

No you did not understand my question.Let me explain it the simple way,as an hour passes,it stores it,like if a player plays 2 hours then it becomes two,and when a player plays another hour,it updates to 3,and when it reaches 9,players score reaches a level higher that it becomes from 2 to 3 from 5 to 6etc,like that,anyways thatnks for the help but anyone else please help.
Reply
#5

sorry i was late to post but thanks.
Reply
#6

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.
Reply
#7

Quote:

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.

Yes!He is right.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)