SetTimerEx problem
#1

Hello.

I have a little problem, and i'm desperate with this already - Everthing i tried failed, so i'm asking here for help. Here's the deal.

I do this in one of my custom functions -
Код:
SetTimerEx( "MovingCamera", MOVING_CAMERA_FPS, true, "i", playerid );
It's a 50 millisecond timer which moves camera around player during the tutorial, so it's critical that i kill it at some point. But the timer won't even start. However, if i do -

Код:
SetTimerEx( "MovingCamera", MOVING_CAMERA_FPS, true, "i", playerid ), SetTimerEx( "MovingCamera", MOVING_CAMERA_FPS, true, "i", playerid );
It works for some reason. Until the point where i got to kill it, then it won't stop. I tried debuging it with printf's and messages and the timer won't start if i do SetTimerEx just once. No errors, warnings, nothing.

I tried it with y_timers too, and it just won't start.

I think this is SetTimerEx bug, because even if do
Код:
MovingCamera( playerid ) { print( "It works!" ); return true; }
nothing happens.

Has anyone got any experience on this?
Reply
#2

It could be the timer itself, post it's code.
Reply
#3

I don't think so, because, as i said, it won't execute even the print function, nothing. Here is the code anyway.

Код:
function MovingCamera( playerid ) {

	RotateCameraAroundPoint( playerid, ServerInfo[ MainSpawnX ], ServerInfo[ MainSpawnY ], ServerInfo[ MainSpawnZ ], 2, 10, 3 );
	return true;
}
And then this function

Код:
RotateCameraAroundPoint( playerid, Float:X, Float:Y, Float:Z, Offset_X, Offset_Y, Offset_Z ) {

	SetPlayerCameraPos( playerid, X - Offset_X * floatsin( - PlayerInfoEx[ playerid ][ CameraSpawnAngle ], degrees ), Y - Offset_Y * floatcos( - PlayerInfoEx[ playerid ][ CameraSpawnAngle ], degrees ), Z + Offset_Z );
	SetPlayerCameraLookAt( playerid, X, Y, Z + 0.5 );

	PlayerInfoEx[ playerid ][ CameraSpawnAngle ] += 0.5;

	if( PlayerInfoEx[ playerid ][ CameraSpawnAngle ] >= 360.0) PlayerInfoEx[ playerid ][ CameraSpawnAngle ] = 0.0;

	return true;
}
Reply
#4

Well there's your problem, it's not "function" its "public"

Код:
forward MovingCamera(playerid);
public MovingCamera( playerid ) {

	RotateCameraAroundPoint( playerid, ServerInfo[ MainSpawnX ], ServerInfo[ MainSpawnY ], ServerInfo[ MainSpawnZ ], 2, 10, 3 );
	return true;
}
Reply
#5

'function' is just a macro, so i don't have to forward every public -
Код:
#define function%0(%1)                             forward %0(%1); public %0(%1)
I am absolutely sure that this is related to SetTimerEx not passing a correct value, playerid. Even though this has never happened to me before.
Reply
#6

Show where you set and kill the timers.
Reply
#7

Код:
ShowXomnia( playerid ) { 
	
	PlayerInfo[ playerid ][ xTutStep ] = 0;
	UpdatePlayer( playerid );
	
	TextDrawSetString( IntroTxt[ playerid ][ 5 ], TutorialTitles[ PlayerInfo[ playerid ][ xTutStep ] ] );
	TextDrawSetString( IntroTxt[ playerid ][ 6 ], TutorialStrings[ PlayerInfo[ playerid ][ xTutStep ] ] );
	
	for( new i = 0; i < 7; i++ ) {
		
		TextDrawShowForPlayer( playerid, IntroTxt[ playerid ][ i ] );
	}
	
	SetPlayerPos( playerid, ServerInfo[ MainSpawnX ], ServerInfo[ MainSpawnY ], ServerInfo[ MainSpawnZ ] );
	SetPlayerFacingAngle( playerid, ServerInfo[ MainSpawnA ] );
	SetPlayerInterior( playerid, ServerInfo[ MainSpawnInterior ] );
	SetPlayerVirtualWorld( playerid, ServerInfo[ MainSpawnVirtualWorld ] );
	
	SetPlayerCameraPos( playerid, ServerInfo[ MainSpawnX ] - TUTORIAL_CAMERA_OFFSET_X, ServerInfo[ MainSpawnY ] - TUTORIAL_CAMERA_OFFSET_Y, ServerInfo[ MainSpawnZ ] + TUTORIAL_CAMERA_OFFSET_Z );
	SetPlayerCameraLookAt( playerid, ServerInfo[ MainSpawnX ], ServerInfo[ MainSpawnY ], ServerInfo[ MainSpawnZ ] );

	TogglePlayerControllable( playerid, 0 );

	Timer_xMoving[ playerid ] = SetTimerEx( "MovingCamera", MOVING_CAMERA_FPS, true, "i", playerid );
	return true;
}
Код:
function FirstTutorial( playerid ) {

	if( PlayerInfo[ playerid ][ xTutStep ] < 6 ) {
	
		TogglePlayerControllable( playerid, 0 );
		
		PlayerInfo[ playerid ][ xTutStep ]++;
		OnPlayerUpdateEx( playerid );
		
		TextDrawSetString( IntroTxt[ playerid ][ 5 ], TutorialTitles[ PlayerInfo[ playerid ][ xTutStep ] ] );
		TextDrawSetString( IntroTxt[ playerid ][ 6 ], TutorialStrings[ PlayerInfo[ playerid ][ xTutStep ] ] );
		
		return true;

	}
	else {
	
		for( new i = 0; i < 7; i++ ) TextDrawHideForPlayer( playerid, IntroTxt[ playerid ][ i ] );

		PlayerInfo[ playerid ][ xTutStep ] = 255;
		UpdatePlayer( playerid );

		KillTimer( Timer_xMoving[ playerid ] );

		SetSpawnForPlayer( playerid );
		SetCameraBehindPlayer( playerid );
	
	}
	
	return true;

}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)