SA-MP Forums Archive
Moving Camera on Request Class - 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: Moving Camera on Request Class (/showthread.php?tid=596799)



Moving Camera on Request Class - FunnyBear - 22.12.2015

Hey there,

I've recently used Drebin's Camera Editor filterscript to generate a camera movement so I can implement into my script.

The output was as follows:

Код:
InterpolateCameraPos(playerid, 1542.339843, -1676.244384, 30.847208, 1421.688476, -1647.271606, 38.576740, 2000);
InterpolateCameraLookAt(playerid, 1547.319580, -1676.068481, 30.433620, 1418.010864, -1643.885131, 38.490806, 2000);
How can I install that into my script so that the camera only starts moving when you go onto a different class? Because at the moment it moves as soon as you go onto OnPlayerRequestClass and as soon as you press the side arrows...

Adding it into the following:

Код:
switch ( classid )
{
	case 0 .. 6 :
	{


	}
	case 7 .. 8 :
	{

	}
}
Can you please help?

Thanks,

FunnyBear


Re: Moving Camera on Request Class - FunnyBear - 23.12.2015

Can someone please help?

Thanks


Re: Moving Camera on Request Class - vassilis - 23.12.2015

I don't get it. You want the camera to move when player is pressing buttons < > OnPlayerRequestclass callback ?


Re: Moving Camera on Request Class - FunnyBear - 23.12.2015

Quote:
Originally Posted by vassilis
Посмотреть сообщение
I don't get it. You want the camera to move when player is pressing buttons < > OnPlayerRequestclass callback ?
Yes, that is what I would like. For example, whenever you press one of the <> buttons, it swiftly moves to another building


Re: Moving Camera on Request Class - RoboN1X - 23.12.2015

Try to use SetPlayerCameraPos and SetPlayerCameraLookAt instead (you can't set the time though, so the time depends on distance between cameras)... You will have to store the camera offset values for each class.
Код:
public OnPlayerRequestClass(playerid, classid)
{
	new Float:CCPX, Float:CCPY, Float:CCPZ, // CCP stands for Class Camera Pos
		Float:CCLX, Float:CCLY, Float:CCLZ; // CCL stands for Class Camera Look at
	switch(classid)
	{
		case 0 .. 6:
		{
			CCPX = 1542.339843, CCPY = -1676.244384, CCPZ = 30.847208; // this is from your 2nd to 4th arguments in InterpolateCameraPos
			CCLX = 1547.319580, CCLY = -1676.068481, CCLZ = 30.433620; // this is from your 2nd to 4th arguments in InterpolateCameraLookAt
			// your code
		}
		case 7 .. 8:
		{
			CCPX = 1421.688476, CCPY = -1647.271606, CCPZ = 38.576740; // this is from your 5th to 7th arguments in InterpolateCameraPos
			CCLX = 1418.010864, CCLY = -1643.885131, CCLZ = 38.490806; // this is from your 5th to 7th arguments in InterpolateCameraLookAt
			// your code
		}
	}
	SetPlayerCameraPos(playerid, CCPX, CCPY, CCPZ);
	SetPlayerCameraLookAt(playerid, CCLX, CCLY, CCLZ, CAMERA_MOVE);
}
Note: the camera will also try to move when you connect to the server or when player just die... To prevent this, you have to mark as player variable to check if player was in class selection.


If you wanted to use Interpolate (and the way), then you have to store the camera offset and class selection category per player's variable and set them depending on the value you specified on each class, which i have not found the best way to code it, i don't know why GetPlayerCameraPos doesn't return the correct value here.