Raised This Month: $32 Target: $400
 8% 

default case problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-26-2010 , 08:51   default case problem
Reply With Quote #1

hi,




i have a problem with cases and default case!

when i try to add 1 item in my menu & then get the player list, it works perfect and without any problems...

but when i add more than 1 items in the menu, i just get wrong cases and more cases will not work.

example :

WORKS

PHP Code:
public free_for_xx(id)
{
    static 
opcion[64]
    
    
formatex(opcioncharsmax(opcion),"\y%L:"id"CHOOSE_Free")
    new 
iMenu menu_create(opcion"choose_freedayler")
    
    new 
players[32], pnumtempid
    
new szName[32], szTempid[10]
    
    
    
get_players(playerspnum"b")
    
    
formatex(opcioncharsmax(opcion),"\w%L"id"BACK")
    
menu_additem(iMenuopcion"1")
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
        
        if (
cs_get_user_team(tempid) != CS_TEAM_T)
        {
            continue
        }
        
        
get_user_name(tempidszName31)
        
num_to_str(tempidszTempid9)
        
menu_additem(iMenuszNameszTempid0)
    }
    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}
public 
choose_freedayler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {    
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
Data[6], Name[64]
    new 
AccessCallback
    menu_item_getinfo
(menuitemAccessData,5Name63Callback)
    
    new 
tempid str_to_num(Data)
    
    
    switch(
tempid)
    {
        case 
1:
        {
            
duel_menu(id)
        }
        default:
        {
            
get_user_name(tempid,name1,32)
            
user_has_freeday1[tempid] = true
            free_for_xx2
(id)            
        }
    }
    
menu_destroy(menu)    
    return 
PLUGIN_HANDLED

WRONG ??? :

Code:
public showing_menu(id)
{
    static szMenuName[64]
    formatex(szMenuName, 63, "\y%L", id, "MENU_HEADER")
    new menu = menu_create(szMenuName, "free_choosed")
        
    
    new players[32], pnum,tempid
    new szName[32], szTempid[10]
    
    

    get_players(players, pnum,"a")

    formatex(szMenuName, charsmax(szMenuName), "\w%L", id, "FFA");
    menu_additem(menu,szMenuName, "1");
    formatex(szMenuName, charsmax(szMenuName), "\w%L", id, "REMOVE");
    menu_additem(menu,szMenuName, "2");
    
    formatex(szMenuName, charsmax(szMenuName), "\w%L", id, "VOTE");
    menu_additem(menu,szMenuName, "3");
    
    formatex(szMenuName, charsmax(szMenuName), "\w%L", id, "HNS");
    menu_additem(menu,szMenuName, "4");
    

    
    for( new i; i<pnum; i++ )
    {
        tempid = players[i]
        
        if (cs_get_user_team(tempid) == CS_TEAM_CT)
        {
            continue
        }
        get_user_name(tempid, szName, 31)
        num_to_str(tempid, szTempid, 9)
        menu_additem(menu, szName, szTempid,0)
    }
    menu_display(id,menu)
    return PLUGIN_HANDLED
}
public free_choosed(id,menu,item)
{
    if( item & MENU_EXIT )
    {
        menu_destroy(menu)
        return PLUGIN_HANDLED
    }
    new data[6], iName[64]
    new access, callback
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)
    
    new tempid  = str_to_num(data)
    
    switch(tempid)
    {
        case 1:
        {
            set_task(0.5,"free_for_all",1337,"",0,"b")
            new name[33]
            get_user_name(id,name,32)
            client_print(0,print_chat,"%L", LANG_PLAYER, "ADMIN_FFA",name)
            client_print(0,print_chat,"%L", LANG_PLAYER, "TIME_TO_FREEDAY")
            admin_gave_freeday = 1
            set_hudmessage(255,255,255,-1.0, 0.2,0, 0.0, 3.0, 0.0, 0.0, -1 );
            show_hudmessage(id, "%L",LANG_PLAYER,"ADMIN_FFA_HUD",name);
        }
        case 2:
        {
            remove_glow(id)
        }
        case 3:
        {
            StartVote(id)
        }
        case 4:
        {
            
            client_print(0,print_chat,"DEBUG")
            hns(id)
        }
        default:
        {
            if(is_user_alive(tempid))
            {
                new name1[33] , name[33]
                get_user_name(tempid,name1,32)
                get_user_name(id,name,32)
                client_print(0,print_chat,"%L", LANG_PLAYER, "ADMIN_FFP",name,name1)
                set_task(0.5,"player_is_free",TASK_PLAYERFREE+g_tempid,"",0,"b")
                player_menu(id)
            }
        }
    }
    menu_destroy(menu);
    return PLUGIN_HANDLED;
}
<<<<BOLD = not working

WTF?

i am working around 2 H. @ only 1 menu and i cant get this shit working.
by case 4 i get nothing. ( see debug print ) nothing willbe printed oO
__________________

Last edited by One; 03-26-2010 at 08:54.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 03-26-2010 , 08:55   Re: default case problem
Reply With Quote #2

Code:
    for( new i; i<pnum; i++ )     {         tempid = players[i]                 if (cs_get_user_team(tempid) == CS_TEAM_CT)         {             continue         }         get_user_name(tempid, szName, 31)         num_to_str(tempid, szTempid, 9)         menu_additem(menu, szName, szTempid,0)     }
Remove this part and test
__________________
xPaw is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-26-2010 , 08:58   Re: default case problem
Reply With Quote #3

the same.

item 4 is not working

no errors.. nothing to see


fullcode =

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <hamsandwich>
#include <cstrike>


#define TASK_PLAYERFREE 1000

new g_tempid,g_MaxPlayers,g_leach_cvar,bool:g_player_is_leader[33],iPlayers32 ], iNum,g_printed,we_have_a_leader,gVoteMenu,
gVotes[2],gVoting,g_delay,g_percent,bool:g_Vote_Player[33],g_voted,g_free_vote,g_its_freeday,g_rounds,g_had_freeround,can_vote,
g_vote_round_number,g_let_be_freeday,g_vote_canceled,g_vip_admin,g_show_votes,g_welcomed[33],admin_gave_freeday,g_welcome_menu,gmsgScreenFade

public plugin_init() 
{
    
register_plugin("Freeday Manager""1.0.2b","One")
    
register_dictionary("freeday_manager.txt")
    
register_cvar("Freeday_Manager""1.0.2b"FCVAR_SERVER);
    
RegisterHamHam_Spawn"player",        "FwdHamPlayerSpawnPost")
    
g_percent register_cvar("amx_vote_percent","80")
    
g_free_vote register_cvar("amx_freeday_vote","1")
    
g_vip_admin register_cvar("amx_admin_vip","1")
    
g_vote_round_number register_cvar("amx_rounds_for_vote","3")
    
g_show_votes register_cvar("amx_show_votes","1")
    
g_MaxPlayers get_maxplayers()
    
g_leach_cvar register_cvar("amx_leader","0")
    
g_delay get_cvar_pointer "amx_vote_delay" )
    
g_welcome_menu register_cvar("amx_show_welcomemenu","1")
    
register_logevent("endround",2,"0=World triggered","1=Round_End")
    
register_clcmd"say","cmd_say")
    
register_clcmd"say_team","cmd_say")
    
register_logevent("startround",2,"0=World triggered","1=Round_Start")
    
register_event("HLTV""new_round""a""1=0""2=0")
    
register_event("TextMsg""restart_round""a""2=#Game_will_restart_in")
    
register_menucmd(register_menuid("welcome_menu"),1023,"welcome_menu_handler")
    
register_event("ResetHUD","resethud","be")
    
gmsgScreenFade    get_user_msgid("ScreenFade")
}
public 
show_welcome(id)
{
    if(
get_pcvar_num(g_welcome_menu))
    {
        if(
g_welcomed[id]) 
        {
            return
        }
        
        new 
menuidkeys
        get_user_menu
(id,menuid,keys)
    
        if(
menuid 0)
        {
            
set_task(3.0,"show_welcome",id)
            return;
        }
        new 
menuText[512];
        new 
len formatex(menuText,511,"%L",id,"MENU_1")
        
len += formatex(menuText[len],511-len,"%L",id,"MENU_2")
        if(
get_pcvar_num(g_free_vote))
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_3")
        }
        else
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_4")
        }
        
        if(
get_pcvar_num(g_vip_admin))
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_5")
        }
        else
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_6")
        }
        if(
get_pcvar_num(g_show_votes))
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_7")
        }
        else
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_8")
        }
        if(
get_pcvar_num(g_leach_cvar))
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_9")
        }
        else
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_10")
        }
        if(
get_pcvar_num(g_free_vote))
        {
            
len += formatex(menuText[len],511-len,"%L",id,"MENU_11",get_pcvar_num(g_vote_round_number))
        }
        
len += formatex(menuText[len],511-len,"%L",id,"MENU_12")
        
len += formatex(menuText[len],511-len,"%L",id,"MENU_13")
        
len += formatex(menuText[len],511-len,"%L",id,"MENU_14")
        
len += formatex(menuText[len],511-len,"%L",id,"MENU_15")
        
len += formatex(menuText[len],511-len,"%L",id,"MENU_16")
        
        
show_menu(id,1023,menuText,-1,"welcome_menu")
    }
}
public 
welcome_menu_handler(id,key)
{
    
g_welcomed[id] = 1
    
return PLUGIN_HANDLED
}
public 
resethud(id)
{
    
show_welcome(id)
}
public 
cmd_say(id)
{
    static 
say_args[64]
    
read_args(say_argscharsmax(say_args))
    
remove_quotes(say_args)
    
    if(
say_args[0] != '/')
        return 
PLUGIN_CONTINUE
    
    
if(equali(say_args"/freeday") || equali(say_args"/fdm"))
    {
        
player_menu(id)
    }
    
    if(
equali(say_args"/rtd") || equali(say_args"rtd") || equali(say_args"rock the day")|| equali(say_args"fdv")|| equali(say_args"/freedayvote"))
    {
        if(!
get_pcvar_num(g_free_vote))
        {
            
client_print(id,print_chat,"%L"id"VOTE_OFF")
            return 
PLUGIN_HANDLED
        
}
        else if(
g_let_be_freeday)
        {
            
client_print(id,print_chat,"%L"id"NEXT_ROUND")
            return 
PLUGIN_HANDLED
        
}
        else if(
g_its_freeday || admin_gave_freeday)
        {
            
client_print(id,print_chat,"%L"id"ALREADY_FREEDAY")
            return 
PLUGIN_HANDLED
        
}
        else if(
g_Vote_Player[id] && !g_its_freeday && !g_vote_canceled)
        {
            
client_print(id,print_chat,"%L"id"ALREADY_VOTED")
        }
        else if(
g_rounds 1)
        {
            
client_print(id,print_chat,"%L"id"FIRST_ROUND")
            return 
PLUGIN_HANDLED
        
}
        else if(
g_vote_canceled && !g_rounds )
        {
            new 
count_down g_had_freeround get_pcvar_num(g_vote_round_number) +g_rounds
            client_print
(id,print_chat,"%L"id"WAIT_FOR_ROUND",count_down)
            return 
PLUGIN_HANDLED
        
}
        else if(!
can_vote)
        {
            
            new 
count_down g_had_freeround get_pcvar_num(g_vote_round_number) +g_rounds
            client_print
(id,print_chat,"%L"id"WAIT_FOR_ROUND",count_down)
            return 
PLUGIN_HANDLED
        
}
        else
        {
            
check_percents(id)
        }
    }
    return 
PLUGIN_CONTINUE
}
public 
restart_round()
{
    
g_rounds 0;    
}
public 
new_round()
{
    
g_rounds += 1
}
public 
check_percents(id)
{
        
g_Vote_Player[id] = true
        client_print
(id,print_chat,"%L"id"ROCKED_THE_DAY")            
        
g_voted++
        new 
connected_player
        
for (new 1g_MaxPlayers; ++i
        {
            if (
is_user_connected(i))
                
connected_player++
        }
        new 
haghe_ray = (100/connected_player)                    //100%20 nafar = 5%
        
new ray_dadeh_kol haghe_ray g_voted                    //5% * 10nafar = 50
        
new nafar_moundeh get_pcvar_num(g_percent) - ray_dadeh_kol        //80% - 50 dadeh = 30moundeh
        
new moundeh nafar_moundeh/haghe_ray                    //30 / 5 = 6 nafar dige
        
new cheghadr_bayad_bedan g_voted moundeh                // 10 + 6 = 16
        
if(g_voted >= cheghadr_bayad_bedan)
        {
            
set_task(10.0,"make_the_vote")
        }
        else
        {
            
client_print(0,print_chat,"%L"id"VOTE_COUNTS",moundeh)
        }

public 
make_the_vote()
{
    new 
id
    set_hudmessage
(255,255,255,-1.00.2,00.03.00.00.0, -);
    
show_hudmessage(0"%L",LANG_PLAYER,"ENOUGH_VOTED");
    
set_task(5.0,"StartVote",id)
}
public 
player_menu(id)
{
    if(
get_user_flags(id) & ADMIN_KICK )
    {
        
showing_menu(id)
    }
    else if(
is_user_connected(id) && ~cs_get_user_team(id) & CS_TEAM_CT)
    {
        
client_print(id,print_chat,"%L"id"NO_CT")
        return 
PLUGIN_HANDLED;
    }
    else if(!
get_pcvar_num(g_leach_cvar))
    {
        if(!
g_player_is_leader[id] || ~get_user_flags(id) & ADMIN_KICK)
        {
            
client_print(id,print_chat,"%L"id"NO_LEADER")
            return 
PLUGIN_HANDLED;
        }
        else
        {
            
showing_menu(id)
        }
    }
    else if(
get_pcvar_num(g_leach_cvar) & 1)
    {
        if(~
get_user_flags(id) & ADMIN_KICK)
        {
            
client_print(id,print_chat,"%L"id"NO_ADMIN")
            return 
PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_HANDLED
}
public 
showing_menu(id)
{
    static 
szMenuName[64]
    
formatex(szMenuName63"\y%L"id"MENU_HEADER")
    new 
menu menu_create(szMenuName"free_choosed")
        
    
    new 
players[32], pnum,tempid
    
new szName[32], szTempid[10]
    
    

    
get_players(playerspnum,"a")

    
formatex(szMenuNamecharsmax(szMenuName), "\w%L"id"FFA");
    
menu_additem(menu,szMenuName"1");
    
formatex(szMenuNamecharsmax(szMenuName), "\w%L"id"REMOVE");
    
menu_additem(menu,szMenuName"2");
    
    
formatex(szMenuNamecharsmax(szMenuName), "\w%L"id"VOTE");
    
menu_additem(menu,szMenuName"3");
    
    
formatex(szMenuNamecharsmax(szMenuName), "\w%L"id"HNS");
    
menu_additem(menu,szMenuName"4");
    

    
    
/*for( new i; i<pnum; i++ )
    {
        tempid = players[i]
        
        if (cs_get_user_team(tempid) == CS_TEAM_CT)
        {
            continue
        }
        get_user_name(tempid, szName, 31)
        num_to_str(tempid, szTempid, 9)
        menu_additem(menu, szName, szTempid,0)
    }*/
    
menu_display(id,menu)
    return 
PLUGIN_HANDLED
}
public 
free_choosed(id,menu,item)
{
    if( 
item MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)
    
    new 
tempid  str_to_num(data)
    
    switch(
tempid)
    {
        case 
1:
        {
            
set_task(0.5,"free_for_all",1337,"",0,"b")
            new 
name[33]
            
get_user_name(id,name,32)
            
client_print(0,print_chat,"%L"LANG_PLAYER"ADMIN_FFA",name)
            
client_print(0,print_chat,"%L"LANG_PLAYER"TIME_TO_FREEDAY")
            
admin_gave_freeday 1
            set_hudmessage
(255,255,255,-1.00.2,00.03.00.00.0, -);
            
show_hudmessage(id"%L",LANG_PLAYER,"ADMIN_FFA_HUD",name);
        }
        case 
2:
        {
            
remove_glow(id)
        }
        case 
3:
        {
            
StartVote(id)
        }
        case 
4:
        {
            
            
client_print(0,print_chat,"DEBUG")
            
hns(id)
        }
        default:
        {
            if(
is_user_alive(tempid))
            {
                new 
name1[33] , name[33]
                
get_user_name(tempid,name1,32)
                
get_user_name(id,name,32)
                
client_print(0,print_chat,"%L"LANG_PLAYER"ADMIN_FFP",name,name1)
                
set_task(0.5,"player_is_free",TASK_PLAYERFREE+g_tempid,"",0,"b")
                
player_menu(id)
            }
        }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}
new 
the_time 0
public hns(id)
{
    
set_task(1.0,"counter",1339,"",0,"b")
    
the_time 0
}
public 
counter()
{
    
the_time++
    
do_hns()
    
set_hudmessage(255,255,255,-1.00.2,00.03.00.00.0, -);
    
show_hudmessage(0"%L",LANG_PLAYER,"Seektime",the_time);
    if(
the_time == 60)
    {
        
remove_dark()
        
remove_task(1339)
    }
}
public 
remove_dark()
{
    new 
id
    
for(id 1id <= g_MaxPlayersid++)
    {
        if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT)
        {
            
f2b(id0)
            
set_user_godmode(id,0)
        }
    }
}
public 
do_hns()
{
    new 
id
    
for(id 1id <= g_MaxPlayersid++)
    {
        if(
is_user_alive(id) && cs_get_user_team(id) == CS_TEAM_CT)
        {
            
f2b(id1)
            
set_user_godmode(id,1)
        }
    }
}
stock f2b(idtype)
{
    
message_begin(MSG_ONE_UNRELIABLEgmsgScreenFade_id);
    
write_short(5000);
    
write_short(5000);
    
write_short(type==1?5:0);
    
write_byte(0);
    
write_byte(0);
    
write_byte(0);
    
write_byte(255);
    
message_end();
}
public 
StartVote(id)
{
    if( 
gVoting )
    {
        
client_print(id,print_chat,"%L"LANG_PLAYER"VOTE_RUNING")
        return 
PLUGIN_HANDLED;
    }
    new 
szVotemenu[32]
    
formatex(szVotemenu31"\y%L"id"VOTE_HEADER")
    
gVoteMenu menu_create(szVotemenu"vote_handler")
    
    new 
options[32]
    
formatex(options31"\w%L"0"FFA_YES")
    
menu_additem(gVoteMenu,options"0",0)
    
    
formatex(options31"\w%L"0"FFA_NO")
    
menu_additem(gVoteMenu,options"1",0)
    
    new 
players[32], pnumtempid
    gVotes
[0] = 0
    gVotes
[1] = 0
    
    get_players
(playerspnum)
    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
        
menu_display(tempidgVoteMenu0)
        
gVoting++
    }
    
    new 
Float:delay get_pcvar_float g_delay )
    
set_task delay"EndVote" )
    
    return 
PLUGIN_HANDLED
}
public 
vote_handler(idmenuitem)
{
    if( 
item MENU_EXIT || !gVoting )
    {
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)
    new 
voteid str_to_num(data)
    
gVotes[voteid]++
    if(
g_show_votes)
    {
        new 
name[33]
        
get_user_name(id,name,32)
        if(
gVotes[0])
        {
            
client_print(0,print_chat,"%L"LANG_PLAYER"VOTED_FOR_YES",name)
        }
        else if(
gVotes[1] )
        {
            
client_print(0,print_chat,"%L"LANG_PLAYER"VOTED_FOR_NO",name)
        }
    }
    
    return 
PLUGIN_HANDLED
}
public 
EndVote()
{
    if( 
gVotes[0] > gVotes[1] )
    {
        
client_print(0,print_chat,"%L"LANG_PLAYER"FIRST_OPTION",gVotes[0])
        
//set_task(5.0,"free_for_all")
        
g_its_freeday 1
        g_let_be_freeday 
1
        client_print
(0,print_chat,"%L"LANG_PLAYER"NEW_FREEDAY",gVotes[1] )
    }
    else if( 
gVotes[0] > gVotes[1] )
    {
        
client_print(0,print_chat,"%L"LANG_PLAYER"SECUND_OPTION",gVotes[1] )
        
g_vote_canceled 1
        can_vote 
0
        g_had_freeround 
g_rounds
    
}
    else
    {
        
client_print(0,print_chat,"%L"LANG_PLAYER"TIED_OPTION")
        
g_vote_canceled 1
        can_vote 
0
        g_had_freeround 
g_rounds
    
}
    
menu_destroy(gVoteMenu)
    
gVoting 0
}
public 
remove_glow(id)
{
    new 
szMenuName[32]
    
formatex(szMenuName31"\y%L"id"MENU_HEADER_UNFREE")
    new 
menu menu_create(szMenuName"unglow")
    new 
players[32], pnum
    
new szName[32], szTempid[10]
    new 
Temp[32]
    
formatex(Temp31"\w%L"id"FREEDAY_MENU");
    
menu_additem(menu,Temp"1"id);
    
    
get_players(playerspnum"a")
    for( new 
ii<pnumi++ )
    {
        
g_tempid players[i]
        
        if (
cs_get_user_team(g_tempid) != CS_TEAM_T)
        {
            continue
        }
        
        
get_user_name(g_tempidszName31)
        
num_to_str(g_tempidszTempid9)
        
menu_additem(menuszNameszTempid0)
    }
    
menu_display(idmenu)
}
public 
unglow(id,menu,item)
{
    if( 
item MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata,5iName63callback)

    
g_tempid str_to_num(data)

    switch(
g_tempid)
    {
        case 
1:
        {
            
player_menu(id)
        }
        default :
        {
            if( 
is_user_alive(g_tempid))
            {
                new 
name1[33] , name[33]
                
get_user_name(g_tempid,name1,32)
                
get_user_name(id,name,32)
                
client_print(0,print_chat,"%L"LANG_PLAYER"ADMIN_TOOK",name,name1)
                
remove_task(TASK_PLAYERFREE+g_tempid);
                
remove_task(1337)
                if(
is_user_connected(g_tempid))
                {
                    
set_user_rendering(g_tempid)
                    
remove_glow(id)
                }
            }
        }
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}
public 
player_is_free(g_tempid)
{
    
g_tempid -= TASK_PLAYERFREE;
    
    new 
num1 random_num(0,255)
    new 
num2 random_num(0,255)
    new 
num3 random_num(0,255)
    
set_user_rendering(g_tempid,kRenderFxGlowShell,num1,num2,num3,kRenderNormal,40)
}
public 
FwdHamPlayerSpawnPost()
{
    if(!
get_pcvar_num(g_leach_cvar))
    {
        if(!
g_its_freeday)
        {
            
get_playersiPlayersiNum )
            for(new 
id 1id <= g_MaxPlayersid++)
            {
                if(!
we_have_a_leader && is_user_alive(id) && cs_get_user_team(id) & CS_TEAM_CT)
                {
                    
g_player_is_leader[iPlayersrandomiNum ) ]] = true
                    
if(g_player_is_leader[id] & true && !g_printed)
                    {
                        
we_have_a_leader 1
                        set_user_scoreattrib
(id,4)
                        new 
name[33]
                        
get_user_name(id,name,32)
                        
client_print(0,print_chat,"%L"LANG_PLAYER"IS_LEADER",name)
                        
g_printed 1
                    
}
                }
                if(
get_pcvar_num(g_vip_admin))
                {
                    if(
is_user_alive(id) && cs_get_user_team(id) & CS_TEAM_CT && get_user_flags(id) & ADMIN_KICK )
                    {
                        
set_user_scoreattrib(id,4)
                    }
                }
            }
            
remove_task(1337)
            for(new 
id 1id <= g_MaxPlayersid++)
            {
                
remove_task(TASK_PLAYERFREE+id);
                if(
is_user_connected(id))
                    
set_user_rendering(id)
            }
        }
    }
    return 
PLUGIN_HANDLED
}    
public 
startround()
{
    
admin_gave_freeday 0
    
if(g_its_freeday)
    {
        
free_for_all()
        
client_print(0,print_chat,"%L"LANG_PLAYER"TIME_TO_FREEDAY")
    }
    new 
count_down g_had_freeround get_pcvar_num(g_vote_round_number) +g_rounds
    
if(g_had_freeround get_pcvar_num(g_vote_round_number) +g_rounds || !count_down)
    {
        
client_print(0,print_chat,"%L"LANG_PLAYER"CAN_VOTE_AGAIN")
        
can_vote 1
        g_vote_canceled 
0
        
for( new idid<g_MaxPlayers;id++ )
        {
            
g_Vote_Player[id] = false
        
}
    }
}
public 
endround()
{
    
we_have_a_leader 0
    g_printed 
0
    
    
for(new id 1id <= g_MaxPlayersid++)
    {
        
g_player_is_leader[id] = false;
    }
    if(
g_its_freeday)
    {
        if(!
g_let_be_freeday)
        {
            
g_its_freeday 0
        
}
    }
}
public 
free_for_all()
{
    
can_vote 0
    g_let_be_freeday 
0
    g_had_freeround 
g_rounds
    
for(new id 1id <= g_MaxPlayersid++)
    {
        
g_Vote_Player[id] = false
        
if(is_user_alive(id) && cs_get_user_team(id) & CS_TEAM_T)
        {
            
remove_task(TASK_PLAYERFREE+id)
            new 
num1 random_num(0,255)
            new 
num2 random_num(0,255)
            new 
num3 random_num(0,255)
            
set_user_rendering(id,kRenderFxGlowShell,num1,num2,num3,kRenderNormal,40)
        }
    }
}
stock set_user_scoreattrib(id,attrib=0)
{
    
message_begin(2,get_user_msgid("ScoreAttrib"),{0,0,0},0);
    
write_byte(id);
    
write_byte(attrib);
    
message_end();

ML if you need to read the messages or .. idk

Code:
[en]
NO_LEADER = You are not the leader, only the leader has access to this command.
NO_ADMIN = Only admins have access to this command.
MENU_HEADER = Freeday for?
FFA = Freeday for all
REMOVE = Remove a Freeday
ADMIN_FFA = Admin %s gave Freeday to ALL
ADMIN_FFP = Admin %s gave Freeday to %s
MENU_HEADER_UNFREE = Choose the UNFree-Player
FREEDAY_MENU = Freeday Menu
NO_CT = You are a terrorist, you have no access to this command.
ADMIN_TOOK = Admin : %s took Freeday of %s
ADMIN_FFA_HUD = Admin : %s gave Freeday to ALL
VOTE_RUNING = here is already a vote going.
VOTE_HEADER = Freeday for all?
FFA_YES = Yes
FFA_NO = No
FIRST_OPTION = Option YES recieved most votes (%d) - Freeday for all ? - YES
TIME_TO_FREEDAY = Its now time to have a FREEDAY.
SECUND_OPTION = Option NO recieved most votes (%d) - Freeday for all ? - NO
TIED_OPTION = Choices were tied for first.Vote has been canceled.
VOTE_OFF = The vote option is OFF. you can not vote for a freeday!
ALREADY_VOTED = I know you want a freeday.
ROCKED_THE_DAY = You rocked the day.
VOTE_COUNTS = %d more players need to ^"rocktheday^" to start the vote.
ENOUGH_VOTED = Enough players has rocked the day that a vote for the next round will now begin.
NEW_FREEDAY = Next round is FREEDAY FOR ALL!
CAN_VOTE_AGAIN = Freeday voting is now enabled!
WAIT_FOR_ROUND = You have to wait %d more round(s) to vote again.
ALREADY_FREEDAY = You cannot vote on Freeday for a Freeday!
IS_LEADER = %s is the Leader
VOTED_FOR_YES = %s voted for option YES
VOTED_FOR_NO = %s voted for option NO
FIRST_ROUND = You cannot vote in the first round!
NEXT_ROUND = You dont need to rock the day. Next round is a Freeday!
MENU_1 = \rJailmod Freeday Manager \d1.0.2b by \rOne^n
MENU_2 = \w---------------------------------^n
MENU_3 = \wOption \rVote for Freeday\w is active.^n
MENU_4 = \wOption \rVote for Freeday\w is deactive.^n
MENU_5 = \wOption \rVIP for admins\w is active.^n
MENU_6 = \wOption \rVIP for admins\w is deactive.^n
MENU_7 = \wOption \rShowing the votes\w is active.^n
MENU_8 = \wOption \rShowing the votes\w is deactive.^n
MENU_9 = \wOnly \rAdmins\w can use the Freeday menu.^n
MENU_10 = \wOnly \rAdmins and Leader\w can user the Freeday menu.^n
MENU_11= \wEvery \r%d round(s)\w you can vote for Freeday.^n
MENU_12 = \w---------------------------------^n
MENU_13 = \wSay \r/rtd \wto \rRock the day^n
MENU_14 = \wSay \r/freeday \was \rLeader\w to use the menu.^n
MENU_15 = \w---------------------------------^n
MENU_16 = \wCredits @ One @ Fragaholics.de
HNS = Hide'n'Seek
Seektime = [Hide'n'Seek] Ts, you've got %d seconds to get hidden!
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-27-2010 , 10:38   Re: default case problem
Reply With Quote #4

PHP Code:
    if( item MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    


PHP Code:
    if( item == MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    

Also, you are assigning menu data indexes for 1-4 and then you loop through players using the player id as the menu data so you will end up having duplicates when\if players on CS_TEAM_T are on server with id's 1-4.
__________________
Bugsy is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-27-2010 , 10:42   Re: default case problem
Reply With Quote #5

oh. i will try this one.
i changed my way to add extra a new menu for players names. but if this works, i will use this one again

@ writing again the full code
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-27-2010 , 10:57   Re: default case problem
Reply With Quote #6

Quote:
Originally Posted by One View Post
oh. i will try this one.
i changed my way to add extra a new menu for players names. but if this works, i will use this one again

@ writing again the full code
Just so you understand why it was not working with the bit-wise AND check.

In your callback, variable 'item' returns 0-X, first item being 0 and so on. Below are the bit representations for each. If atleast one of the bits matched in MENU_EXIT and item, the code was stopped at your if ( item & MENU_EXIT ) check. You noticed that only 1 and 3 worked, below shows why.

Code:
11111111111111111111111111111101 MENU_EXIT == -3

00000000000000000000000000000000 Item 0 Data="1" Works
00000000000000000000000000000001 Item 1 Data="2" Does not work
00000000000000000000000000000010 Item 2 Data="3" Works
00000000000000000000000000000011 Item 3 Data="4" Does not work
__________________

Last edited by Bugsy; 03-27-2010 at 11:04.
Bugsy is offline
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-27-2010 , 11:54   Re: default case problem
Reply With Quote #7

haha this was so easy .... :-)))

n1 explanation . ty bugsy
__________________
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
One
Veteran Member
Join Date: Oct 2008
Location: Hardstyle-eSports.de
Old 03-29-2010 , 12:25   Re: default case problem
Reply With Quote #8

so again a menu problem.

i added a menu to give freedays and this works without any problems..
after i give a player FREEDAY, i set is_user_free[id] on TRUE.


in removings menu i have a loop to show all users to remove the freeday.

and i check
if(is_user_free[tempid])
then add menu item... but i get only wrong resaults


PHP Code:
public remove_glow(id)
{
    static 
szMenuName[64]
    
formatex(szMenuName63"\y%L"id"MENU_HEADER_REMOVE")
    new 
menu menu_create(szMenuName"Remove_Freedays")    
    
    
formatex(szMenuNamecharsmax(szMenuName), "\w%L"id"MENU_MAIN_MENU");
    
menu_additem(menu,szMenuName"1",id);
    new 
g_tempid
    
new players[32]
    new 
szName[32], szTempid[10]; 
    new 
pnum
    get_players
(playerspnum)
    new 
count 0
    
for(new ii<pnumi++ ) 
    {
        
g_tempid players[i]
        if(
is_user_free[g_tempid] && is_user_alive(g_tempid))
        {
            
count++
            
get_user_name(g_tempidszName31)
            
num_to_str(g_tempidszTempid9
            
menu_additem(menuszNameszTempid0)
        }
    } 
    if(
This_is_a_FFA_round)
    {
        
formatex(szMenuNamecharsmax(szMenuName), "\d%L"id"MENU_ITS_FFA");
        
menu_additem(menu,szMenuName"0",id);
    }
    else if(
count == 0)
    {
        
formatex(szMenuNamecharsmax(szMenuName), "\d%L"id"MENU_NO_FREEDAY");
        
menu_additem(menu,szMenuName"0",id);
    }
    
menu_display(idmenu,0); 
    return 
PLUGIN_HANDLED

add freeday and change is_user_free to true :

PHP Code:
switch(f_tempid)
    {
        case 
1:
        {
            
show_the_menu(id)
        }
        default:
        {
            if(
is_user_alive(f_tempid))
            {
                new 
name1[33] , name[33]
                
get_user_name(f_tempid,name1,32)
                
get_user_name(id,name,32)                
                
ChatColor(0"%L"LANG_PLAYER,"PRINT_PLAYER_FREE"tag,name,name1)
                
ChatColor(f_tempid"%L"LANG_PLAYER,"PRINT_YOU_FREE"tag,name)
                
set_task(0.5,"Player_Freeday",TASK_PLAYERFREE+f_tempid,"",0,"b")
                
show_player_menu_for_freeday(id)
                
is_user_free[f_tempid] = true
            
}
            else
            {
                new 
name1[33]
                
get_user_name(f_tempid,name1,32)
                
ChatColor(id"%L"LANG_PLAYER,"ERROR_NOT_ALIVE"tag,name1)
            }
        }
        
    } 
__________________

Last edited by One; 03-29-2010 at 12:29.
One is offline
Send a message via ICQ to One Send a message via AIM to One Send a message via MSN to One Send a message via Yahoo to One Send a message via Skype™ to One
Reply



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 21:12.


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