AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Reserve slot (https://forums.alliedmods.net/showthread.php?t=192943)

Sutar 08-15-2012 09:53

Reserve slot
 
I have a server, it can be 17 players.
1st place for the administrator.
16 places for the players.

When the server has 15 players at the entrance of the sixteenth - is disabled and says that there is no space.
Although it should be disabled when the server is 16 people.

Here's the script:

Code:

public client_authorized(id)
{
        accessUser(id)
       
        if(!access(id, ADMIN_RESERVATION))
        {
                if(get_playersnum(1) >= (get_maxplayers() - g_aSlot))
                {
                        server_cmd("kick #%d ^"There is no place.^"", get_user_userid(id))
                        return PLUGIN_CONTINUE
                }
        }
       
        return PLUGIN_CONTINUE
}

What is wrong?

striker07 08-15-2012 10:40

Re: Reserve slot
 
show the entire plugin and not just a part

Sutar 08-15-2012 10:51

Re: Reserve slot
 
I wrote this piece in end admin.amxx...

The plugin will be:

Code:

#include <amxmodx>
#include <amxmisc>

new g_aSlot = 1

public plugin_init()
{
        register_plugin("AmxBans Admin Base", "2.5", "Sutar")
}

public client_authorized(id)
{
        if(!access(id, ADMIN_RESERVATION))
        {
                if(get_playersnum(1) >= (get_maxplayers() - g_aSlot))
                {
                        server_cmd("kick #%d ^"Извините, нет места для игроков!^"", get_user_userid(id))
                        return PLUGIN_CONTINUE
                }
        }
        return PLUGIN_CONTINUE
}

Possible error in the:
Code:

get_playersnum(1)
-->
Code:

get_playersnum()

striker07 08-15-2012 15:30

Re: Reserve slot
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
 
new g_aSlot 1
 
public plugin_init()
{
    
register_plugin("AmxBans Admin Base""2.5""Sutar")
}
 
public 
client_authorized(id)
{
    if(!
access(idADMIN_RESERVATION))
    {
        if(
get_playersnum(1) >= (get_maxplayers() - g_aSlot))
        {
            
server_cmd("kick #%d Извините, нет места для игроков!"get_user_userid(id))           
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE


try changing plugin continue to handled, i think that should do it
Quote:

Possible error in the:
Code:

get_playersnum(1)
-->
Code:

get_playersnum()

get_playersnum(1) will return also players connecting to the server
get_playersnum() not

Exolent[jNr] 08-15-2012 15:32

Re: Reserve slot
 
Quote:

Originally Posted by striker07 (Post 1772306)
try changing plugin continue to handled, i think that should do it

Return value is ignored in the connect/authorized/disconnect forwards.

striker07 08-15-2012 15:38

Re: Reserve slot
 
return PLUGIN_IGNORED?
does he even need the returns?

Exolent[jNr] 08-15-2012 15:39

Re: Reserve slot
 
Quote:

Originally Posted by striker07 (Post 1772314)
return PLUGIN_IGNORED?
does he even need the returns?

1. That doesn't exist.
2. No, since return values are ignored, there is no point to return here.

striker07 08-15-2012 16:38

Re: Reserve slot
 
ah ok thx :)

Sutar 08-16-2012 03:03

Re: Reserve slot
 
That is, the code will be then?

Code:

#include <amxmodx>
#include <amxmisc>
 
new g_aSlot = 1
 
public plugin_init()
{
    register_plugin("AmxBans Admin Base", "2.5", "Sutar")
}
 
public client_authorized(id)
{
        if(!access(id, ADMIN_RESERVATION) && get_playersnum() >= (get_maxplayers() - g_aSlot))
                server_cmd("kick #%d", get_user_userid(id))
}

as said striker07, get_playersnum() - Not the player who enters. That's what I need?

jimaway 08-16-2012 06:45

Re: Reserve slot
 
Quote:

Originally Posted by Sutar (Post 1772007)
Code:

public client_authorized(id)
{
        accessUser(id)
       
        if(!access(id, ADMIN_RESERVATION))
        {
                if(get_playersnum(1) >= (get_maxplayers() - g_aSlot))
                {
                        server_cmd("kick #%d ^"There is no place.^"", get_user_userid(id))
                        return PLUGIN_CONTINUE
                }
        }
       
        return PLUGIN_CONTINUE
}


the problem is in this line: if(get_playersnum(1) >= (get_maxplayers() - g_aSlot))
let me change the natives with proper numbers
if(16 >= (17 - 1))
thats why it wont let the 16th player connect :wink:


All times are GMT -4. The time now is 05:41.

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