How to use timers ? -
marinov - 28.11.2010
I'm making one of those Video tutorial on OnPlayerConnect and I want the camera to look at different places as the text appears, how do I use the timers to change the camera pos, and the camera look at ?
Re: How to use timers ? -
XePloiT - 28.11.2010
https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
Re: How to use timers ? -
marinov - 28.11.2010
read those already, I still don't know how to use them
Re: How to use timers ? -
marinov - 28.11.2010
pawn Код:
SetTimer("Tutorial", 5000, true);
pawn Код:
public Tutorial()
{
if(team(playerid) == 0)
{
SetPlayerCameraPos(playerid, 286.32, 1785.15, 63.57);
SetPlayerCameraLookAt(playerid, 203.95, 1902.99, 17.64);
}
return 1;
}
Did this just to test, is it right ?
Re: How to use timers ? -
Retardedwolf - 28.11.2010
No.
pawn Код:
forward tutorial ( playerid );
SetTimerEx ( "tutorial", 5000, false, "d", playerid );
Re: How to use timers ? -
marinov - 28.11.2010
let me try
Re: How to use timers ? -
XoSarahMoX - 28.11.2010
Umm well lets make a simple timer
First we need to find out what we want this timer to do, lets say we want it to send the player somewhere after they die

.
So we do this just above:
Код:
public OnPlayerDeath(playerid)
Put this:
Код:
forward changethistotimernamehere(playerid);
Now go under OnPlayerDeath and put this:
Код:
SetTimer("changethistotimernamehere",milliseconds, repeat or not);
For the milliseconds know that (1000 milliseconds = 1 second) and if you want it to repeat put 1 and if not put 0
After that lets make a new public for this timer, so underneath our current onplayerdeath code:
Код:
forward Timerexample(playerid);
public OnPlayerDeath(playerid)
{
SetTimer("Timerexample", 2500, 0);
return 1;
}
Put this:
Код:
public Timerexample(playerid)
{
//CODE HERE
return 1;
}
So lets say we want them to teleport we do this:
Код:
public Timerexample(playerid)
{
SetPlayerPos(playerid, coords);
return 1;
}
So pretty much what we did is after the player dies a timer will start, after the timer finishes it will do whatever actions are in its public

.
All together it looks like this:
Код:
forward Timerexample(playerid);
public OnPlayerDeath(playerid)
{
SetTimer("Timerexample", 2500, 0);
return 1;
}
public Timerexample(playerid)
{
SetPlayerPos(playerid, coords);
return 1;
}
Goodluck

!
Re: How to use timers ? -
marinov - 28.11.2010
wow bro nice tut, I will try it now xD
Re: How to use timers ? -
XoSarahMoX - 28.11.2010
Thanks and goodluck

.
Re: How to use timers ? -
Anthonyx3' - 28.11.2010
Quote:
Originally Posted by XoSarahMoX
Umm well lets make a simple timer
First we need to find out what we want this timer to do, lets say we want it to send the player somewhere after they die  .
So we do this just above:
Код:
public OnPlayerDeath(playerid)
Put this:
Код:
forward changethistotimernamehere(playerid);
Now go under OnPlayerDeath and put this:
Код:
SetTimer("changethistotimernamehere",milliseconds, repeat or not);
For the milliseconds know that (1000 milliseconds = 1 second) and if you want it to repeat put 1 and if not put 0
After that lets make a new public for this timer, so underneath our current onplayerdeath code:
Код:
forward Timerexample(playerid);
public OnPlayerDeath(playerid)
{
SetTimer("Timerexample", 2500, 0);
return 1;
}
Put this:
Код:
public Timerexample(playerid)
{
//CODE HERE
return 1;
}
So lets say we want them to teleport we do this:
Код:
public Timerexample(playerid)
{
SetPlayerPos(playerid, coords);
return 1;
}
So pretty much what we did is after the player dies a timer will start, after the timer finishes it will do whatever actions are in its public  .
All together it looks like this:
Код:
forward Timerexample(playerid);
public OnPlayerDeath(playerid)
{
SetTimer("Timerexample", 2500, 0);
return 1;
}
public Timerexample(playerid)
{
SetPlayerPos(playerid, coords);
return 1;
}
Goodluck  !
|
Nice mini-tut, you just helped me understand timers, just when i needed them too