|
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
|

05-30-2009
, 09:11
Re: Need help with menu and fm_give_item
|
#8
|
PHP Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <cstrike> #include <hamsandwich>#define PRIMARY_WEAPONS_BIT_SUM ((1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)) #define SECONDARY_WEAPONS_BIT_SUM ((2<<CSW_P228)|(2<<CSW_ELITE)|(2<<CSW_FIVESEVEN)|(CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE)) #define SECONDARY_WEAPONS_BIT_USE (1<<CSW_USP|1<<CSW_DEAGLE|1<<CSW_P228|1<<CSW_DEAGLE|1<<CSW_GLOCK18|1<<CSW_ELITE) #define UsingSecondaryWeapon(%1) ((1<<get_user_weapon(%1)) & SECONDARY_WEAPONS_BIT_USE) #define MENU_STARTID g_menu_data[id][2]new g_menu_data[33][8];#define MAXLEVEL 20 new const GUNNAME[MAXLEVEL][] = { "Glock 18C", "USP .45 ACP Tactical", "P228 Compact", "FiveseveN", "Desert Eagle .50 AE", "Dual Elite Berettas", "Schmidt TMP", "Ingram MAC-10", "UMP 45", "MP5 Navy", "ES P90", "Famas", "IMI Galil", "M3 Super 90", "AK-47", "M4A1 Carbine", "Steyr AUG A1", "SG-552 Commando", "SG-550 Auto-Sniper", "G3SG1 Auto-Sniper", "M249 Para Machinegun" }; // Weapon Name Ranksnew const LEVELS[MAXLEVEL] = { 100, 300, 600, 1000, 1500, 2100, 2800, 3600, 4500, 5500, 6600, 7800, 9100, 10500, 12000, 13600, 15400, 17300, 32300, 50600, 150000 }; // Levels XPnew const RANK[MAXLEVEL][] = { "Warrior", "Warrior", "Warrior", "Warrior", "Mega Natural", "Mega Natural", "Mega Natural", "Runner", "Runner", "Runner", "Hunter", "Hunter", "Hunter", "Dark Lord", "Dark Lord", "Dark Lord", "Electric", "Electric", "Electric", "Mystic Jumper", "Mystic Jumper" }; // Players Ranksnew const levelup[] = { "msx/levelup.wav" } new PlayerXP[33], PlayerLevel[33], iKills[33] new XP_Kill, SaveXP new g_MaxPlayers new g_maxplayers new death_msg_enable new PlayerHumanKills[33] new PlayerZombieKills[33] new PlayerHumanDeaths[33] new PlayerZombieDeaths[33]const KEYSMENU = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9) //============================================================// // ~[ Sounds/Waves ]~ // //============================================================// new const music1[][] = { "msx/brains1.wav", "msx/brains2.wav", "msx/brains3.wav", "msx/brains4.wav" } new const music2[][] = { "msx/brains5.wav", "msx/brains6.wav", "msx/brains7.wav", "msx/brains8.wav", "msx/brains9.wav", "msx/brains10.wav", "msx/brains11.wav", "msx/brains12.wav" } //============================================================// // ~[ Plugin Start ]~ // //============================================================// public plugin_precache() { register_forward(FM_Spawn, "fwdSpawn"); register_forward(FM_Touch,"fwTouch"); g_MaxPlayers = get_maxplayers(); } public plugin_init() { register_plugin("Left 4 Dead XP", "1.4", "xFrost") // Events // register_event("DeathMsg", "event_deathmsg", "a") // Forwards // RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1) // Cvars // SaveXP = register_cvar("SaveXP", "1") XP_Kill = register_cvar("XP_per_kill", "7") death_msg_enable = register_cvar("l4d_dmsg","1") // Comands // register_clcmd("say level", "ShowLevel") register_clcmd("say /level", "ShowLevel") // Other // register_dictionary("l4d.txt"); } public event_deathmsg() { new g_attacker = read_data(1); new g_victim = read_data(2) new attacker_msg[32] new victim_msg[32] get_user_name(g_attacker, attacker_msg, 31) get_user_name(g_victim, victim_msg, 31) PlayerXP[g_attacker] += get_pcvar_num(XP_Kill) set_hudmessage(0, 255, 50, 0.50, 0.33, 1, 2.0, 2.1) show_hudmessage(g_attacker, "%L", LANG_SERVER, "KILL_XP", get_pcvar_num(XP_Kill)) while(PlayerXP[g_attacker] >= LEVELS[PlayerLevel[g_attacker]]) { PlayerLevel[g_attacker] += 1 client_cmd(g_attacker, "spk %s", levelup) client_printcolor(g_attacker, "/ctr%s /yreaches level /g%i!", PlayerLevel[g_attacker]) } if(PlayerXP[g_attacker] <= 34980) { PlayerXP[g_attacker] += get_pcvar_num(XP_Kill) } if (get_user_team(g_attacker) == 2) // ct killed t { if((1 <= g_attacker <= g_maxplayers)) { iKills[g_attacker]++; } if(get_pcvar_num(death_msg_enable) == 1) { set_hudmessage(0, 5, 255, 0.01, 0.31, 1, 0.01, 3.0, 0.01, 0.01, 2) show_hudmessage(0, "%s has been owned by %s!", victim_msg, attacker_msg) client_cmd( 0, "spk %s", music2[random_num(0,sizeof music2 - 1)]) } PlayerZombieDeaths[g_victim] += 1 PlayerZombieKills[g_attacker] += 1 } if (get_user_team(g_attacker) == 1) // t killed ct { if(get_pcvar_num(death_msg_enable) == 1) { set_hudmessage(255, 0, 10, 0.01, 0.21, 1, 0.01, 3.0, 0.01, 0.01, 3) show_hudmessage(0, "%s's brains has been eaten by %s!", victim_msg, attacker_msg) client_cmd( 0, "spk %s", music1[random_num(0,sizeof music1 - 1)]) } PlayerHumanDeaths[g_victim] += 1 PlayerHumanKills[g_attacker] += 1 } ShowLevel(g_attacker) SaveLevel(g_attacker) } public ShowLevel(id) { client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT", PlayerLevel[id],PlayerXP[id],LEVELS[PlayerLevel[id]]) client_printcolor(id, "%L", LANG_SERVER, "LEVEL_TEXT2", GUNNAME[PlayerLevel[id]],RANK[PlayerLevel[id]]) } public client_connect(id) { if(get_cvar_num("SaveXP") == 1) { LoadLevel(id) client_printcolor(0, "%L", LANG_SERVER, "XP_LOADED") } } public client_disconnect(id) { if(get_pcvar_num(SaveXP) == 1) { SaveLevel(id) } PlayerXP[id] = 0 PlayerLevel[id] = 0 } public SaveLevel(id) { new authid[32]; get_user_authid(id,authid,31); new vaultkey[64], vaultdata[64]; format(vaultkey,63,"ANIMAL-%s-xp",authid); format(vaultdata,63,"%d",PlayerXP[id]); set_vaultdata(vaultkey,vaultdata); format(vaultkey,63,"ANIMAL-%s-level",authid); format(vaultdata,63,"%d",PlayerLevel[id]); set_vaultdata(vaultkey,vaultdata); } public LoadLevel(id) { new authid[32]; get_user_authid(id,authid,31); new vaultkey[64], vaultdata[64]; format(vaultkey,63,"ANIMAL-%s-xp",authid); get_vaultdata(vaultkey,vaultdata,63); PlayerXP[id] = str_to_num(vaultdata); format(vaultkey,63,"ANIMAL-%s-level",authid); get_vaultdata(vaultkey,vaultdata,63); PlayerLevel[id] = str_to_num(vaultdata); } //============================================================// // ~[ No Pickup Weapons]~ // //============================================================// public fwTouch( ent , id ) { if ( !( 1 <= id <= g_MaxPlayers ) || !pev_valid( ent ) || !( pev( ent , pev_flags ) & FL_ONGROUND ) ) return FMRES_IGNORED; //This will block picking up all weapons except backpack (c4) static szEntModel[32]; pev( ent , pev_model , szEntModel , 31 ); return equal( szEntModel , "models/w_backpack.mdl" ) ? FMRES_IGNORED : FMRES_SUPERCEDE; } //============================================================// // ~[ No Buy ]~ // //============================================================// public fwdSpawn(iEnt) { static s_szClassName[32]; pev(iEnt, pev_classname, s_szClassName, 31); if (equal(s_szClassName, "func_buyzone")) return FMRES_SUPERCEDE; return FMRES_IGNORED; } //============================================================// // ~[ FM Give Item ]~ // //============================================================// public fw_PlayerSpawn_Post(id) { set_task(0.1, "show_menu_level", id); } public show_menu_level(id) { if ( !is_user_alive(id) ) return; static menu[510], len, class; len = 0; new xKeys = MENU_KEY_0; new max = min(MENU_STARTID+7, sizeof (LEVELS)); new iPosNum = 0; // Title len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "PLAYER_INFO", PlayerLevel[id], PlayerXP[id], LEVELS[PlayerLevel[id]]) // 1-7. Class List for (class = MENU_STARTID; class < max; class++) { if ( PlayerLevel[id] < class) { len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "INACTIVE_LEVEL", ++iPosNum, GUNNAME[class], class) } else { xKeys |= (1<<iPosNum++); len += formatex(menu[len], sizeof menu - 1 - len, "%L", LANG_SERVER, "ACTIVE_LEVEL", class-MENU_STARTID+1, GUNNAME[class], class) } } if ( MENU_STARTID != 0 && MENU_STARTID != 21 ) { xKeys |= (1<<7) xKeys |= (1<<8) len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L^n\r9.\w %L^n^n\r0.\w %L", id, "BACK_MENU", id, "NEXT_MENU", id, "EXIT_MENU") } else if ( MENU_STARTID == 0 ) { xKeys |= (1<<8) len += formatex(menu[len], sizeof menu - 1 - len, "^n\r9.\w %L^n^n\r0.\w %L", id, "NEXT_MENU", id, "EXIT_MENU") } else if ( MENU_STARTID == 21 ) { xKeys |= (1<<7) len += formatex(menu[len], sizeof menu - 1 - len, "^n\r8.\w %L^n^n\r0.\w %L", id, "BACK_MENU", id, "EXIT_MENU") } switch(key) { case 0:{ drop_secondary(id) fm_give_item(id, "weapon_glock18") fm_set_user_bpammo(id, CSW_GLOCK18, 100) } case 1:{ drop_secondary(id) fm_give_item(id, "weapon_usp") fm_set_user_bpammo(id, CSW_USP, 100) } case 2:{ drop_secondary(id) fm_give_item(id, "weapon_p228") fm_set_user_bpammo(id, CSW_P228, 52) } case 3:{ drop_secondary(id) fm_give_item(id, "weapon_fiveseven") fm_set_user_bpammo(id, CSW_FIVESEVEN, 100) } case 4:{ drop_secondary(id) fm_give_item(id, "weapon_deagle") fm_set_user_bpammo(id, CSW_DEAGLE, 35) } case 5:{ drop_secondary(id) fm_give_item(id, "weapon_elite") fm_set_user_bpammo(id, CSW_ELITE, 120) } case 6:{ drop_primary(id) fm_give_item(id, "weapon_tmp") fm_set_user_bpammo(id, CSW_TMP, 120) } case 7:{ drop_primary(id) fm_give_item(id, "weapon_mac10") fm_set_user_bpammo(id, CSW_MAC10, 120) } case 8:{ drop_primary(id) fm_give_item(id, "weapon_ump45") fm_set_user_bpammo(id, CSW_UMP45, 100) } case 9:{ drop_primary(id) fm_give_item(id, "weapon_mp5navy") fm_set_user_bpammo(id, CSW_MP5NAVY, 120) } case 10:{ drop_primary(id) fm_give_item(id, "weapon_p90") fm_set_user_bpammo(id, CSW_P90, 100) } case 11:{ drop_primary(id) fm_give_item(id, "weapon_famas") fm_set_user_bpammo(id, CSW_FAMAS, 90) } case 12:{ drop_primary(id) fm_give_item(id, "weapon_galil") fm_set_user_bpammo(id, CSW_GALIL, 90) } case 13:{ drop_primary(id) fm_give_item(id, "weapon_m3") fm_set_user_bpammo(id, CSW_M3, 32) } case 14:{ drop_primary(id) fm_give_item(id, "weapon_ak47") fm_set_user_bpammo(id, CSW_AK47, 90) } case 15:{ drop_primary(id) fm_give_item(id, "weapon_m4a1") fm_set_user_bpammo(id, CSW_M4A1, 90) } case 16:{ drop_primary(id) fm_give_item(id, "weapon_aug") fm_set_user_bpammo(id, CSW_AUG, 90) } case 17:{ drop_primary(id) fm_give_item(id, "weapon_sg552") fm_set_user_bpammo(id, CSW_SG552, 90) } case 18:{ drop_primary(id) fm_give_item(id, "weapon_sg550") fm_set_user_bpammo(id, CSW_SG550, 90) } case 19:{ drop_primary(id) fm_give_item(id, "weapon_g3sg1") fm_set_user_bpammo(id, CSW_G3SG1, 90) } case 20:{ drop_primary(id) fm_give_item(id, "weapon_m249") fm_set_user_bpammo(id, CSW_M249, 200) } } }//============================================================// // ~[ Stocks ]~ // //============================================================// stock client_printcolor(const id, const input[], any:...) { new msg[191], players[32], count = 1; vformat(msg,190,input,3); replace_all(msg,190,"/g","^4");// green clr replace_all(msg,190,"/y","^1");// orange clr replace_all(msg,190,"/ctr","^3");// team clr if (id) players[0] = id; else get_players(players,count,"ch"); for (new i=0;i<count;i++) if (is_user_connected(players[i])) { message_begin(MSG_ONE_UNRELIABLE, 76, _, players[i]); write_byte(players[i]); write_string(msg); message_end(); } }stock fm_set_user_bpammo(id, iWeapon, iAmount) { new iOffset; switch(iWeapon) { case CSW_AWP: iOffset = 377; case CSW_SCOUT, CSW_AK47, CSW_G3SG1: iOffset = 378; case CSW_M249: iOffset = 379; case CSW_FAMAS, CSW_M4A1, CSW_AUG, CSW_SG550, CSW_GALI, CSW_SG552: iOffset = 380; case CSW_M3, CSW_XM1014: iOffset = 381; case CSW_USP, CSW_UMP45, CSW_MAC10: iOffset = 382; case CSW_FIVESEVEN, CSW_P90: iOffset = 383; case CSW_DEAGLE: iOffset = 384; case CSW_P228: iOffset = 385; case CSW_GLOCK18, CSW_MP5NAVY, CSW_TMP, CSW_ELITE: iOffset = 386; case CSW_FLASHBANG: iOffset = 387; case CSW_HEGRENADE: iOffset = 388; case CSW_SMOKEGRENADE: iOffset = 389; case CSW_C4: iOffset = 390; default:return; } set_pdata_int(id, iOffset, iAmount); } stock fm_give_item(index, const item[]) { if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10)) return 0 new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item)) if (!pev_valid(ent)) return 0 new Float:origin[3] pev(index, pev_origin, origin) set_pev(ent, pev_origin, origin) set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN) dllfunc(DLLFunc_Spawn, ent) new save = pev(ent, pev_solid) dllfunc(DLLFunc_Touch, ent, index) if (pev(ent, pev_solid) != save) return ent engfunc(EngFunc_RemoveEntity, ent) return -1 } stock drop_secondary(id) { new weapons[32], num get_user_weapons(id, weapons, num) for (new i = 0; i < num; i++) { if (SECONDARY_WEAPONS_BIT_SUM & (2<<weapons[i])) { static wname[32] get_weaponname(weapons[i], wname, sizeof wname - 1) engclient_cmd(id, "drop", wname) } } } stock drop_primary(id) { new weapons[32], num get_user_weapons(id, weapons, num) for (new i = 0; i < num; i++) { if (PRIMARY_WEAPONS_BIT_SUM & (1<<weapons[i])) { static wname[32] get_weaponname(weapons[i], wname, sizeof wname - 1) engclient_cmd(id, "drop", wname) } } }
Edit: Oh aye, didn't fix anything, just showing identitation.
Last edited by SnoW; 05-30-2009 at 09:14.
|
|