SA-MP Forums Archive
Timer Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Timer Help (/showthread.php?tid=200783)



Timer Help - jameskmonger - 19.12.2010

In my server, I've got this:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, -2829.4509,2601.7959,160.1133);
    TogglePlayerControllable(playerid, 0);
    SetPlayerCameraLookAt(playerid,-2482.0869,2384.7859,13.3606);
    SetPlayerCameraPos(playerid,-2287.3457,2080.9849,10.2316);
    SetTimerEx("BaysideCameras", 1500, 0, "i", playerid);
    return 1;
}
And here's my BaysideCameras method:
pawn Код:
public BaySideCameras(playerid)
{
    new camera;
    switch(camera) {
        case 0: SetPlayerCameraPos(playerid,-2287.3457,2080.9849,10.2316);
        case 1: SetPlayerCameraPos(playerid,-2222.0532,2169.4048,58.7913);
        case 2: SetPlayerCameraPos(playerid,-2186.5342,2428.9966,58.7913);
        case 3: SetPlayerCameraPos(playerid,-2350.1245,2559.9856,58.7913);
        case 4: SetPlayerCameraPos(playerid,-2604.7361,2597.5889,91.1503);
        case 5: SetPlayerCameraPos(playerid,-2741.2986,2435.5330,91.4912);
        case 6: SetPlayerCameraPos(playerid,-2663.8237,2143.5085,72.0710);
    }
    if(camera < 6) {
        camera++;
    } else if(camera == 6) {
        camera = 0;
    }
}
So I log on and wait at the class selection, and nothing happens. What's wrong?


Re: Timer Help - Norck - 19.12.2010

Quote:

What's wrong?

1) Your function is 'BaySideCameras'
And in your timer you named it as 'BaysideCameras' ('s' instead of 'S');
2) Your 'BaySideCameras' doesn't return any value;
3) You set your timer only once;

Let's add a second argument 'camera' to the 'BaysideCameras' , so OnPlayerRequestClass will looks like this
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, -2829.4509,2601.7959,160.1133);
    TogglePlayerControllable(playerid, 0);
    SetPlayerCameraLookAt(playerid,-2482.0869,2384.7859,13.3606);
    SetPlayerCameraPos(playerid,-2287.3457,2080.9849,10.2316);
    SetTimerEx("BaySideCameras", 1500, 0, "ii", playerid,0);//camera = 0
    return 1;
}
And the BaySideCameras
pawn Код:
public BaySideCameras(playerid,camera)
{
    switch(camera)
    {
        case 0: SetPlayerCameraPos(playerid,-2287.3457,2080.9849,10.2316);
        case 1: SetPlayerCameraPos(playerid,-2222.0532,2169.4048,58.7913);
        case 2: SetPlayerCameraPos(playerid,-2186.5342,2428.9966,58.7913);
        case 3: SetPlayerCameraPos(playerid,-2350.1245,2559.9856,58.7913);
        case 4: SetPlayerCameraPos(playerid,-2604.7361,2597.5889,91.1503);
        case 5: SetPlayerCameraPos(playerid,-2741.2986,2435.5330,91.4912);
        case 6: SetPlayerCameraPos(playerid,-2663.8237,2143.5085,72.0710);
    }
    if(camera < 6)
    camera++;
    else
    camera = 0;
    SetTimerEx("BaySideCameras", 1500, 0, "ii", playerid,camera);//Let's set our timer again, but with new camera
    return 1;//should return a value
}
Check this out, i quess it should work as you wanted.


Re: Timer Help - jameskmonger - 19.12.2010

I go to the request class screen and the camera still doesn't change.


Re: Timer Help - Norck - 19.12.2010

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
I go to the request class screen and the camera still doesn't change.
Even if you select a different classid ?


Re: Timer Help - jameskmonger - 19.12.2010

I have no classes, I don't want them to be able to pick their class.


Re: Timer Help - Norck - 19.12.2010

Quote:
Originally Posted by jameskmonger
Посмотреть сообщение
I have no classes, I don't want them to be able to pick their class.
Doesn't matter. Did you tried to press that buttons that should show you a different classid?

However, try to put your 'OnPlayerRequestClass' code to 'OnPlayerConnect' callback


Re: Timer Help - MadeMan - 19.12.2010

You need to use SetPlayerCameraLookAt also.


Re: Timer Help - jameskmonger - 19.12.2010

Thankyou, it works perfectly now!