03.02.2013, 01:51
(
Последний раз редактировалось MP2; 03.04.2013 в 11:20.
)
Old topic: https://sampforum.blast.hk/showthread.php?tid=346633
Description
This include allows you to set and/or interpolate a player's camera with the HUD (health bars, cash, weapons, radar etc.) hidden. The only way to hide the HUD in SA:MP is to put the player in to spectator mode*. The problem is, if you set the player's camera right after putting them in spectator mode like so:
it simply will not work. The player's camera will be overlooking a bridge near Blueberry (default camera when spectating). I call this 'Spectator's Bridge'.
This include fixes this by setting the player's camera the next time OnPlayerUpdate is called. It's nothing special really, it's just a useful thing to have so you don't have to script it yourself. It makes your life easier.
Usage Examples
- Login/register screens
- Tutorial cameras
- 'Waiting to respawn' screen
- 'Loading' screen
- etc.
Usage
There are 2 functions in this include:
SetPlayerCamera - Set the player's camera to a set of coordinates. Can be set to interpolate from player's current camera pos.
Parameters:
playerid - The ID of the player whose camera to set.
Float:x - The X coordinate to set the camera to.
Float:y - The y coordinate to set the camera to.
Float:z - The z coordinate to set the camera to.
Float:lookx - The X coordinate the camera will look toward.
Float:looky - The Y coordinate the camera will look toward.
Float:lookz - The Z coordinate the camera will look toward.
bool:camera_interpolate=false - Whether the camera should 'interpolate' (move smoothly, rather than instant jump) to the coordinates from where the players' camera currently is. Disabled (instant jump) by default. Set to 'true' to enable this. SEE NOTES BELOW ABOUT THIS**.
InterpolatePlayerCamera - Interpolate a player's camera between two points.
startposx/y/z - The starting coordinates.
startlookx/y/z - The starting 'look at' coordinates.
toposx/y/z - The coordinates to finish at.
tolookx/y/z - The 'look at' coordinates to finish at.
interpolation_time=3000 - The time (in MS) it will take the camera to move. Set to 3000 MS (3 seconds) by default.
Changelog
3.0 (3rd of April 2013):
- Re-designed it a bit to fix some issues. Semi-reverted back to version 1.
2.1 (4th of Jan 2013):
- camera_interpolate in SetPlayerCamera now works properly. I had to code another fix using OnPlayerUpdate to reset the old camera first.
2.0 (3rd of Jan 2013):
- Removed 'sets' parameter - not needed after all!
- Added InterpolatePlayerCamera to interpolate straight after setting
- Added an optional parameter to SetPlayerCamera to use 'CAM_MOVE' for SetPlayerCameraPos. This is an 'easier' version of InterpolatePlayerCamera, and it will interpolate from wherever the player's camera currently is!
DOWNLOAD
http://pastebin.com/C1196Tpj
NOTES:
- This isn't the 'tidiest' script ever. The main thing is it works, and (hopefully) pretty well. Please report any bugs and feel free to leave suggestions.
** - Using camera_interpolate in SetCameraPos may not be the best thing to do, as the blueberry bridge will flash on screen, and players/vehicles near-by will stream out for a few seconds. It may be best to use SPECIAL_ACTION_DANCE (which this include doesn't support (yet)) if your actual player isn't on the screen. ClearAnimations and TogglePlayerControllable may even fix this.
* It can also be done with SetPlayerDrunkLevel, SelectTextdraw and SPECIAL_ACTION_DANCE, but all 3 have unwanted effects.
Description
This include allows you to set and/or interpolate a player's camera with the HUD (health bars, cash, weapons, radar etc.) hidden. The only way to hide the HUD in SA:MP is to put the player in to spectator mode*. The problem is, if you set the player's camera right after putting them in spectator mode like so:
pawn Код:
TogglePlayerSpectating(playerid, true);
SetPlayerCameraPos(...);
SetPlayerCameraLookAt(...);
This include fixes this by setting the player's camera the next time OnPlayerUpdate is called. It's nothing special really, it's just a useful thing to have so you don't have to script it yourself. It makes your life easier.
Usage Examples
- Login/register screens
- Tutorial cameras
- 'Waiting to respawn' screen
- 'Loading' screen
- etc.
Usage
There are 2 functions in this include:
pawn Код:
SetPlayerCamera(playerid, Float:x, Float:y, Float:z, Float:lookx, Float:looky, Float:lookz, bool:camera_interpolate=false)
InterpolatePlayerCamera(playerid, Float:startposx, Float:startposy, Float:startposz, Float:startlookx, Float:startlooky, Float:startlookz, Float:toposx, Float:toposy, Float:toposz, Float:tolookx, Float:tolooky, Float:tolookz, interpolation_time=3000)
Parameters:
playerid - The ID of the player whose camera to set.
Float:x - The X coordinate to set the camera to.
Float:y - The y coordinate to set the camera to.
Float:z - The z coordinate to set the camera to.
Float:lookx - The X coordinate the camera will look toward.
Float:looky - The Y coordinate the camera will look toward.
Float:lookz - The Z coordinate the camera will look toward.
bool:camera_interpolate=false - Whether the camera should 'interpolate' (move smoothly, rather than instant jump) to the coordinates from where the players' camera currently is. Disabled (instant jump) by default. Set to 'true' to enable this. SEE NOTES BELOW ABOUT THIS**.
InterpolatePlayerCamera - Interpolate a player's camera between two points.
startposx/y/z - The starting coordinates.
startlookx/y/z - The starting 'look at' coordinates.
toposx/y/z - The coordinates to finish at.
tolookx/y/z - The 'look at' coordinates to finish at.
interpolation_time=3000 - The time (in MS) it will take the camera to move. Set to 3000 MS (3 seconds) by default.
Changelog
3.0 (3rd of April 2013):
- Re-designed it a bit to fix some issues. Semi-reverted back to version 1.
2.1 (4th of Jan 2013):
- camera_interpolate in SetPlayerCamera now works properly. I had to code another fix using OnPlayerUpdate to reset the old camera first.
2.0 (3rd of Jan 2013):
- Removed 'sets' parameter - not needed after all!
- Added InterpolatePlayerCamera to interpolate straight after setting
- Added an optional parameter to SetPlayerCamera to use 'CAM_MOVE' for SetPlayerCameraPos. This is an 'easier' version of InterpolatePlayerCamera, and it will interpolate from wherever the player's camera currently is!
DOWNLOAD
http://pastebin.com/C1196Tpj
NOTES:
- This isn't the 'tidiest' script ever. The main thing is it works, and (hopefully) pretty well. Please report any bugs and feel free to leave suggestions.
** - Using camera_interpolate in SetCameraPos may not be the best thing to do, as the blueberry bridge will flash on screen, and players/vehicles near-by will stream out for a few seconds. It may be best to use SPECIAL_ACTION_DANCE (which this include doesn't support (yet)) if your actual player isn't on the screen. ClearAnimations and TogglePlayerControllable may even fix this.
* It can also be done with SetPlayerDrunkLevel, SelectTextdraw and SPECIAL_ACTION_DANCE, but all 3 have unwanted effects.