How to use timers ?
#1

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

https://sampwiki.blast.hk/wiki/SetTimer
https://sampwiki.blast.hk/wiki/SetTimerEx
Reply
#3

read those already, I still don't know how to use them
Reply
#4

pawn Код:
forward Tutorial();
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 ?
Reply
#5

No.

pawn Код:
forward tutorial ( playerid );

SetTimerEx ( "tutorial", 5000, false, "d", playerid );
Reply
#6

let me try
Reply
#7

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 !
Reply
#8

wow bro nice tut, I will try it now xD
Reply
#9

Thanks and goodluck .
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)