PDA

View Full Version : Client crash


Wesley221
07/08/2012, 01:49 PM
Hey guys,

I want if you die, that you gonna spectate the map for 10 seconds. Ive made the function for it, it all works; but somehow after 1 second my client crashes.

Anyone can take a look over my code?


//OnPlayerDeath
WatchMap( playerid, CurrentMap );

//watchmap function
stock WatchMap(playerid, mapid)
{
if( mapid == 0 )
{
TogglePlayerControllable( playerid, false );

SetPlayerPos( playerid, 0.0, 0.0, 3.0 );

new pos = random( 3 );

switch( pos )
{
case 0:
{
SetPlayerCameraPos( playerid, 1381.8101, 1912.3900, 268.3900 );
SetPlayerCameraLookAt( playerid, 1381.7400, 1911.3900, 267.9700 );
}
case 1:
{
SetPlayerCameraPos( playerid, 1150.4301, 1805.5699, 254.2200 );
SetPlayerCameraLookAt( playerid, 1151.4301, 1805.6300, 253.7900 );
}
case 2:
{
SetPlayerCameraPos( playerid, 1125.5100, 1655.7600, 221.2900 );
SetPlayerCameraLookAt( playerid, 1126.3700, 1656.2700, 220.9700 );
}
}

}

CameraBack[playerid] = SetTimerEx( "Cameraback", 1000, true, "i", playerid );

return 1;
}

// Cameraback timer
forward Cameraback(playerid);
public Cameraback(playerid)
{
new string[20];
format( string, sizeof string, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~%i", CameraBackTicks[playerid] );
GameTextForPlayer( playerid, string, 1000, 3 );

CameraBackTicks[playerid] --;

if( CameraBackTicks[playerid] == 0 )
{
SetCameraBehindPlayer( playerid );
TogglePlayerSpectating( playerid, false );
TogglePlayerControllable( playerid, true );
SpawnPlayer( playerid );
KillTimer( CameraBack[playerid] );
CameraBackTicks[playerid] = 10;
GameTextForPlayer( playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~You have been spawned!", 2000, 3 );
}
return 1;
}

All variables DO work, and CameraBackTicks starts at 10 by default. So that cant be the problem

~Wesley

Edit:
Ive just added a little debuggin:

printf( "%i", CameraBackTicks[playerid] );
print( string );

This is what it prints:

[16:40:30] 10
[16:40:30] ~n~~n~~n~~n~~n~~n~~
[16:40:32] 9
[16:40:32] ~n~~n~~n~~n~~n~~n~~
[16:40:33] 8
[16:40:33] ~n~~n~~n~~n~~n~~n~~
[16:40:34] 7
[16:40:34] ~n~~n~~n~~n~~n~~n~~
[16:40:35] 6
[16:40:35] ~n~~n~~n~~n~~n~~n~~
[16:40:36] 5
[16:40:36] ~n~~n~~n~~n~~n~~n~~
[16:40:37] 4
[16:40:37] ~n~~n~~n~~n~~n~~n~~
[16:40:38] 3
[16:40:38] ~n~~n~~n~~n~~n~~n~~
[16:40:39] 2
[16:40:39] ~n~~n~~n~~n~~n~~n~~
[16:40:40] 1
[16:40:40] ~n~~n~~n~~n~~n~~n~~
Strange thing is, with the string it doesnt show the numbers (10 to 1), and with just normal print %i, it does