SA-MP Forums Archive
Little 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)
+--- Thread: Little help. (/showthread.php?tid=312170)



Little help. - iZN - 20.01.2012

I've created moving camera in Class Selection. It's working fine, i spawn player it spawns BUT when i choose some other player class like the second one, the player doesn't spawns and the camera gets still on the Class Selection. The first player class is spawned correctly but the other ones are not spawning -.- Anybody can tell me, what i can do with it?


Re: Little help. - TheLazySloth - 20.01.2012

Show code?


Re: Little help. - iPLEOMAX - 20.01.2012

Pretty sure it's code related problem. We can't help you if you don't show us some part of your code.


Re: Little help. - iZN - 20.01.2012

This is at OnPlayerRequestClass

pawn Код:
PlayerInfo[playerid][SpawnTimer] = SetTimerEx("MoveCamera", moving_speed, true, "i", playerid);
This is the callback i created
pawn Код:
forward MoveCamera(playerid);
public MoveCamera(playerid)
{
    SetPlayerCameraPos(playerid, player_x - 2 * floatsin(-PlayerInfo[playerid][SpawnAngle], degrees), player_y - 10 * floatcos(-PlayerInfo[playerid][SpawnAngle], degrees), player_z + 3);
    SetPlayerCameraLookAt(playerid, player_xE, player_yE, player_zE + 0.5);
    PlayerInfo[playerid][SpawnAngle] += 0.5;
    if (PlayerInfo[playerid][SpawnAngle] >= 360.0)
        PlayerInfo[playerid][SpawnAngle] = 0.0;
}
This is at my OnPlayerSpawn

pawn Код:
PlayerInfo[playerid][SpawnAngle] = 0.0;
    KillTimer( PlayerInfo[playerid][SpawnTimer] ); //to kill it, since its useless now
    new r = random(sizeof(spawns));
    SetPlayerPos(playerid, spawns[r][ex], spawns[r][ey], spawns[r][ez]);
    SetPlayerInterior(playerid, spawns[r][interior]);
    SendClientMessage(playerid, COLOR_WHITE, spawns[r][emsg]);



Re: Little help. - TheLazySloth - 20.01.2012

Nevermind...
This code looks fine provided all the variables are correct.
Try adding KillTimer(PlayerInfo[playerid][SpawnTimer]); above PlayerInfo[playerid][SpawnTimer] = SetTimerEx("MoveCamera", moving_speed, true, "i", playerid); in OnPlayerRequestClass
and change the code in OnPlayerSpawn to OnPlayerRequestSpawn


Re: Little help. - iZN - 20.01.2012

Quote:
Originally Posted by TheLazySloth
Посмотреть сообщение
Nevermind...
This code looks fine provided all the variables are correct.
Try adding KillTimer(PlayerInfo[playerid][SpawnTimer]); above PlayerInfo[playerid][SpawnTimer] = SetTimerEx("MoveCamera", moving_speed, true, "i", playerid); in OnPlayerRequestClass
and change the code in OnPlayerSpawn to OnPlayerRequestSpawn
Worked! Thank you. +rep for ya


Re: Little help. - TheLazySloth - 22.01.2012

You're welcome.