10.10.2012, 11:52
(
Last edited by Norhy; 10/10/2012 at 03:43 PM.
)
Introduction
Hello. You may ask yourself, what does he mean by 'Cameras'. Well, i'm new to this Community so i decided to make a Tutorial. This tutorial is about adding Camera views to your Script. What do i mean? Well, lets say you're at a Airport, somewhere in a Tower, you type /camera in the Tower and you'll see your Camera will be at the Airport's Entrance. Lets go.
Step 1
Alright, first we'll need to chceck if the player's already in the 'Camera view'. We'll do it like this:
Code:
new IsPlayerChecking[MAX_PLAYERS];
Step 2: The Command
Good. Now we need to make a command, we'll do this at the public OnPlayerCommandText. I use the classic strcmp but you can use DCMD or ZCMD, your choice.
Code:
if (strcmp("/camera", cmdtext, true, 6) == 0)
Now we'll check if the player is in the Spectating state.
Code:
if(IsPlayerChecking[playerid] == 0) { }
Now we should make the player non-controllable. Why? Because when he'll be in the Spec. state he'll be still able to move, but he wouldn't see where he moves.
Code:
if(IsPlayerChecking[playerid] == 0) { ToggePlayerControllable(playerid, false); }
So, we've got a command that checks if the player's spectating or not. Now we'll add the Camera coordinates. We need the position of the Camera Postiton, and the coodrs of the point where the Camera will look at. In my case it'll be from one of the A69 tower's and it'll be looking at the Gate.
Code:
if(IsPlayerChecking[playerid] == 0) { ToggePlayerControllable(playerid, false); SetPlayerCameraPos(playerid, 102.09620, 1903.80322, 34.71486); // Set the Camera's position. SetPlayerCameraLookAt(playerid, 97.01453, 1920.62439, 18.15041); // Where should it look at. IsPlayerChecking[playerid] = 1; // Checks if the player's is in Spec. state. 1 - True, 0 - False. }
Alright. Now we have everything we need. One last thing is missing. After some time the player's bored of the spectating and want to play again, so we need to switch him back to Character and make him Controllable.
Code:
else { SetCameraBehindPlayer(playerid); TogglePlayerControllable(playerid, true); IsPlayerChecking[playerid] = 0; }
Here's the Full Command:
Code:
public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/camera", cmdtext, true, 6) == 0) { if(IsPlayerChecking[playerid] == 0) { TogglePlayerControllable(playerid, false); SetPlayerCameraPos(playerid, 102.09620, 1903.80322, 34.71486); // You can change to your own coords. SetPlayerCameraLookAt(playerid, 97.01453, 1920.62439, 18.15041); // Same as above. IsPlayerChecking[playerid] = 1; } else { SetCameraBehindPlayer(playerid); TogglePlayerControllable(playerid, true); IsPlayerChecking[playerid] = 0; } return 1; } return 0; }
I hope i teached someone how to make Camera views, you must not use a Command to trigger it, you can also use OnPlayerKeyStateChange, be crative. I recommend this mainly for RP server for RPing and so on.
I'm new to this Forum, Community and i'll try to make my best here. If something's wrong, reply to this Topic and i'll try to help you