Re: Give C4 Randomly
+Karma for the help. I am still having a little problem with the C4. It is doing like it should in giving the c4 but when i get to the bomb site A and B its telling me that i must be in a bomb site to plant. It will not allow me to plant? I dont understand. I had disabled the buy menu and it removes the Icon indicator. i wounder if that is removing the bomb plant site entity as well? here is my full code for the plugin.
PHP Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fakemeta> #include <fakemeta_util> #include <fun> #include <hamsandwich> #include <nvault> #define PLUGIN "COD4" #define VERSION "1.0" #define AUTHOR "<GT>LINK" #define CLASS_NOTHING 0 #define CLASS_ASSUALT 1 #define CLASS_DEMO 4 #define CLASS_HEAVYG 3 #define CLASS_SNIPER 5 #define CLASS_SPECOPS 2 #define MAXCLASSES 6 #define MAXRANK 55 new PlayerRank[33] new PlayerClass[33] new PlayerXP[33] new PlayerLevel[33] new g_vault new g_msgStatusIcon new iPlayers[32] new iNum new const CLASSES[MAXCLASSES][] = { "None", "Assault", "Spec Ops", "Heavy Gunner", "Demolitions", "Sniper" } new const RANK[MAXRANK][] = { "Private First Class", "Private First Class I", "Private First Class II", "Lance Corporal", "Lance Corporal I", "Lance Corporal II", "Corporal", "Corporal I", "Corporal II", "Sargeant", "Sargeant I", "Sargeant II", "Staff Sargeant", "Staff Sargeant I", "Straff Sargeant II", "Gunnery Sargeant", "Gunnery Sargeant I", "Gunnery Sargeant II", "Master Sargeant", "Master Sargeant I", "Master Sargeant II", "Master Gunnery Sergeant", "Master Gunnery Sergeant I", "Master Gunnery Sergeant II", "2nd Lieutenant", "2nd Lieutenant I", "2nd Lieutenant II", "1st Lieutenant", "1st Lieutenant I", "1st Lieutenant II", "Captain", "Captain I", "Captain II", "Major", "Major I", "Major II", "Lt. Colonel", "Lt. Colonel I", "Lt. Colonel II", "Colonel", "Colonel I", "Colonel II", "Brigadier General", "Brigadier General I", "Brigadier General II", "Major General", "Major General I", "Major General II", "Lieutenant General", "Lieutenant General I", "Lieutenant General II", "General", "General I", "General II", "Commander" } new msgtext new const LEVELS[55] = { 0, 30, 120, 270, 480, 750, 1080, 1470, 1920, 2430, 3000, 3650, 4380, 5190, 6080, 7050, 8100, 9230, 10440, 11730, 13100, 14550, 16080, 17690, 19380, 21150, 23000, 24930, 26940, 29030, 31240, 33570, 36020, 38590, 41280, 44090, 47020, 50070, 53240, 56530, 59940, 63470, 67120, 70890, 74780, 82920, 87170, 91540, 96030, 100640, 105370, 110220, 115190, 120280 } public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) register_cvar("sv_cod4", "1") register_event("DeathMsg", "DeathMsg", "a") register_cvar("XP_per_kill", "30") register_cvar("XP_Bomb", "15") register_cvar("XP_BDefuse", "15") register_cvar("XP_Xplode", "20") register_cvar("Min_players_XP", "1") register_cvar("XP_HS", "10") register_cvar("SaveXP","1") register_menucmd(register_menuid("menu_ChooseClass"),1023,"DoChooseClass"); register_event("ResetHUD", "ResetHud", "b") msgtext = get_user_msgid("StatusText") register_clcmd("say /changeclass", "ChooseClass") register_clcmd("say_team /changeclass", "ChooseClass") register_clcmd("say /class", "ShowClass") register_clcmd("say /rank", "ShowRank") g_vault = nvault_open("cod4") g_msgStatusIcon = get_user_msgid("StatusIcon") register_message(g_msgStatusIcon, "msgStatusIcon") } public msgStatusIcon(msgid, msgdest, id) { static szIcon[8]; get_msg_arg_string(2, szIcon, 7); if(equal(szIcon, "buyzone") && get_msg_arg_int(1)) { set_pdata_int(id, 235, get_pdata_int(id, 235) & ~(1<<0)); return PLUGIN_HANDLED; } return PLUGIN_CONTINUE; } public SaveData(id) { new AuthID[35]; get_user_authid(id,AuthID,34) new vaultkey[64],vaultdata[256] format(vaultkey,63,"%s-Mod",AuthID) format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerRank[id]) nvault_set(g_vault,vaultkey,vaultdata) return PLUGIN_CONTINUE } public LoadData(id) { new AuthID[35] get_user_authid(id,AuthID,34) new vaultkey[64],vaultdata[256] format(vaultkey,63,"%s-Mod",AuthID) format(vaultdata,255,"%i#%i#%i#",PlayerXP[id],PlayerLevel[id],PlayerRank[id]) nvault_get(g_vault,vaultkey,vaultdata,255) replace_all(vaultdata, 255, "#", " ") new playerxp[32], playerlevel[32], playerrank[32]; parse(vaultdata, playerxp, 31, playerlevel, 31) PlayerXP[id] = str_to_num(playerxp) PlayerLevel[id] = str_to_num(playerlevel) PlayerRank[id] = str_to_num(playerrank) return PLUGIN_CONTINUE } public client_connect(id) { if(get_cvar_num("SaveXP") == 1) { LoadData(id) client_print(id, print_chat, "[Call of Duty 4] XP Loaded!") client_print(id, print_chat, "[Call of Duty 4] You are a %s with level %s and %s XP", PlayerClass[id], PlayerLevel[id], PlayerXP[id], PlayerRank[id]) } } public client_disconnect(id) { if(get_cvar_num("SaveXP") == 1) { SaveData(id) } } public ChooseClass(id) { new menu[] = "Call Of Duty 4: Choose Class^n^n1. Assault^n2. Spec Ops^n3. Heavy Gunner^n4. Demolitions^n5. Sniper"; new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5; show_menu(id, keys, menu, -1, "menu_ChooseClass") return PLUGIN_CONTINUE } public DoChooseClass(id, key) { if(key == 0) { if(PlayerClass[id] == CLASS_ASSUALT) { client_print(id, print_chat, "[Call of Duty 4] You are allready a Assault! Choose something else!") ChooseClass(id) return PLUGIN_HANDLED } PlayerClass[id] = CLASS_ASSUALT cs_set_user_money(id, 0); fm_strip_user_weapons(id); fm_give_item(id, "weapon_knife"); fm_give_item(id, "weapon_m4a1"); fm_give_item(id, "ammo_556nato"); fm_give_item(id, "weapon_glock18"); fm_give_item(id, "ammo_9mm"); client_print(id, print_chat, "[Call of Duty 4] You are now Assault Class!") } if(key == 3) { if(PlayerClass[id] == CLASS_DEMO) { client_print(id, print_chat, "[Call of Duty 4] You are allready Demolitions! Choose something else!") ChooseClass(id) return PLUGIN_HANDLED } PlayerClass[id] = CLASS_DEMO cs_set_user_money(id, 0); fm_strip_user_weapons(id); fm_give_item(id, "weapon_knife"); fm_give_item(id, "weapon_m3"); fm_give_item(id, "ammo_buckshot"); fm_give_item(id, "weapon_glock18"); fm_give_item(id, "ammo_9mm"); fm_give_item(id, "weapon_c4"); client_print(id, print_chat, "[Call of Duty 4] You are now Demolitions!") } if(key == 2) { if(PlayerClass[id] == CLASS_HEAVYG) { client_print(id, print_chat, "[Call of Duty 4] You are allready a Heavy Gunner! Choose something else!") ChooseClass(id) return PLUGIN_HANDLED } PlayerClass[id] = CLASS_HEAVYG cs_set_user_money(id, 0); fm_strip_user_weapons(id); fm_give_item(id, "weapon_knife"); fm_give_item(id, "weapon_m249"); fm_give_item(id, "ammo_556natobox"); fm_give_item(id, "weapon_glock18"); fm_give_item(id, "ammo_9mm"); client_print(id, print_chat, "[Call of Duty 4] You are now a Heavy Gunner!") } if(key == 4) { if(PlayerClass[id] == CLASS_SNIPER) { client_print(id, print_chat, "[Call of Duty 4] You are allready a Sniper! Choose something else!") ChooseClass(id) return PLUGIN_HANDLED } PlayerClass[id] = CLASS_SNIPER cs_set_user_money(id, 0); fm_strip_user_weapons(id); fm_give_item(id, "weapon_knife"); fm_give_item(id, "weapon_scout"); fm_give_item(id, "ammo_762nato"); fm_give_item(id, "weapon_glock18"); fm_give_item(id, "ammo_9mm"); client_print(id, print_chat, "[Call of Duty 4] You are now a Sniper!") } if(key == 1) { if(PlayerClass[id] == CLASS_SPECOPS) { client_print(id, print_chat, "[Call of Duty 4] You are allready Spec Ops! Choose something else!") ChooseClass(id) return PLUGIN_HANDLED } PlayerClass[id] = CLASS_SPECOPS cs_set_user_money(id, 0); fm_strip_user_weapons(id); fm_give_item(id, "weapon_knife"); fm_give_item(id, "weapon_mp5navy"); fm_give_item(id, "ammo_9mm"); fm_give_item(id, "weapon_glock18"); fm_give_item(id, "ammo_9mm"); client_print(id, print_chat, "[Call of Duty 4] You are now Spec Ops!") } get_players( iPlayers, iNum ) new id for( new i = 0; i < iNum; i++ ) { id = iPlayers[i] if( is_user_alive( id ) && cs_get_user_team( id ) == CS_TEAM_T ) { give_item( id, "weapon_c4" ) break; } } } public ResetHud(id) { if(PlayerClass[id] == CLASS_NOTHING) { ChooseClass(id) return PLUGIN_HANDLED } return PLUGIN_HANDLED } public DeathMsg() { if(get_cvar_num("sv_cod4") == 0) { return PLUGIN_HANDLED } if(get_playersnum() < get_cvar_num("Min_players_XP")) { return 0; } new attacker = read_data(1) new headshot = read_data(3) if(PlayerClass[attacker] == CLASS_NOTHING) { return PLUGIN_HANDLED } if(PlayerLevel[attacker] == 50) { return PLUGIN_HANDLED } PlayerXP[attacker] += get_cvar_num("XP_per_kill") if(headshot) PlayerXP[attacker] += get_cvar_num("XP_HS") if(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]]) { PlayerLevel[attacker] += 1 client_print(attacker, print_chat, "[Call of Duty 4] Congratulations! You are now level %i!", PlayerLevel[attacker]) if(get_cvar_num("SaveXP") == 1) { SaveData(attacker) } ShowHUD(attacker) } ShowHUD(attacker) return PLUGIN_CONTINUE } public ShowHUD(id) { new HUD[51] format(HUD, 50, "[%s]Level: %i XP: %i", RANK[PlayerClass[id]], PlayerLevel[id], PlayerXP[id], PlayerRank[id]) message_begin(MSG_ONE, msgtext, {0,0,0}, id) write_byte(0) write_string(HUD) message_end() return PLUGIN_CONTINUE } public ShowClass(id) { new HUDS[61] format(HUDS, 60, "[%s]Level: %i XP: %i", CLASSES[PlayerClass[id]], PlayerLevel[id], PlayerXP[id], PlayerRank[id]) message_begin(MSG_ONE, msgtext, {0,0,0}, id) write_byte(0) write_string(HUDS) message_end() return PLUGIN_CONTINUE } public ShowRank(id) { new HUDD[71] format(HUDD, 70, "[%s]Level: %i XP: %i", RANK[PlayerClass[id]], PlayerLevel[id], PlayerXP[id], PlayerRank[id]) message_begin(MSG_ONE, msgtext, {0,0,0}, id) write_byte(0) write_string(HUDD) message_end() return PLUGIN_HANDLED }
|