Raised This Month: $ Target: $400
 0% 

Help with Spec Kick plugin for CS 1.6


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
foo.bar
Junior Member
Join Date: Sep 2004
Location: SJCampos - Brazil
Old 09-10-2004 , 08:57   Help with Spec Kick plugin for CS 1.6
Reply With Quote #1

Heyall,

I've been lurking these forums for the past 3 days trying to iron out my spec kick plugin but it just doesn't work so I've decided to post the code here and see what you guys think.

I coded it for my CS 1.6 server so there are no STEAM checks or anything. It's purpose is to kick users that are in SPECTATOR mode, connected but don't have the immunity bit set at the start of a round when there are 10 or more players.

Code:
#include <amxmodx>

public Round_Time()
{
        new Float:roundtime = get_cvar_float("mp_roundtime") * 60.0
        new rtime = read_data(1)

        if ( roundtime == rtime )   {
                new playerCount = get_playersnum()

                if (playerCount > 9) {
                        new Players[32]
                        new i, userid, team
                        get_players(Players, playerCount)

                        for (i=0; i<playerCount; i++) {
                                if (is_user_connected(i)) {
                                        if (!(get_user_flags(i)&ADMIN_IMMUNITY)) {
                                                team = get_user_team(i)
                                                if (team != 0 && team != 1) {
                                                        new name[32], authid[32]

                                                        get_user_name(i, name,31)
                                                        get_user_authid(i, authid,31)

                                                        userid = get_user_userid(i)
                                                        server_cmd("kick #%d ^"Spectator^"",userid)

                                                        log_amx("Spec Kick: ^"%s<%d><%s>^" was spec kicked)", name,get_user_userid(i),authid)

                                                }
                                        }
                                }
                        }
                }

        }

        return PLUGIN_CONTINUE
}

public plugin_init() {
        register_plugin("Spec Kick","0.1","Foo.bar")
        register_event("RoundTime", "Round_Time", "bc")

        return PLUGIN_CONTINUE
}
(Maybe useful) observations:
- The code is stretched out (cascading ifs) so that I could code in a simpler manner but it'll be optimized once it starts working.
- I've tried coding it with cs_user_team_get but it didn't work (right after the immunity bit check, I did have an include for cstrike)
Code:
if (cs_user_team_get(i) == 3) {
- I've tried comparing the variable "team" with 3 and it didn't work.

If you've got an idea, please help!

Edit:
- I've left out the is_player_alive() check because I don't know if spectators are considered dead or alive.
__________________
Wenn ist das Nunstuck git und Slotermeyer?
Ja! Beiherhund das Oder die Flipperwaldt gersput!
foo.bar is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 09-10-2004 , 09:15  
Reply With Quote #2

instead of i use Players[i]
Freecode is offline
foo.bar
Junior Member
Join Date: Sep 2004
Location: SJCampos - Brazil
Old 09-10-2004 , 09:21  
Reply With Quote #3

Quote:
Originally Posted by Freecode
instead of i use Players[i]
In all instances after the for?
__________________
Wenn ist das Nunstuck git und Slotermeyer?
Ja! Beiherhund das Oder die Flipperwaldt gersput!
foo.bar is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 09-10-2004 , 09:25  
Reply With Quote #4

yes also u can get their flag isntead of checking team. flag is FL_SPECTATOR or something like that.
Freecode is offline
foo.bar
Junior Member
Join Date: Sep 2004
Location: SJCampos - Brazil
Old 09-10-2004 , 10:24  
Reply With Quote #5

Okay, I'll give it a try...

I've changed the team checking "if" to:
Code:
if ((team != 0 && team != 1) || get_user_flags(Players[i])&FL_SPECTATOR) {
I know, it might be redundant but it's better to be safe than sorry on this one considering that all my previous attempts have all been met with failure.
__________________
Wenn ist das Nunstuck git und Slotermeyer?
Ja! Beiherhund das Oder die Flipperwaldt gersput!
foo.bar is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 09-10-2004 , 10:30  
Reply With Quote #6

cant do this
get_user_flags(Players[i])&FL_SPECTATOR
need to include engine module and do this

Code:
#define FL_SPECTATOR        (1<<26) // Add this under include files new flags = entity_get_int(players[i],EV_INT_flags); if(flags & FL_SPECTATOR)
Freecode is offline
foo.bar
Junior Member
Join Date: Sep 2004
Location: SJCampos - Brazil
Old 09-10-2004 , 10:36  
Reply With Quote #7

Quote:
Originally Posted by Freecode
cant do this
get_user_flags(Players[i])&FL_SPECTATOR
need to include engine module and do this
Done, thanks once again.

BTW, is there any documentation or primers for programing AMX/AMXX plugins?

I probably didn't do enough research before asking about my problem but I've found very little help (except on the AMX and AMXX forums) about how I should do stuff.
__________________
Wenn ist das Nunstuck git und Slotermeyer?
Ja! Beiherhund das Oder die Flipperwaldt gersput!
foo.bar is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 09-10-2004 , 10:39  
Reply With Quote #8

hmm include files is proly all u need to look at. not much documentation on scripting.
Freecode 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 17:13.


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