Raised This Month: $ Target: $400
 0% 

Preventing Spectators for certain players *solved*


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MALON
Member
Join Date: Jan 2008
Old 07-21-2008 , 16:37   Preventing Spectators for certain players *solved*
Reply With Quote #1

I know it's possible because I've seen it done, I just don't know how it was done. Players could say /nospec and it would prevent them from having spectators. They could say it again and then spectators would be allowed.

Yes, I really did search the forums and I didn't see anything, but this seems like something that should be fairly easy.

Thanks!

Last edited by MALON; 07-28-2008 at 02:37.
MALON is offline
Old 07-21-2008, 17:14
Alka
This message has been deleted by Alka.
MALON
Member
Join Date: Jan 2008
Old 07-21-2008 , 20:28   Re: Preventing Spectators for certain players
Reply With Quote #2

Well, it was a nice attempt, but all it seems to do is tell the player "You're not allowed to spectate this player!" Maybe it's functioning correctly, but I guess what I had meant is that I'd like for the plugin to skip a player with /nospec active, as if he's not even in the server.

I appreciate the attempt though. Thanks
MALON is offline
Old 07-22-2008, 04:09
Alka
This message has been deleted by Alka.
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 07-22-2008 , 04:37   Re: Preventing Spectators for certain players
Reply With Quote #3

Quote:
Originally Posted by Alka View Post
1.You have tried it with 2 players? beacause if the player spectated is the last alive from his team won't be skipped.
2.

What ?!
3.Try this new version...
Have you tried just setting pev_iuser2 to the player you want the user to spectate now?
danielkza is offline
Old 07-22-2008, 07:37
Alka
This message has been deleted by Alka.
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-22-2008 , 07:55   Re: Preventing Spectators for certain players
Reply With Quote #4

From mistake i deleted the last post o.0, anyway try this version.Make shure that number of players from same team with spectated player is > 1.

EDIT:
-Little update, and i've tested it, works fine.
-The plugin switches to another player from same team with spectated player...so if spectated player is CT then will pick a random player from CT and switch to him.

Maybe i will make this more complex:
*Menu.
*Switch to a random player from all players or specfied team.
*Can restrict spec only for some players, not for all.
Attached Files
File Type: sma Get Plugin or Get Source (nospec.sma - 797 views - 2.4 KB)
__________________
Still...lovin' . Connor noob! Hello

Last edited by Alka; 07-22-2008 at 09:36.
Alka is offline
MALON
Member
Join Date: Jan 2008
Old 07-22-2008 , 18:25   Re: Preventing Spectators for certain players
Reply With Quote #5

I am going to test it now. I didn't really need all this fancy stuff

Sorry for saying it didn't work before, I tested it with only two players. Didn't realize that it would still spec if only one player is left. The reason why I wanted the plugin is because I run a KZ server, and when people are going for a really fast run, they don't like people speccing them. Ideally, I'd like it so that if there are two players left, one being a spectator and the other is doing a run and is nospecced, that it would basically tell the user trying to spectate "No one available to spectate". Your plugin might already do this! Your code is just beyond my level and I can't read the source to tell if it does or not

Thanks again!

--MALON
MALON is offline
MALON
Member
Join Date: Jan 2008
Old 07-22-2008 , 18:51   Re: Preventing Spectators for certain players
Reply With Quote #6

Ok, it works close to correct. I am testing it with two players at the moment. It appears that with two players, spec in first person mode doesn't work quite correctly. It still follows the player's location, but not direction of looking. I think this might be good enough for me to use even so.

Thank you very much. Greatly appreciated.

--MALON
MALON is offline
MALON
Member
Join Date: Jan 2008
Old 07-22-2008 , 19:08   Re: Preventing Spectators for certain players
Reply With Quote #7

Ok, it's now been tested with more than 2 players and the first person bug still exists. Sorry for that info

I am also using SpecInfo by ian.cammarata and even though i'm not allowed to spectate the given player, i still show up on that message as spectating them. This can be dealt with by me (i think), so don't worry too much about it, unless you know a better fix.

If you decide to fix the the first-person glitch, I will probably remove the "you are not allowed to spectate that player!" message. Basically, I want it to emulate as if the person isn't even in the server.

Thank you for what you've done so far, +karma.
MALON is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-23-2008 , 03:45   Re: Preventing Spectators for certain players
Reply With Quote #8

-Maybe i can do somehting if are only 2 players on server, just attach player view on a fake ent.
-I've notice that too, you can see old spectated body, but the vision is attached to next player.But after 3-4 worked fine;dunno i will make more tests.
-About SpecInfo, strange pev_iuser2 should be the spectated target, so if change it, you can't appear on that list.Maybe there is another offset/value , that store spectated player info, so must be changed too.

I will try to fix those bugs.
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
MALON
Member
Join Date: Jan 2008
Old 07-26-2008 , 14:40   Re: Preventing Spectators for certain players
Reply With Quote #9

Ok, I tried to make a barebones one. Why is it failing? It seems like it should logically work..All it does is instantly set anyone who spectates to free-roam.

PHP Code:

#include <amxmodx>
#include <fakemeta>

new bool:specMe[33] = true;
new 
playerCounter[33] = 0;

public 
plugin_init() 
{        
  
register_concmd("say /nospec""cmdNoSpec"0"Don't allow players to spec you")
  
register_forward(FM_PlayerPreThink"fwdPlayerPreThink"0);
}


public 
cmdNoSpec(id)
{
    if(
specMe[id]){
        
client_print(idprint_chat"[xKz] No one can spec you now"); // Re-assure the guy
        
specMe[id]=false// Tell the pricks not to look at this guy 
    
}else{
        
client_print(idprint_chat"[xKz] Anyone can spec you now"); // Re-assure the guy
        
specMe[id]=true// Tell the pricks not to look at this guy
    
}
}


public 
fwdPlayerPreThink(id)
{
    if(
is_user_alive(id))//if you are alive
        
return FMRES_IGNORED;
    
    static 
iTarget;
    
iTarget pev(idpev_iuser2);//get the person you're spectatings id
    
    
if(!is_user_alive(iTarget))//are they alive?
        
return FMRES_IGNORED;

    
    if (!
specMe[iTarget]){//execute +attack if unspeccable
        
client_cmd(id"+attack;-attack")
    }
    
    if(
playerCounter[id] >= get_playersnum())//if looped through all players in the server and none found speccable
    
{
        
playerCounter[id] = 0;
        
set_pev(idpev_iuser13)//set to free roam
        
set_pev(idpev_iuser20)//not sure, but it helps setting free roam
        
return PLUGIN_CONTINUE
    
}
    
    
playerCounter[id]++;//if not looped through everyone, increase player counter by one
    
return PLUGIN_CONTINUE


Last edited by MALON; 07-26-2008 at 14:44.
MALON is offline
MALON
Member
Join Date: Jan 2008
Old 07-28-2008 , 02:39   Re: Preventing Spectators for certain players *solved*
Reply With Quote #10

PHP Code:
public cmdNoSpec(id)
{
    if(
get_entity_visibility(id)){
        
client_print(idprint_chat"No one can spec you now");
        
set_entity_visibility(id0)
    }else{
        
client_print(idprint_chat"Anyone can spec you now");
        
set_entity_visibility(id1)
    }
    return 
PLUGIN_CONTINUE

Works perfectly and does just what i wanted
MALON 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 05:32.


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