AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Limiting spectator modes (https://forums.alliedmods.net/showthread.php?t=64633)

karar 12-19-2007 20:09

Limiting spectator modes
 
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?

YamiKaitou 12-19-2007 20:34

Re: Limiting spectator modes
 
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;



karar 12-19-2007 21:00

Re: Limiting spectator modes
 
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

YamiKaitou 12-19-2007 21:18

Re: Limiting spectator modes
 
There, that should do what you want for now

Drak 12-19-2007 22:23

Re: Limiting spectator modes
 
Quote:

Originally Posted by YamiKaitou (Post 565082)
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 }

karar 12-21-2007 21:02

Re: Limiting spectator modes
 
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 12-21-2007 21:42

Re: Limiting spectator modes
 
Quote:

Originally Posted by Drak (Post 565110)
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

Drak 12-21-2007 23:23

Re: Limiting spectator modes
 
Quote:

Originally Posted by karar (Post 565719)
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); }

karar 12-22-2007 07:44

Re: Limiting spectator modes
 
still no luck ... can u plz check it on your end and then tell me the code that works?

karar 12-22-2007 08:44

Re: Limiting spectator modes
 
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;




All times are GMT -4. The time now is 11:06.

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