AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help with Spec Kick plugin for CS 1.6 (https://forums.alliedmods.net/showthread.php?t=5704)

foo.bar 09-10-2004 08:57

Help with Spec Kick plugin for CS 1.6
 
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.

Freecode 09-10-2004 09:15

instead of i use Players[i]

foo.bar 09-10-2004 09:21

Quote:

Originally Posted by Freecode
instead of i use Players[i]

In all instances after the for?

Freecode 09-10-2004 09:25

yes also u can get their flag isntead of checking team. flag is FL_SPECTATOR or something like that.

foo.bar 09-10-2004 10:24

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.

Freecode 09-10-2004 10:30

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)

foo.bar 09-10-2004 10:36

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.

Freecode 09-10-2004 10:39

hmm include files is proly all u need to look at. not much documentation on scripting.


All times are GMT -4. The time now is 17:13.

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