| #8 SickneSS |
07-14-2010 11:58 |
Re: Making a menu to two differents index?
Thanks wreked,I made the first way,here is the code..(Sorry if is redundant,it's the first time I made something like this...)
Compiles good but don't show the menu
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #include <fakemeta> #include <hamsandwich>
#define PLUGIN "Knife Fight" #define VERSION "1.0" #define AUTHOR "#8 SickneSS"
/* Players */ new MaxPlayers
/* Players Index */ new Winner new Looser new iIndexz
/* Booleans */ new bool:KnifeFight new bool:Choosing[33]
/* Buy Commands */ /*By fezh */ new BuyCommands[][] = { "usp", "glock", "deagle", "p228", "elites", "fn57", "m3", "xm1014", "mp5", "tmp", "p90", "mac10", "ump45", "ak47", "galil", "famas", "sg552", "m4a1", "aug", "scout", "awp", "g3sg1", "sg550", "m249", "vest", "vesthelm", "flash", "hegren", "sgren", "defuser", "nvgs", "shield", "primammo", "secammo", "km45", "9x19mm", "nighthawk", "228compact", "12gauge", "autoshotgun", "smg", "mp", "c90", "cv47", "defender", "clarion", "krieg552", "bullpup", "magnum", "d3au1", "krieg550", "buyammo1", "buyammo2" }
public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) /* Command */ register_clcmd("say /kf","cmdKnifeFight",ADMIN_CFG) /* Block Buy */ for (new i = 0; i < sizeof (BuyCommands); i++) register_clcmd(BuyCommands[i], "BlockBuyCommands") /* Event */ register_event("DeathMsg","EventDeathMsg","a") /* Ham Registration */ RegisterHam(Ham_Spawn,"player","HamSpawnPlayer",1) /* Players */ MaxPlayers = get_maxplayers() }
public cmdKnifeFight(id,level,cid) { if(!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED new name[32] get_user_name(id,name,31) KnifeFight = true client_print(0,print_chat,"ADMIN %s has make an knife fight",name) server_cmd("sv_restart 1") return PLUGIN_HANDLED }
public EventDeathMsg() { if(KnifeFight) { Winner = read_data(1) Looser = read_data(2) iIndexz = Winner+Looser if(Winner > MaxPlayers || cs_get_user_team(Winner) == cs_get_user_team(Looser)) return PLUGIN_HANDLED new szWeapon[20] szWeapon = get_user_weapon2(Winner) if(Winner != Looser && equal(szWeapon,"knife")) { Choosing[Winner] = true ShowMenu(iIndexz) } KnifeFight = false } return PLUGIN_HANDLED }
public HamSpawnPlayer(id) { if(KnifeFight) { if(is_user_connected(id)) { strip_user_weapons(id) ham_strip_weapon(id,"CSW_C4") give_item(id,"weapon_knife") give_item(id,"item_kevlar") } } }
public BlockBuyCommands(id) { if(KnifeFight) return PLUGIN_HANDLED return PLUGIN_CONTINUE }
public ShowMenu(iIndexz) { new Menu = menu_create("Choose a teammate","MenuHandler") new name[32] new item[32] new Players[32] new Num get_players(Players,Num) for(new i = 0;i < Num;i++) { if(is_user_connected(i) && cs_get_user_team(i) == CS_TEAM_SPECTATOR) { get_user_name(i,name,31) num_to_str(i,item,31) menu_additem(Menu,name,item,_,menu_makecallback("MenuCallback")) } }
new temp[51] if(Choosing[Winner] && Looser) { get_user_name(Winner,name,31) format(temp,50,"Waiting to %s",name) } else if(Choosing[Looser] && Winner) { get_user_name(Looser,name,31) format(temp,50,"Waiting to %s",name) } menu_setprop(Menu,MPROP_EXITNAME,temp) if(Choosing[Winner] || Choosing[Looser]) menu_setprop(Menu,MPROP_EXITNAME,"Random") menu_display(iIndexz,Menu) } public MenuCallback(iIndexz,Menu,item) { if(Choosing[Winner] && Looser) return ITEM_DISABLED else if(Choosing[Looser] && Winner) return ITEM_DISABLED return ITEM_ENABLED } public MenuHandler(iIndexz,Menu,item) { new name[32] if(item == MENU_EXIT) { if(Choosing[Winner]) { get_user_name(Winner,name,31) RandomPlayer(Winner) client_print(0,print_chat,"%s has made a random choice",name) } else if(Choosing[Looser]) { get_user_name(Looser,name,31) RandomPlayer(Looser) client_print(0,print_chat,"%s has made a random choice",name) } } new iData[6] new iName[64] new Access new Callback menu_item_getinfo(Menu,item,Access,iData,5,iName,63,Callback) new Choosed = str_to_num(iData) if(Choosed && Winner) { get_user_name(Winner,name,31) cs_set_user_team(Choosed,cs_get_user_team(Winner)) client_print(0,print_chat,"%s has choosed %s",name,iName) Choosing[Winner] = false Choosing[Looser] = true } else if(Choosed && Looser) { get_user_name(Looser,name,31) cs_set_user_team(Choosed,cs_get_user_team(Looser)) client_print(0,print_chat,"%s has choosed %s",name,iName) Choosing[Winner] = true Choosing[Looser] = false } if(is_user_connected(iIndexz)) ShowMenu(iIndexz) }
stock RandomPlayer( Index ) /* By Bugsy */ { new Players[ 32 ] , Num , id; new bool:Checked[ 32 ] , NumChecked; get_players( Players , Num ); while ( NumChecked < Num) { id = Players[ random( Num ) ]; if( !Checked[ id ] ) { if ( ( id != Index ) && ( cs_get_user_team( id ) == CS_TEAM_SPECTATOR ) ) { cs_set_user_team( id , cs_get_user_team( Index ) ) break; } else { Checked[ id ] = true; NumChecked++; } } } } stock ham_strip_weapon(const id,const weapon[]) /* By XxAvalanchexX */ { if(!equal(weapon,"weapon_",7)) return 0; new wId = get_weaponid(weapon); if(!wId) return 0; new wEnt; while((wEnt = engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {} if(!wEnt) return 0; if(get_user_weapon(id) == wId) ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt); if(!ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0; ExecuteHamB(Ham_Item_Kill,wEnt); set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId)); if(wId == CSW_C4) { cs_set_user_plant(id,0,0); cs_set_user_bpammo(id,CSW_C4,0); } else if(wId == CSW_SMOKEGRENADE || wId == CSW_FLASHBANG || wId == CSW_HEGRENADE) cs_set_user_bpammo(id,wId,0); return 1; }
stock get_user_weapon2( id ) /* By xPaw */ { new szWeapon[20]; get_weaponname(get_user_weapon(id), szWeapon, charsmax(szWeapon)); replace(szWeapon, charsmax(szWeapon), "weapon_", ""); return szWeapon; }
|