Raised This Month: $ Target: $400
 0% 

Limiting spectator modes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
karar
Junior Member
Join Date: Dec 2007
Old 12-19-2007 , 20:09   Limiting spectator modes
Reply With Quote #1

I want to limite spectator mode on my server to:

- Firsts person + Team View only
- Locked Chase cam + Team only

and restrict rest of views.. i tried to make my own plugin for this.. using this:

Code:
#include <amxmod>

public plugin_init() {
//register_clcmd("spec_mode 1", "cmdBlock") //Locked Chase cam

//Free Chase cam
register_clcmd("spec_mode 2", "cmdBlock")

//Free Look
register_clcmd("spec_mode 3", "cmdBlock")

//register_clcmd("spec_mode 4", "cmdBlock") //First Person

//Free overview
register_clcmd("spec_mode 5", "cmdBlock")

//Chase overview
register_clcmd("spec_mode 6", "cmdBlock")
}
public cmdBlock(id)
{
return PLUGIN_HANDLED;
}
but this doesnt work... if i set commands like say etc.. they are very well blocked using this code, but using spec_mode is not blocked. i can still give this command on console to change mode or even use spectator menu or spacebar to change views.

any help plz?
karar is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-19-2007 , 20:34   Re: Limiting spectator modes
Reply With Quote #2

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_clcmd("spec_mode""cmdBlock");
}

public 
cmdBlock(id)
{
    new 
mode read_argv(1);
    if (
mode == || mode == 4)
        return 
PLUGIN_CONTINUE;
    return 
PLUGIN_HANDLED;

__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).

Last edited by YamiKaitou; 12-19-2007 at 21:17. Reason: updated
YamiKaitou is offline
karar
Junior Member
Join Date: Dec 2007
Old 12-19-2007 , 21:00   Re: Limiting spectator modes
Reply With Quote #3

But I DONT want to block SPEC_MODE 1 and 4, that is why I have commented those lines...

later on I will enable those options by CVARs... but right now i want to hardcode block all spec_modes EXCEPT 1 and 4
karar is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 12-19-2007 , 21:18   Re: Limiting spectator modes
Reply With Quote #4

There, that should do what you want for now
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 12-19-2007 , 22:23   Re: Limiting spectator modes
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_clcmd("spec_mode""cmdBlock");
}

public 
cmdBlock(id)
{
    new 
mode read_argv(1);
    if (
mode == || mode == 4)
        return 
PLUGIN_CONTINUE;
    return 
PLUGIN_HANDLED;

That would give off a compile error.
Code:
#include <amxmodx> public plugin_init() {     register_clcmd("spec_mode", "cmdBlock"); } public cmdBlock(id) {     new arg[32]     read_argv(0,arg,31);         new mode = str_to_num(arg)     if(mode != 1 || mode != 4)         return PLUGIN_HANDLED_MAIN }
And if that doesn't work, this might.
Code:
#include <amxmodx> public plugin_init() {     register_clcmd("spec_mode", "cmdBlock"); } public client_command(id) {     new arg[32],iNum[32]     read_argv(0,arg,31);         if(equal(arg,"spec_mode"))     {         read_argv(1,iNum,31)         new mode = str_to_num(iNum)         if(mode != 1 || mode != 4)             return PLUGIN_HANDLED_MAIN     }     return PLUGIN_CONTINUE }
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
karar
Junior Member
Join Date: Dec 2007
Old 12-21-2007 , 21:02   Re: Limiting spectator modes
Reply With Quote #6

although it compiles but none of this works...

the spec_mode command isnt able to be blocked!!!! i can still give it on console and get whtever view i want
karar is offline
karar
Junior Member
Join Date: Dec 2007
Old 12-21-2007 , 21:42   Re: Limiting spectator modes
Reply With Quote #7

Quote:
Originally Posted by Drak View Post
That would give off a compile error.
Code:
#include <amxmodx> public plugin_init()
{
register_clcmd("spec_mode", "cmdBlock");
}

public cmdBlock(id) {
new arg[32]
read_argv(0,arg,31)
new mode = str_to_num(arg)
if(mode != 1 || mode != 4)
return PLUGIN_HANDLED_MAIN
}

I think read argv command should be:
PHP Code:
read_argv(1,arg,31); 
btw i put some client_print commands to debug e.g. i added (before if command):
PHP Code:
client_print(0,print_console,"Spec mode switched to = <%s>"mode
and this command never showed up on console... then for testing i changed the register clccommand to:
PHP Code:
register_clcmd("say""cmdBlock"); 
and now console was printing the debug line fine.. so say command is being captured fine but spec_mode command is not. Hope this helps you guys figring out a solution
karar is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 12-21-2007 , 23:23   Re: Limiting spectator modes
Reply With Quote #8

Quote:
Originally Posted by karar View Post
I think read argv command should be:
PHP Code:
read_argv(1,arg,31); 
btw i put some client_print commands to debug e.g. i added (before if command):
PHP Code:
client_print(0,print_console,"Spec mode switched to = <%s>"mode
and this command never showed up on console... then for testing i changed the register clccommand to:
PHP Code:
register_clcmd("say""cmdBlock"); 
and now console was printing the debug line fine.. so say command is being captured fine but spec_mode command is not. Hope this helps you guys figring out a solution
I used zero on "read_argv" because zero means the command, according to the docs. As for "spec_mode" not registering. I think it's because it's a client-side command. If it's a CVar you can query a client-side cvar like so:
Code:
public GetSpecMode(id) {     new Value = query_client_cvar(id,"spec_mode","cvar_spec_mode"); } public cvar_spec_mode(id,const cvar[],const value[]) {     return str_to_num(value); }
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
karar
Junior Member
Join Date: Dec 2007
Old 12-22-2007 , 07:44   Re: Limiting spectator modes
Reply With Quote #9

still no luck ... can u plz check it on your end and then tell me the code that works?
karar is offline
karar
Junior Member
Join Date: Dec 2007
Old 12-22-2007 , 08:44   Re: Limiting spectator modes
Reply With Quote #10

ok guys I finally got it... thx for continuous replies.. which kept me sticking to the project, or else i would have dumped the idea!

and one thing i want to mention that i picked this idea from statsx plugin.. cuz it had a check thingy for currect spectator mode of player.. and i just picked it and modified it for my use. The following code is working fine.. so i am posting it incase anyone needs it or better enhancement or use in some similar project:

PHP Code:
#include <amxmodx>

public plugin_init()
{
    
register_plugin("spec_limit""1""PM");
    
register_event("TextMsg""eventSpecMode""bd""2&ec_Mod")
}

public 
eventSpecMode(id)
{
    new 
sData[12]
    
read_data(2sData11)
    new 
mode str_to_num(sData[10])
    
    
//Locked chase cam
    
if (mode==1)
    {
        return 
PLUGIN_CONTINUE;
    }
    
    
//First person cam
    
if (mode==4)
    {
        return 
PLUGIN_CONTINUE;
    }
    
    
//Other camera views
    
client_cmd(id"spec_mode 1");
    
client_print(id,print_console,"SERVER: spec_mode <%i> blocked."mode);
    return 
PLUGIN_HANDLED_MAIN;

karar is offline
Reply



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 11:06.


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