PDA

View Full Version : Obscura Cam (New 3rd Person) [v0.7]


SkumTomteN
03-11-2016, 16:05
Hello, i decide that i will publish this 3rd person camera plugin.
This camera has alot more features than the current cameras available.

Change Log
Version 0.7:
*Made some of the code more efficent (Thanks to jhob94).
Version 0.6:
*Improved the way the camera is removed.
*Fixed a bug when the player disconnected. it would say "invalid player".
Version 0.5:
*Fixed a bug in removing the camera.
Version 0.4:
*Reworked the code with various fixes.
*Now using engines think + other things.
*You can now set your cam when you arent alive and your camera will be set on spawn.
*Colored prints added.
*Removed global variable to handle entity, now using a different method.
*Your camera choice wont remove on spawn or kill. it will always be saved until next map.
Version 0.3:
*Removed supported mods, use natives with subplugins to support your own mode.
Version 0.2:
*Added new cvar (cam_forced).
*Removed some code/added some code, just some small fixes.

Commands

say /cam
sayteam /cam


Natives

set_user_camera(id, ThirdPerson) *1/0
get_user_camera(id) *Returns 1 if true, else 0


Cvars

cam_distance *Default: 150.0, Changes the distance of the camera.
cam_forced *Default: 0, forces the server to use 3rd person mode, cmd wont work, sets the cam at spawn.


Modules

Fakemeta
Engine
Hamsandwich


Pros

Toggle camera mode (Turn on/off with cmd /cam).
Super fast camera, like normal view.
Server manager can change distance of the camera with cvar.
Server manager can force 3rd person mode with cvar.
Natives to set/get camera mode.
Automatically sets the camera distance to player when close to wall. depending on camera_distance cvar.


Cons

The camera will lag depending on your ping in-game. (The entity will move slower).


Credits

Valve for "thirdperson" camera mode idea.
ConnorMcLeod for code to set new camera origin when close to wall.
Di57inct aka georgik57. (Ideas, Help)
Jhob94 (Code Improvement Suggestions)


Video
V0bwY1WV_x0
tChD_JkdLe4

EFFx
03-11-2016, 20:31
What is the difference of others versions?

Only include ??

SkumTomteN
03-12-2016, 04:21
What is the difference of others versions?

Only include ??

If you want to see in detail what is different, i suggest you compare it yourself.

EFFx
03-12-2016, 12:15
The code is different, but the model havent difference.

SkumTomteN
03-12-2016, 13:24
The code is different, but the model havent difference.

Yeah, btw, you should wait for the 0.4 version, it has many bug fixes.

Edit: 0.4 is now released.

EFFx
03-12-2016, 14:19
I liked the native :D:D

But the CustomCamera i know make, is easy.

Of course, nice. Approved.

SkumTomteN
03-12-2016, 15:32
I liked the native :D:D

But the CustomCamera i know make, is easy.

Of course, nice. Approved.

0.5 released, fixed a bug where you couldnt go back to original cam. :)

EFFx
03-12-2016, 15:39
Amazing.

Arkshine, can you approve? haha :D

SkumTomteN
03-12-2016, 16:37
Amazing.

Arkshine, can you approve? haha :D

He probably wont approve this, and i dont really care if he does.

EFFx
03-12-2016, 16:49
Just wait :)

SkumTomteN
03-18-2016, 14:15
0.6 Released.

Version 0.6:
*Improved the way the camera is removed.
*Fixed a bug when the player disconnected. it would say "invalid player".

Jhob94
03-19-2016, 14:10
Well i have some advices, they are not really necessary, but it makes the code looks more nice.

You have some cases like this
if(is_user_alive(iVictim))
return HAM_IGNORED;
if(!is_user_connected(iVictim))
return HAM_IGNORED;
:arrow:
if(!is_user_connected(iVictim) || is_user_alive(iVictim))
return HAM_IGNORED;
or
if(is_user_connected(iVictim) && !is_user_alive(iVictim))
{
//Your code
}


Also, you could change this
public CMD_ToggleCam(iPlayer)
{
if(get_pcvar_num(g_pCvar_iCameraForced))
{
client_printc(iPlayer, "!g[%s]!n Camera is forced on !t3rd person!n by server manager!", PLUGIN_TAG)
return;
}
if(is_user_alive(iPlayer))
{
if(!g_bInThirdPerson[iPlayer])
{
Set_CameraEnt(iPlayer)

g_bInThirdPerson[iPlayer] = true;

client_print(0, print_center, "3rd Person Mode")
}
else
{
Remove_CameraEnt(iPlayer, 1)

g_bInThirdPerson[iPlayer] = false;

client_print(0, print_center, "1st Person Mode")
}
}
else /* He toggles when not alive */
{
if(!g_bInThirdPerson[iPlayer])
{
g_bInThirdPerson[iPlayer] = true;
}
else g_bInThirdPerson[iPlayer] = false;

client_printc(iPlayer, "!g[%s]!n Your camera will be !t%s!n when you spawn!", PLUGIN_TAG, g_bInThirdPerson[iPlayer] ? "3rd Person" : "1st Person")
}
}
:arrow:
public CMD_ToggleCam(iPlayer)
{
if(get_pcvar_num(g_pCvar_iCameraForced))
{
client_printc(iPlayer, "!g[%s]!n Camera is forced on !t3rd person!n by server manager!", PLUGIN_TAG)
return;
}

g_bInThirdPerson[iPlayer] = ~g_bInThirdPerson[iPlayer]

if(is_user_alive(iPlayer))
{
if(g_bInThirdPerson[iPlayer])
{
Set_CameraEnt(iPlayer)

client_print(0, print_center, "3rd Person Mode")
}
else
{
Remove_CameraEnt(iPlayer, 1)

client_print(0, print_center, "1st Person Mode")
}
}
else /* He toggles when not alive */
{
client_printc(iPlayer, "!g[%s]!n Your camera will be !t%s!n when you spawn!", PLUGIN_TAG, g_bInThirdPerson[iPlayer] ? "3rd Person" : "1st Person")
}
}


And last:
public fw_PlayerSpawn_Post(iPlayer)
{
if(!is_user_alive(iPlayer))
return HAM_IGNORED;
if(!is_user_connected(iPlayer))
return HAM_IGNORED;

if(get_pcvar_num(g_pCvar_iCameraForced))
{
Set_CameraEnt(iPlayer)
}
else
{
if(g_bInThirdPerson[iPlayer])
Set_CameraEnt(iPlayer)
else
Remove_CameraEnt(iPlayer, 1)
}
return HAM_HANDLED;
}
:arrow:
public fw_PlayerSpawn_Post(iPlayer)
{
if(is_user_alive(iPlayer))
{
if(get_pcvar_num(g_pCvar_iCameraForced) || g_bInThirdPerson[iPlayer])
{
Set_CameraEnt(iPlayer)
}
else
{
Remove_CameraEnt(iPlayer, 1)
}
}
}

They are not really necessary, but it's always good to improve it.

SkumTomteN
03-19-2016, 17:47
Its been implemented in the code now, you were always so good in coding style:D, im jealous.
But i prefer to use "return" when im not using an if > else, just a preference.

Thank you for the suggestions and improvement. ill add you to credits:)

GuskiS
03-22-2016, 16:06
...
if(get_pcvar_num(g_pCvar_iCameraForced) || g_bInThirdPerson[iPlayer])
...

:arrow:

if(g_bInThirdPerson[iPlayer] || get_pcvar_num(g_pCvar_iCameraForced))

Jhob94
03-22-2016, 16:11
:arrow:

if(g_bInThirdPerson[iPlayer] || get_pcvar_num(g_pCvar_iCameraForced))


Doesn't matter. If cvar is enabled, would be better the other case. It's 50/50, so i am not sure why you posted that.

GuskiS
03-23-2016, 02:39
It does matter. I posted that because it is wiser to check on array than on native first because if array will return true, it won't check the other expression to be true. This can be really usefull in functions/events that are being called very often :)

Jhob94
03-23-2016, 13:33
This can be really usefull in functions/events that are being called very often :)

Yes, i know. But here isn't really the case.

Visinescu
03-25-2016, 14:24
I don't see this plugin to be approved... make more camera views like the shoulder view, and fix that wallhack plis.

SkumTomteN
03-25-2016, 22:18
More camera angles!: The purpose of the plugin is a simple cam. but as always, if anyone wants to make more angles, post your code here.
Fix wallhack: I don't have time to fix that issue, it would take a very long time and testing. but if anyone wants to support this plugin by giving a suggestion code for this, feel free :)

Craxor
09-18-2016, 15:26
If you want to see in detail what is different, i suggest you compare it yourself.


Wrong, if it's your plugin you have the responsability to say the differences between the others similar versions, anyway it's kind of useless. Same can be achieved very easy with engine.

SkumTomteN
09-24-2016, 03:47
Wrong, if it's your plugin you have the responsability to say the differences between the others similar versions, anyway it's kind of useless. Same can be achieved very easy with engine.

What about you read the plugin description, it has some features that none of other camera plugin has, even though the viewangles are limited.

set_view is extremely slow and its even slow when playing singleplayer and i get headache when i use it (though its more smoother). This is faster, even though it depends alot on clients ping, i see alot of my own clients prefer this cam and say its fine:)

This plugin is also old. and will not get more support i think, i use it all the time in my testing, i never found a bug with it, alot can be optimized though, can be made alot faster/efficent/smoother.

Thanks for ur comment

Craxor
09-24-2016, 08:13
What about you read the plugin description, it has some features that none of other camera plugin has, even though the viewangles are limited.

set_view is extremely slow and its even slow when playing singleplayer and i get headache when i use it (though its more smoother). This is faster, even though it depends alot on clients ping, i see alot of my own clients prefer this cam and say its fine:)

This plugin is also old. and will not get more support i think, i use it all the time in my testing, i never found a bug with it, alot can be optimized though, can be made alot faster/efficent/smoother.

Thanks for ur comment


Your description are :

Hello, i decide that i will publish this 3rd person camera plugin.
This camera has alot more features than the current cameras available.

Anyway i'm not approver and i don't fully understand your code so i'm not able to judge you, if you want some advices here you after a quick check:


Insteand of using #defines, replace them all with constants, these:

/* The info of this plugin */
#define PLUGIN_VERSION "0.7"
#define PLUGIN_TAG "CAM"

/* Just dont touch it */
#define CAMERA_CLASSNAME "trigger_camera"
#define CAMERA_MODEL "models/rpgrocket.mdl"

this one:
#define CAMERA_OWNER EV_INT_iuser1

Delete and put directly ENV_INT_iuser1, even if is for readability is realy useles.


For sake of noobs owners, don't let the cvar to be a float, use it as normal number:
register_cvar("cam_distance", "150.0")
->
register_cvar("cam_distance", "150")

by changin these, with these(just my op):


fCameraOrigin[0] = fPlayerOrigin[0] + (-vBack[0] * get_pcvar_float(g_pCvar_fCameraDistance))
fCameraOrigin[1] = fPlayerOrigin[1] + (-vBack[1] * get_pcvar_float(g_pCvar_fCameraDistance))
fCameraOrigin[2] = fPlayerOrigin[2] + (-vBack[2] * get_pcvar_float(g_pCvar_fCameraDistance))

With ->


fCameraOrigin[0] = fPlayerOrigin[0] + (-vBack[0] * float(get_pcvar_num(g_pCvar_fCameraDistance)) )
fCameraOrigin[1] = fPlayerOrigin[1] + (-vBack[1] * float(get_pcvar_num(g_pCvar_fCameraDistance)) )
fCameraOrigin[2] = fPlayerOrigin[2] + (-vBack[2] * float(get_pcvar_num(g_pCvar_fCameraDistance)) )



This one:
register_clcmd("sayteam /cam", "CMD_ToggleCam")

should not be?

register_clcmd("say_team /cam", "CMD_ToggleCam")

And here:

if(!is_valid_ent(iEnt))
continue;

What the fuck?

here:
new bool:g_bInThirdPerson[33] = false;

When you declare a boolean variable, the default value is already 'false' so you don't need to re-set it.

HamletEagle
09-24-2016, 14:17
What the fuck?

If you don't understand something it doesn't mean that the thing is wrong.


Delete and put directly ENV_INT_iuser1, even if is for readability is realy useles.

Doesn't matter, it's up to the coder.


For sake of noobs owners, don't let the cvar to be a float, use it as normal number:

There's nothing wrong with it being a float.


When you declare a boolean variable, the default value is already 'false' so you don't need to re-set it

Both ways are fine.

You should really focus on learning and understanding how things really work before reviewing.

klippy
09-24-2016, 14:46
Both ways are fine.


While that holds true, I don't think what he did here was correct. If he wanted all values to be true by default, like so:

new bool:g_bInThirdPerson[33] = true;

Only the first cell would become true. This is the proper way of doing it:

new bool:g_bInThirdPerson[33] = {true, ...};


I know it won't make a difference in this case, but I think it's worth mentioning.

HamletEagle
09-25-2016, 05:38
I've answered only on what I've quoted(i.e the generic sentence, not OP implementation). But yeah, what you said is correct.

Depresie
11-27-2016, 18:22
Seems nice, but you should adjust the distance a little bit when the player is near walls.. if you succeed fixing the "bug" where the camera gets inside a wall, you get a 10 from me =P

SkumTomteN
02-22-2017, 14:34
This plugin is old and outdated, wont support it anymore, and i know there is tons of faults with it. dont bother reviewing it.