03.08.2009, 12:33
Remember - 0/false = no 1/true = yes
_________________________________________________
Timers
There are two types - SetTimer and SetTimerEx
Timers can cause alot of problems - best to keep them minimal - if you cant, merge timers together.
SetTimer("Timer",60000,true);
the Timer is in " " because it needs to - dont know why...lol
the second is your interval, in miliseconds - 60000 = 1 min - 1 min - 60 second - http://www.calculateme.com/Time/Minu...lliseconds.htm
now the repeating is the last. set it to false if you DONT want it to repeat or if you DO want it to repeat use true.
All timers need forwardation. so under your #include area put forward Timer;
that forwards the timer so you can set a public - so anywhere put public Timer
then you can do what you want
SetTimerEx("Timer",60000,false,"i",playerid);
this is different, this will work for the player who exicuted it. being playerid.
forwardation for this looks like this: forward Timer(playerid);
its all the same except the last two things that i dont know why they are there
- maybe check the wiki.
they can be used like this
thats pretty much it....
_________________________________________________
Making player Variables and assigning them to help with somehting(All shown here is an example)
under all your #includes put this:
dont forget to forward Spawncheck(playerid);
_________________________________________________
Randoms
Spawns
Say you have made an armydm teleport command - with the syntax /armydm [1-2]
this is how you create it
after the command line
so if you do /armydm 1 - case 1: will be called and vice versa
thanks hope you learned, will add more maybe
_________________________________________________
Timers
There are two types - SetTimer and SetTimerEx
Timers can cause alot of problems - best to keep them minimal - if you cant, merge timers together.
SetTimer("Timer",60000,true);
the Timer is in " " because it needs to - dont know why...lol
the second is your interval, in miliseconds - 60000 = 1 min - 1 min - 60 second - http://www.calculateme.com/Time/Minu...lliseconds.htm
now the repeating is the last. set it to false if you DONT want it to repeat or if you DO want it to repeat use true.
All timers need forwardation. so under your #include area put forward Timer;
that forwards the timer so you can set a public - so anywhere put public Timer
then you can do what you want
Quote:
public Timer { //enter your code here } |
this is different, this will work for the player who exicuted it. being playerid.
forwardation for this looks like this: forward Timer(playerid);
its all the same except the last two things that i dont know why they are there
![Cheesy](images/smilies/biggrin.png)
they can be used like this
Quote:
public OnPlayerSpawn(playerid) { TogglePlayerControllable(playerid,0); SendClientMessage(playerid,COLOR_BLUE,"You are frozen for one minute. Please wait"); return 1; } public Timer(playerid) { SendClientMessage(playerid,COLOR_BLUE,"You may move now"); TogglePlayerControllable(playerid,1); } |
_________________________________________________
Making player Variables and assigning them to help with somehting(All shown here is an example)
under all your #includes put this:
Quote:
new PlayerSpawned[MAX_PLAYERS];// this created the player variable public OnPlayerConnect(playerid) { PlayerSpawned[playerid] = 0;//sets the players variable to 0 SetTimerEx("Spawncheck",30000,false,"i",playerid); return 1; } public OnPlayerSpawn(playerid) { PlayerSpawned[playerid] = 1;// this will by-pass the spawn check return 1; } } public SpawnCheck(playerid) { if(PlayerSpawned[playerid] == 0)// if it is equal to 1 - timer will just run out { SendClientMessage(playerid,COLOR_RED,"You have been kicked - you took too long to spawn!"); Kick(playerid); return 1; } } |
_________________________________________________
Randoms
Spawns
Quote:
public OnPlayerSpawn(playerid) { new RandSpawns = random(5); // the number can be as many cases as you want - 5 is for example switch(RandSpawns) { case 0: SetPlayerPos(playerid....... // MUST start with case 0: case 1: SetPlayerPos(playerid....... case 2: SetPlayerPos(playerid....... case 3: SetPlayerPos(playerid....... case 4: SetPlayerPos(playerid.......// 5 will end at case 4: because of case 0: } return 1; } } |
this is how you create it
after the command line
Quote:
new ID; switch(ID) { case 1: SetPlayerPos(playerid...... // ONLY TIME case can start at 1 instead of 0 case 2: SetPlayerPos(playerid...... } return 1; } |
thanks hope you learned, will add more maybe