PDA

View Full Version : Little help.


iZN
20/01/2012, 09:29 AM
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?

TheLazySloth
20/01/2012, 09:31 AM
Show code?

iPLEOMAX
20/01/2012, 09:31 AM
Pretty sure it's code related problem. We can't help you if you don't show us some part of your code.

iZN
20/01/2012, 09:40 AM
This is at OnPlayerRequestClass


PlayerInfo[playerid][SpawnTimer] = SetTimerEx("MoveCamera", moving_speed, true, "i", playerid);


This is the callback i created

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


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]);

TheLazySloth
20/01/2012, 09:42 AM
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

iZN
20/01/2012, 10:03 AM
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 :)

TheLazySloth
22/01/2012, 11:15 AM
You're welcome.