AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved don't change before x rounds (https://forums.alliedmods.net/showthread.php?t=299900)

Ayman Khaled 07-29-2017 14:00

don't change before x rounds
 
hi guys
i made a small plugin which block change map when rounds didn't reach 14.
but it's not works
PHP Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Ayman Khaled"

new CurrentRound
new g_szAllowedRoundsp_AllowedRounds

public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("amx_map""cmdMap")
    
register_clcmd("amx_votemap""cmdMap")
    
    
g_szAllowedRounds register_cvar("change_map_rounds""14")
    
p_AllowedRounds get_pcvar_num(g_szAllowedRounds)
    
    
register_logevent("Hook_NewR"2"1=Round_Start" );
    
register_event("TextMsg""Hook_Restart""a""2&#Game_C""2&#Game_w""2&#Game_will_restart_in" );
}

public 
Hook_NewR()
{
    
CurrentRound++
}

public 
Hook_Restart()
{
    
CurrentRound=0;
}

public 
cmdMap(id)
{
    if(
CurrentRound p_AllowedRounds)
        return 
PLUGIN_HANDLED
    
    
return PLUGIN_CONTINUE



siriusmd99 07-29-2017 15:04

Re: don't change before x rounds
 
You must put your plugin at the top in plugins.ini so that cmdMap(id) will be called first and return Handled on next plugins.

Ayman Khaled 07-29-2017 16:15

Re: don't change before x rounds
 
same thing, it's not works.
should i add this code to admincmd.amxx in cmdMap(id) or not ?
EDIT:
now it's works in admincmd.sma :D
if someone is interesting
PHP Code:

const AdminFlags = ( ADMIN_IMMUNITY );
#define IsAdmin(%1)    ((get_user_flags(%1)&AdminFlags)==AdminFlags)

new CurrentRound
new g_szAllowedRoundsp_AllowedRounds 

in plugin_init

PHP Code:

g_szAllowedRounds register_cvar("change_map_rounds""20")
        
p_AllowedRounds get_pcvar_num(g_szAllowedRounds)
    
        
register_logevent("Hook_NewR"2"1=Round_Start" );
        
register_event("TextMsg""Hook_Restart""a""2&#Game_C""2&#Game_w""2&#Game_will_restart_in" ); 

PHP Code:

public Hook_NewR()
{
    
CurrentRound++
}

public 
Hook_Restart()
{
    
CurrentRound=0;


if ( !IsAdmin ( id ) )
here to check if user don't has ADMIN_IMMUNITY then block change map until reach 20 rounds.
PHP Code:

public cmdMap(idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
        
if ( !IsAdmin id ) )
    {
        if(
CurrentRound p_AllowedRounds)
        {
            
client_print(idprint_chat "[NaBlu$-GamING] You are not allowed to change map right now.")
            return 
PLUGIN_HANDLED
        
}
    }

    new 
arg[32]
    new 
arglen read_argv(1argcharsmax(arg))
    
    if (!
is_map_valid(arg))
    {
        
console_print(id"[AMXX] %L"id"MAP_NOT_FOUND")
        return 
PLUGIN_HANDLED
    
}

    new 
authid[32], name[MAX_NAME_LENGTH]
    
    
get_user_authid(idauthidcharsmax(authid))
    
get_user_name(idnamecharsmax(name))
    
    
show_activity_key("ADMIN_MAP_1""ADMIN_MAP_2"namearg);
    
    
log_amx("Cmd: ^"%s<%d><%s><>^" changelevel ^"%s^""nameget_user_userid(id), authidarg)
    
    new 
_modName[10]
    
get_modname(_modNamecharsmax(_modName))
    
    if (!
equal(_modName"zp"))
    {
        
message_begin(MSG_ALLSVC_INTERMISSION)
        
message_end()
    }
    
    
set_task(2.0"chMap"0argarglen 1)
    
    return 
PLUGIN_HANDLED



D3XT3R 07-29-2017 19:29

Re: don't change before x rounds
 
because you need edit yours map chooser plugin... add a task delay by rounds

Ayman Khaled 07-29-2017 23:45

Re: don't change before x rounds
 
i don't use default map chooser, i'm using map manager.


All times are GMT -4. The time now is 22:58.

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