AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Kick no-steam ppl (https://forums.alliedmods.net/showthread.php?t=55683)

Alka 05-27-2007 16:21

Kick no-steam ppl
 
1 Attachment(s)
Hi.I have this plugin that supose to act like this:"When the server is full and a player with steam is connecting, kick a random "no-steam" player!"
*I dunno how to kick a random "no-steam" player,maybe a stock or....,
*I don't know i plugin works!Someone tells me is not working...:|


Thanks.

Cheap_Suit 05-27-2007 16:28

Re: Kick no-steam ppl
 
Your checking here if the user is a bot.
PHP Code:

if(!is_user_bot(id))
  return 
0

Checking the players authid is pretty much useless here since your going to loop to all the players in player_kick() function
PHP Code:

new authid[32]
 
get_user_authid(id,authid,31)
 
 if(
players limit
 {
  if(
containi(authid,"STEAM_ID_PENDING"))
  {
   
player_kick()
  }
 
 } 

Also the right usage of "containi" is
PHP Code:

if(containi(authid,"STEAM_ID_PENDING") != -1

Because it returns -1 if it cant find anything.

regalis 05-27-2007 20:25

Re: Kick no-steam ppl
 
Im bored so i fixed cheap_suit's suggestions/hints and optimized a little..
Hope that is ok ;)

The returns are strange i would return PLUGIN_HANDLED or PLUGIN_CONTINUE, but i don't know which is better so i don't touched this..0o

Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Advanced Steam slot"
#define VERSION "1.0"
#define AUTHOR "Alka"

new g_maxplayers

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    g_maxplayers = get_maxplayers();
}

public client_connect(id)
{
    if(is_user_bot(id)) return 0;
   
    new players = get_playersnum(1);
    new limit = g_maxplayers - get_cvar_num("amx_reservation");
       
    if(players > limit)
    {
        new authid[32];
        get_user_authid(id,authid,31);
        if(containi(authid,"STEAM_ID_PENDING") != -1)
        {
            player_kick();
        }
    }
    return 0;
}

public player_kick()
{
    new players[32], inum, i, player;
    get_players(players,inum);
   
    for(i = 0; i < inum; i++)
    {
        player = players[i];
       
        new authid[32];
        get_user_authid(player,authid,31);
       
        if(!equal(authid,"STEAM_ID_PENDING") && (containi(authid,"STEAM_0:0") == -1) && (containi(authid,"STEAM_0:1") == -1))
        {
            server_cmd("kick #%i A player with SteamID connected! Buy Steam for reserved slot!",get_user_userid(player));
        }
    }
    return 1;
}

greetz regalis

Alka 05-28-2007 03:31

Re: Kick no-steam ppl
 
heh thanks ^^!! but strange code :lol:

Code:

        if(!equal(authid,"STEAM_ID_PENDING") && (containi(authid,"STEAM_0:0") == -1) && (containi(authid,"STEAM_0:1") == -1))
        {
            server_cmd("kick #%i A player with SteamID connected! Buy Steam for reserved slot!",get_user_userid(player));
        }

i think should be
Code:

        if(!equal(authid,"STEAM_ID_PENDING") && (containi(authid,"STEAM_0:0") != -1) || (containi(authid,"STEAM_0:1") =! -1))
        {
            server_cmd("kick #%i A player with SteamID connected! Buy Steam for reserved slot!",get_user_userid(player));
        }

...:/

Lee 05-28-2007 06:04

Re: Kick no-steam ppl
 
The first check is rather redundant since STEAM_0:0/1 is not contained within STEAM_ID_PENDING.

regalis 05-28-2007 06:57

Re: Kick no-steam ppl
 
Quote:

Originally Posted by Alka (Post 482795)
heh thanks ^^!! but strange code :lol:

Code:

        if(!equal(authid,"STEAM_ID_PENDING") && (containi(authid,"STEAM_0:0") == -1) && (containi(authid,"STEAM_0:1") == -1))
        {
            server_cmd("kick #%i A player with SteamID connected! Buy Steam for reserved slot!",get_user_userid(player));
        }

i think should be
Code:

        if(!equal(authid,"STEAM_ID_PENDING") && (containi(authid,"STEAM_0:0") != -1) || (containi(authid,"STEAM_0:1") =! -1))
        {
            server_cmd("kick #%i A player with SteamID connected! Buy Steam for reserved slot!",get_user_userid(player));
        }

...:/

If you do != then you get the players with STEAM_0:" in their name ;)
Means you will kick a steamplayer *g*


Quote:

Originally Posted by Lee (Post 482823)
The first check is rather redundant since STEAM_0:0/1 is not contained within STEAM_ID_PENDING.

If i got that right, players who have a authid of type "STEAM_ID_PENDING" or "STEAM_0:" have a steam account!? correct?
Then this check would be correct because STEAM_0: wouldn't contain STEAM_ID_PENDING.
But i got doubts that "STEAM_ID_PENDIG" is a valid steamaccount...dont know exactly...

greetz regalis

Lee 05-28-2007 07:23

Re: Kick no-steam ppl
 
My mistake. I was a little confused as to whether you were checking for a valid or invalid SteamID. I should pay more attention.


All times are GMT -4. The time now is 10:33.

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