[Include] SetPlayerCamera (without the HUD) v2 -Now supports interpolation + CAMERA_MOVE
#1

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:

pawn Код:
TogglePlayerSpectating(playerid, true);
SetPlayerCameraPos(...);
SetPlayerCameraLookAt(...);
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:

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)
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.
Reply
#2

That's a nice hack. Well done!
Reply
#3

Good fix. Thanks MP2
Reply
#4

Another way to do this, if you need your PED on screen, would be setting them in SelectTextDraw mode.
Reply
#5

Quote:
Originally Posted by wups
Посмотреть сообщение
Another way to do this, if you need your PED on screen, would be setting them in SelectTextDraw mode.
But then they have the cursor.

ANOTHER way, is to put them in certain special actions (the dancing ones specifically). But then they're dancing. Perhaps ClearAnimations would fix that. Not sure. Drunk mode > 5000 also works (well, I know it hides the radar, but not sure about the rest of the HUD in the top-right corner).
Reply
#6

Version 2.1 released - fixes camera_interpolate in SetPlayerCamera (wasn't working correctly - the player's camera would interpolate from blueberry acres (default spectate screen) instead of where it already was, had to code a second fix with OnPlayerUpdate to reset the player's camera back first using GetPlayerCameraPos).
Reply
#7

Have you a video of this?
Reply
#8

No. There's no need.
Reply
#9

New version of this is released now (v3.0). I had to re-design the main concept of it because of some issues I was having with 'Spectator's Bridge'. Semi-reverted to version 1 again.

Let me know if you have this problem with the new version.
Reply
#10

Good job man..

Thanks
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)