BANNED
Join Date: May 2021
Location: https://t.me/pump_upp
|
08-03-2022
, 09:17
[ZP 50] Human Class Fire M4a1 Help
|
#1
|
Hello programmers.
A few hours ago I was trying to make a Human Class and its idea is when you start a new round you get an extra item ( Fire M4a1) but after many attempts it didn't work. The problem is that it does not give Fire M4a1 but rather Classic M4a1,
This is the code of Fire M4a1:
PHP Code:
/*----------------------------------------------------------------------------------------------------- [Fire M4A1 | Credits:] First Release v1.0 By ShaunCraft ------------------------------------------------------------------------------------------------------*/
/*-------------------------------------------=[Includes]=---------------------------------------------*/ #include <amxmodx> #include <cstrike> #include <fakemeta> #include <hamsandwich> #include <cs_ham_bots_api> #include <zp50_grenade_fire> #include <zp50_items> #include <zombieplague> #include <zp50_items> #define WEAPON_BITSUM ((1<<CSW_M4A1)) native remove_nukem4a1(id) native remove_frostm4a1(id) /*-------------------------------=[Variables, Conts, Defines & Cvars]=--------------------------------*/
new FM_V_MODEL[64] = "models/S_Surf_Zp/v_SS_Fire_M4a1.mdl" new FM_P_MODEL[64] = "models/S_Surf_Zp/p_fire_m4a1.mdl" new FM_W_MODEL[64] = "models/S_Surf_Zp/w_fire_m4a1.mdl"
new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 };
new cvar_custommodel, cvar_uclip, cvar_f_duration, cvar_oneround, cvar_dmgmultiplier new g_itemid, g_firem4[33], tracer_spr, g_maxplayers
#define is_user_valid_alive(%1) (1 <= %1 <= g_maxplayers && is_user_alive(%1))
/*---------------------------------------=[Plugin Register]=-----------------------------------------*/ public plugin_init() { // Register The Plugin register_plugin("[Ss] Extra: Fire M4A1", "1.3", "AsnoLa") register_cvar("zp_firem4a1", "1.3", FCVAR_SERVER|FCVAR_UNLOGGED); // Register Zombie Plague extra item g_itemid = zp_register_extra_item("Fire M4A1", 50, ZP_TEAM_HUMAN) // Death Msg register_event("DeathMsg", "Death", "a") register_event("CurWeapon", "event_CurWeapon", "b", "1=1") register_event("CurWeapon","checkWeapon","be","1=1") register_event("HLTV", "event_round_start", "a", "1=0", "2=0") register_event("CurWeapon", "fw_TraceAttack", "be", "1=1", "3>0") // Forwards register_forward(FM_SetModel, "fw_SetModel") register_forward(FM_CmdStart, "fw_CmdStart") // Ham TakeDamage RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage") RegisterHamBots(Ham_TakeDamage, "fw_TakeDamage") RegisterHam(Ham_Item_AddToPlayer, "weapon_m4a1", "fw_AddToPlayer") RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1) RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1) RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1) RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1) RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1) RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1) RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1) // Cvars cvar_dmgmultiplier = register_cvar("zp_firem4_dmg_multiplier", "2") // Elemental Damage Multipler cvar_custommodel = register_cvar("zp_firem4_custom_model", "1") // Custom Model (0 - Off | 1 - On) cvar_uclip = register_cvar("zp_firem4_unlimited_clip", "1") // Unlimited Clip (0 - Off | 1 - On) cvar_f_duration = register_cvar("zp_firem4_fire_time", "5") // Time will be burning cvar_oneround = register_cvar("zp_firem4_one_round", "0") // The Elemental should be 1 round? (1 - On | 0 - Off) g_maxplayers = get_maxplayers() }
public plugin_natives() { register_native("remove_firem4a1", "native_remove_firem4a1", 1) register_native("get_firem4a1", "native_get_firem4a1", 1) }
public native_get_firem4a1(id) { if(user_has_weapon(id, CSW_M4A1)) { drop_primary(id); } remove_nukem4a1(id) remove_frostm4a1(id) g_firem4[id] = true; }
public native_remove_firem4a1(id) { g_firem4[id] = false; }
/*------------------------------------------=[Precaches]=--------------------------------------------*/ public plugin_precache() { precache_model(FM_V_MODEL) precache_model(FM_P_MODEL) precache_model(FM_W_MODEL) tracer_spr = precache_model("sprites/xenobeam.spr") precache_sound("weapons/zoom.wav") }
/*---------------------------------------=[Bug Prevention]=-----------------------------------------*/ public client_connect(id) g_firem4[id] = false public client_disconnect(id) g_firem4[id] = false public Death() g_firem4[read_data(2)] = false public zp_fw_core_infect_post(id) g_firem4[id] = false public zp_fw_core_cure_post(id) g_firem4[id] = false
public event_round_start() { if(get_pcvar_num(cvar_oneround)) { for(new id = 1; id <= g_maxplayers; id++) g_firem4[id] = false } }
/*----------------------------------------=[Custom Model]=-------------------------------------------*/ public event_CurWeapon(id) { if (!is_user_valid_alive(id) || zp_core_is_zombie(id)) return PLUGIN_HANDLED new g_Weapon = read_data(2) if (g_Weapon == CSW_M4A1 && g_firem4[id] && get_pcvar_num(cvar_custommodel)) { set_pev(id, pev_viewmodel2, FM_V_MODEL) set_pev(id, pev_weaponmodel2, FM_P_MODEL) } return PLUGIN_CONTINUE }
/*----------------------------------------=[Unlimited Clip]=------------------------------------------*/ public checkWeapon(id) { new plrClip, plrAmmo, plrWeap[32], plrWeapId
plrWeapId = get_user_weapon(id, plrClip , plrAmmo) if (plrWeapId == CSW_M4A1 && g_firem4[id]) event_CurWeapon(id) else return PLUGIN_CONTINUE if (plrClip == 0 && get_pcvar_num(cvar_uclip)) { // If the user is out of ammo.. get_weaponname(plrWeapId, plrWeap, 31) give_item(id, plrWeap) engclient_cmd(id, plrWeap) // Get the name of their weapon engclient_cmd(id, plrWeap) engclient_cmd(id, plrWeap) } return PLUGIN_HANDLED }
public fw_AddToPlayer(wpn, id) { if(pev_valid(wpn) && is_user_connected(id) && pev(wpn, pev_impulse) == 324584) { g_firem4[id] = true set_pev(wpn, pev_impulse, 0) return HAM_HANDLED } return HAM_IGNORED }
/*-----------------------------------------=[World Model]=-------------------------------------------*/ public fw_SetModel(entity, model[]) { static szClassName[33]; pev(entity, pev_classname, szClassName, charsmax(szClassName)) if(!equal(szClassName, "weaponbox")) return FMRES_IGNORED; static owner, wpn owner = pev(entity, pev_owner) wpn = find_ent_by_owner(-1, "weapon_m4a1", entity) if(g_firem4[owner] && pev_valid(wpn)) { g_firem4[owner] = false set_pev(wpn, pev_impulse, 324584) engfunc(EngFunc_SetModel, entity, FM_W_MODEL) return FMRES_SUPERCEDE } return FMRES_IGNORED }
/*-----------------------------------------=[Take Damage]=-------------------------------------------*/ public fw_TakeDamage(victim, inflictor, attacker, Float:damage) { if(is_user_valid_alive(attacker) && !zp_core_is_zombie(attacker) && get_user_weapon(attacker) == CSW_M4A1 && g_firem4[attacker] && is_user_valid_alive(victim) && zp_core_is_zombie(victim)) { SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmgmultiplier)) switch(random_num(1,100)) { case 31..100: { zp_grenade_fire_set(victim, true) set_task(get_pcvar_float(cvar_f_duration),"removefire", victim) } } } } /*----------------------------------------=[Weapon Tracer]=------------------------------------------*/ public fw_TraceAttack(iEnt, iAttacker, Float:flDamage, Float:fDir[3], ptr, iDamageType) { if(!is_user_alive(iAttacker)) return
new g_currentweapon = get_user_weapon(iAttacker)
if(g_currentweapon != CSW_M4A1) return if(!g_firem4[iAttacker]) return
static Float:end[3] get_tr2(ptr, TR_vecEndPos, end) if(iEnt) { message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_DECAL) engfunc(EngFunc_WriteCoord, end[0]) engfunc(EngFunc_WriteCoord, end[1]) engfunc(EngFunc_WriteCoord, end[2]) write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)]) write_short(iEnt) message_end() } else { message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(TE_WORLDDECAL) engfunc(EngFunc_WriteCoord, end[0]) engfunc(EngFunc_WriteCoord, end[1]) engfunc(EngFunc_WriteCoord, end[2]) write_byte(GUNSHOT_DECALS[random_num (0, sizeof GUNSHOT_DECALS -1)]) message_end() } message_begin(MSG_BROADCAST, SVC_TEMPENTITY ) write_byte(TE_BEAMENTPOINT) write_short(iAttacker | 0x1000) engfunc(EngFunc_WriteCoord, end[0]) engfunc(EngFunc_WriteCoord, end[1]) engfunc(EngFunc_WriteCoord, end[2]) write_short(tracer_spr) write_byte(0) // framerate write_byte(0) // framerate write_byte(1) // life write_byte(23) // width write_byte(0)// noise write_byte(200)// r, g, b write_byte(80)// r, g, b write_byte(4)// r, g, b write_byte(200) // brightness write_byte(5) // speed message_end()
} /*----------------------------------=[Action on Choose the Item]=------------------------------------*/
public zp_fw_items_select_post(player, itemid) { if(itemid != g_itemid) return; if(user_has_weapon(player, CSW_M4A1)) { drop_primary(player); } remove_nukem4a1(player) remove_frostm4a1(player) ham_strip_weapon(player, "weapon_m4a1") give_item(player, "weapon_m4a1") cs_set_user_bpammo(player, CSW_M4A1, 90) g_firem4[player] = true; }
/*------------------------------------=[Remove fire]=-------------------------------------*/ public removefire(plr) { if(is_user_connected(plr)) zp_grenade_fire_set(plr, false) }
/*--------------------------------------------=[Stocks]=---------------------------------------------*/
stock find_ent_by_owner(index, const classname[], owner, jghgtype = 0) { new strtype[11] = "classname", ent = index; switch (jghgtype) { case 1: strtype = "target"; case 2: strtype = "targetname"; }
while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
return ent; }
stock set_user_weapon_anim(id, anim) { set_pev(id, pev_weaponanim, anim) message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, {0, 0, 0}, id) write_byte(anim) write_byte(pev(id, pev_body)) message_end() }
stock drop_primary(id) { new weapons[32], num; get_user_weapons(id, weapons, num); for (new i = 0; i < num; i++) { if (WEAPON_BITSUM & (1<<weapons[i])) { static wname[32]; get_weaponname(weapons[i], wname, sizeof wname - 1); engclient_cmd(id, "drop", wname); } } }
stock 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 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 replace_all(msg,190,"!y","^1"); // normal replace_all(msg,190,"!t","^3"); // team 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,get_user_msgid("SayText"),_,players[i]); write_byte(players[i]); write_string(msg); message_end(); } } }
stock ham_strip_weapon(id,weapon[]) { 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))
return 1 }
PHP Code:
/*================================================================================ ---------------------------------- -*- [ZP] Class: Human: Alice Human -*- ---------------------------------- This plugin is part of Zombie Plague Mod and is distributed under the terms of the GNU General Public License. Check ZP_ReadMe.txt for details. ================================================================================*/
#include <amxmodx> #include <cstrike> #include <fakemeta> #include <fun> #include <zp50_class_human> #include <zp50_class_survivor> #include <zp50_core> #include <zombieplague> #include <crxranks>
native get_firem4a1(id)
//Alice Human Attributes new const humanclass1_name[] = "Alice" new const humanclass1_info[] = "[Fire M4a1]" new const humanclass1_models[][] = { "Ss_Alice" } const humanclass1_health = 500 const Float:humanclass1_speed = 1.0 const Float:humanclass1_gravity = 0.81 new g_alice_human
public plugin_precache() { register_plugin("[Ss] Class: Human: Alice", ZP_VERSION_STRING, "AsnoLa.V") g_alice_human = zp_class_human_register(humanclass1_name, humanclass1_info, humanclass1_health, humanclass1_speed, humanclass1_gravity) new index for (index = 0; index < sizeof humanclass1_models; index++) zp_class_human_register_model(g_alice_human, humanclass1_models[index]) }
public zp_fw_class_human_select_pre(id, classid) { if (classid == g_alice_human) { if (!(crxranks_get_user_level(id) >= 5)) { zp_class_human_menu_text_add("\r|Level 5|") return ZP_CLASS_NOT_AVAILABLE; } else { zp_class_human_menu_text_add("") return ZP_CLASS_AVAILABLE; } } return ZP_CLASS_AVAILABLE; }
public plugin_init() { set_task(0.6, "newround", 0, _, _, "b"); }
public newround(id) { // Check Current Human Class and not zombie if (is_user_alive(id) && zp_class_human_get_next(id) == g_alice_human && !zp_core_is_zombie(id)) {
//Give Weapon get_firem4a1(id) // Item fm_give_item(id, "weapon_hegrenade") fm_give_item(id, "weapon_flashbang") fm_give_item(id, "weapon_smokegrenade") fm_set_user_bpammo(id, CSW_M4A1, 90) } }
stock fm_set_user_bpammo(id, weaponid, amnt) {
static offset; switch(weaponid) { case CSW_FLASHBANG: offset = 387; case CSW_HEGRENADE: offset = 388; case CSW_SMOKEGRENADE: offset = 389; default: return 0; } set_pdata_int(id,offset,amnt,5); return 1; }
stock fm_give_item(id, const item[]) { static ent ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item)) if (!pev_valid(ent)) return; static Float:originF[3] pev(id, pev_origin, originF) set_pev(ent, pev_origin, originF) set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN) dllfunc(DLLFunc_Spawn, ent) static save save = pev(ent, pev_solid) dllfunc(DLLFunc_Touch, ent, id) if (pev(ent, pev_solid) != save) return; engfunc(EngFunc_RemoveEntity, ent) }
Last edited by ALonsoVIP4141; 09-16-2022 at 10:02.
|
|