Raised This Month: $ Target: $400
 0% 

problem with x-war 1.5


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
lempl
Junior Member
Join Date: Mar 2009
Old 06-17-2009 , 18:47   problem with x-war 1.5
Reply With Quote #1

hi im running this: http://forums.alliedmods.net/showthread.php?t=45771 plugin on my sever and its great, but i have problem with vote system included in x-warvote.amxx, match started succesfully only if max 2 players are connected otherwise vote neverends


x-warvote.sma code


PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "x-warvote"
#define VERSION "0.2"
#define AUTHOR "niro"

// command access level:
#define CMDACCESS ADMIN_USER

//#define DEBUG

#define TID_VOTEEND    144441
#define TID_UNBLOCK    144442

new vyesvnovnumct_plnumt_plnum
new menu[32], menunummenuheader[32]
new 
command[32], block[2] = {00}, modeinprogress 0

public plugin_init() {
    
#if defined DEBUG
    
server_print("* plugin_init()")
    
#endif
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_dictionary("x-war.txt")
    
register_dictionary("x-warvote.txt")
    
    
register_cvar("xw_vote_delay""10")
    
register_cvar("xw_vote_time""1")
    
register_cvar("xw_vote_ratio""0.9")
    
register_cvar("xw_maxnotvoted_ratio""0.1")
    
    
register_concmd("say cw""vote_cw"CMDACCESS)
    
register_concmd("say cwabort""vote_cwabort"CMDACCESS)

    new 
cfgdir[64]
    
get_configsdir(cfgdir,63)
    
server_cmd("exec %s/x-war/x-warvote.cfg",cfgdir)
}

public 
vote_cw(id){
    if(
vaultdata_exists("cw_initialized")){
        
client_print(idprint_chat"%L"LANG_PLAYER"notallowed")
        return 
PLUGIN_HANDLED
    
}
    
format(command31"cw")
    
format(menuheader31"menu_mm_item1")
    
mode 0
    vote_start
(id)
    
    return 
PLUGIN_CONTINUE
}

public 
vote_cwabort(id){
    if(!
vaultdata_exists("cw_initialized")){
        
client_print(idprint_chat"%L"LANG_PLAYER"notallowed")
        return 
PLUGIN_HANDLED
    
}
    
format(command31"cwabort")
    
format(menuheader31"menu_mm_item3")
    
mode 1
    vote_start
(id)

    return 
PLUGIN_CONTINUE
}

public 
vote_start(id){
    
#if defined DEBUG
    
server_print("* vote_start()")
    
#endif
    
if (id && !((get_user_flags(id) & CMDACCESS))){ 
        
client_print(0print_chat"%L"LANG_PLAYER"clt_noaccess")
        return 
PLUGIN_CONTINUE
    
}
    new 
players[32], i

    
if(block[mode] || inprogress){
        
client_print(idprint_chat"%L"LANG_PLAYER"notallowed")
        return 
PLUGIN_CONTINUE
    
}
    
vyes 0
    vno 
0
    vnum 
0
    menunum 
0
    get_players
(players,ct_plnum,"e","CT")
    for(
i=0;i<ct_plnum;i++) if(players[i]!=idcwmenu_show(players[i])

    
get_players(players,t_plnum,"e","TERRORIST")
    for(
i=0;i<t_plnum;i++) if(players[i]!=idcwmenu_show(players[i])
    
    
cwmenu_action(id00)
    
    
set_task(float(get_cvar_num("xw_vote_time")*60), "vote_end"TID_VOTEEND)
    
set_task(float(get_cvar_num("xw_vote_delay")*60), "vote_unblock"TID_UNBLOCK+mode)
    
block[mode] = 1
    inprogress 
1
    
    
return PLUGIN_CONTINUE
}

public 
vote_unblock(){
    
#if defined DEBUG
    
server_print("* vote_unblock()")
    
#endif
    
block[mode] = 0
    
    
return PLUGIN_CONTINUE
}

public 
vote_end(){
    
#if defined DEBUG
    
server_print("* vote_end()")
    
#endif
    
new ineed floatround(get_cvar_float("xw_vote_ratio")*float(vnum), floatround_ceil)
    
    for(
i=0;i<menunum;i++) menu_destroy(menu[menunum])

    if((
ct_plnum+t_plnum-vnum) >= get_cvar_float("xw_maxnotvoted_ratio")*float(ct_plnum+t_plnum)){
        
remove_task(TID_UNBLOCK+mode)
        
vote_unblock()
    }
    
    if((
vyes>=need) && vnumserver_cmd(command)
    else 
client_print(0print_chat"%L"LANG_PLAYER"failed"vyesvnoct_plnum+t_plnum-vnumneed)
    
    
inprogress 0
    
    
return PLUGIN_CONTINUE
}

public 
client_disconnect(id){
    
#if defined DEBUG
    
server_print("* client_disconnect(id=%d)"id)
    
#endif
    
new playerteam[2]
    
    
get_user_team(id,playerteam,1)
    switch(
playerteam[0]){
        case 
'C'ct_plnum--
        case 
'T't_plnum--
    }
    
    return 
PLUGIN_CONTINUE
}

public 
cwmenu_action(idmenuitem){
    
#if defined DEBUG
    
server_print("* cwmenu_action(id=%d, menu=%d, item=%d)"idmenuitem)
    
#endif
    
if(item == MENU_EXIT) return PLUGIN_HANDLED
    
    vnum
++
    (
item) ? vno++ : vyes++
    
    if(
vnum == ct_plnum t_plnum){
        
remove_task(TID_VOTEEND)
        
vote_end()
    }
    
    return 
PLUGIN_HANDLED
}

public 
cwmenu_show(id){
    
#if defined DEBUG
    
server_print("* cwmenu_show(id=%d)"id)
    
#endif
    
new str[32]
    
    
format(str31"%L"idmenuheader)
    
menu[menunum] = menu_create(str"cwmenu_action")
    
    
format(str31"%L"id"menu_yes")
    
menu_additem(menu[menunum], str)
    
format(str31"%L"id"menu_no")
    
menu_additem(menu[menunum], str)
    
menu_setprop(menu[menunum], MPROP_EXITMEXIT_NEVER)
    
menu_display(idmenu[menunum++], 0)
    
    return 
PLUGIN_HANDLED

debug output:
Code:
L 06/17/2009 - 23:39:11: Invalid menu id 0(2)                                                                                
L 06/17/2009 - 23:39:11: [AMXX] Displaying debug trace (plugin "x-warvote.amxx")                                             
L 06/17/2009 - 23:39:11: [AMXX] Run time error 10: native error (native "menu_destroy")                                      
L 06/17/2009 - 23:39:11: [AMXX]    [0] 20146.attach::vote_end (line 117)                                                     
L 06/17/2009 - 23:39:11: [AMXX]    [1] 20146.attach::cwmenu_action (line 158)                                                
L 06/17/2009 - 23:39:16: World triggered "Round_Start"
whats wrong?

Last edited by lempl; 06-17-2009 at 18:51.
lempl is offline
 



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 15:26.


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