Raised This Month: $32 Target: $400
 8% 

Solved Camera


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blAck.
Member
Join Date: Jun 2018
Old 07-14-2018 , 10:17   Camera
Reply With Quote #1

Hey, I just started coding and I need help with small cs 1.6 plugin that I'm trying to make.
I know there is already one plugin that does this for you but I wanted to make my own with some difference.

It's about camera plugin. I'm trying to make when a player types /cam, he goes into 3rd camera mode, and if he is already in 3rd camera mode, he goes into first mode.
But with this code, I can only go in 3rd person, and I cannot come back in 1st person. Why? I think this code should be fine.

Code:
public setview(id)
{
	if(set_view(id, CAMERA_NONE)) {
		
		set_view(id, CAMERA_3RDPERSON)
		
	} else if(set_view(id, CAMERA_3RDPERSON)) {
		
		set_view(id, CAMERA_NONE)
		
		return PLUGIN_HANDLED
	} else {
	return PLUGIN_HANDLED
	}
	return PLUGIN_HANDLED
}

Last edited by blAck.; 08-05-2018 at 14:02.
blAck. is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-14-2018 , 10:19   Re: Camera
Reply With Quote #2

set_view only sets player view and returning nothing so you shouldnt use it in if statement, you can use bool[33]
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 07-14-2018 , 10:22   Re: Camera
Reply With Quote #3

Code:
new bool:PlayerInThirdPerson[33];

Code:
public setview(id)
{
	if(!PlayerInThirdPerson[id]) {
		
		set_view(id, CAMERA_3RDPERSON)
		PlayerInThirdPerson[id] = true;
	} else
		
		set_view(id, CAMERA_NONE)
		PlayerInThirdPerson[id] = false;
	}

	return PLUGIN_HANDLED
}
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 07-14-2018 , 10:27   Re: Camera
Reply With Quote #4

This is how I did it in my plugin:
PHP Code:
enum
{
    
VIEW_NONE 0,
    
VIEW_3RDPERSON,
}

new 
g_iPlayerView33 ];

public 
plugin_init( )
{
    
RegisterHamHam_Player_ImpulseCommands"player""@HamPlayerImpulseCommands_Pre");
    
RegisterHamHam_Spawn"player""@HamSpawn_Post");
}

public 
client_connectid )
{
    
g_iPlayerViewid ] = VIEW_NONE;
}


public @
HamSpawn_Postid )
{
    if( 
is_user_aliveid ) )
    {
        
g_iPlayerViewid ] = VIEW_NONE;
    }
    return 
HAM_IGNORED;
}

public @
HamPlayerImpulseCommands_Preid )
{
    if( ! 
is_user_aliveid ) )
    return 
HAM_IGNORED;
    
    if( 
pevidpev_impulse ) == 201 )
    {
        
g_iPlayerViewid ] = g_iPlayerViewid ] == VIEW_3RDPERSON VIEW_NONE VIEW_3RDPERSON;
        
set_viewidg_iPlayerViewid ] );
        
        
set_pevidpev_impulse);
    }
    return 
HAM_IGNORED;

__________________

Last edited by edon1337; 07-14-2018 at 10:28.
edon1337 is offline
blAck.
Member
Join Date: Jun 2018
Old 07-14-2018 , 10:31   Re: Camera
Reply With Quote #5

Quote:
Originally Posted by Ghosted View Post
Code:
new bool:PlayerInThirdPerson[33];

Code:
public setview(id)
{
	if(!PlayerInThirdPerson[id]) {
		
		set_view(id, CAMERA_3RDPERSON)
		PlayerInThirdPerson[id] = true;
	} else
		
		set_view(id, CAMERA_NONE)
		PlayerInThirdPerson[id] = false;
	}

	return PLUGIN_HANDLED
}
It won't work.
blAck. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-14-2018 , 10:32   Re: Camera
Reply With Quote #6

Show the full code.
__________________








CrazY. is offline
blAck.
Member
Join Date: Jun 2018
Old 07-14-2018 , 10:36   Re: Camera
Reply With Quote #7

Quote:
Originally Posted by CrazY. View Post
Show the full code.
Code:
#include <amxmodx>
#include <engine>
#include <amxmisc>

new bool:PlayerInThirdPerson[33];

public plugin_init()
{
    register_plugin("Camera", "1.0", "blAck")

    register_clcmd("say /cam", "setview")
}

public plugin_modules()
{
    require_module("engine")
}

public plugin_precache()
{
    precache_model("models/rpgrocket.mdl")
}

public setview(id)
{	
	
	if(!PlayerInThirdPerson[id]) {
		
		set_view(id, CAMERA_3RDPERSON)
		PlayerInThirdPerson[id] = true;
	} else
		
		set_view(id, CAMERA_NONE)
		PlayerInThirdPerson[id] = false;
}
blAck. is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 07-14-2018 , 10:45   Re: Camera
Reply With Quote #8

Here it's working.

Code:
#include <amxmodx> #include <engine> new bool:PlayerInThirdPerson[33]; public plugin_init() {     register_plugin("Camera", "1.0", "blAck")     register_clcmd("say /cam", "setview") } public plugin_precache() {     precache_model("models/rpgrocket.mdl") } public setview(id) {        if (!PlayerInThirdPerson[id])     {         PlayerInThirdPerson[id] = true;         set_view(id, CAMERA_3RDPERSON);     }     else     {         PlayerInThirdPerson[id] = false;         set_view(id, CAMERA_NONE);     }     return PLUGIN_HANDLED; }

Spoiler
__________________








CrazY. is offline
blAck.
Member
Join Date: Jun 2018
Old 07-14-2018 , 10:49   Re: Camera
Reply With Quote #9

Quote:
Originally Posted by CrazY. View Post
Here it's working.

Code:
#include <amxmodx> #include <engine> new bool:PlayerInThirdPerson[33]; public plugin_init() {     register_plugin("Camera", "1.0", "blAck")     register_clcmd("say /cam", "setview") } public plugin_precache() {     precache_model("models/rpgrocket.mdl") } public setview(id) {        if (!PlayerInThirdPerson[id])     {         PlayerInThirdPerson[id] = true;         set_view(id, CAMERA_3RDPERSON);     }     else     {         PlayerInThirdPerson[id] = false;         set_view(id, CAMERA_NONE);     }     return PLUGIN_HANDLED; }

Spoiler
Thanks <3
blAck. is offline
Apb hq
Senior Member
Join Date: Apr 2014
Old 07-14-2018 , 15:33   Re: Camera
Reply With Quote #10

Quote:
Originally Posted by blAck. View Post
Thanks <3
Guys i am unable to test it now unfortunately , i wanted to know if this version of plugin has the transparency bug fixed
Thanks in advance

Last edited by Apb hq; 07-14-2018 at 15:33.
Apb hq is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:22.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode