Raised This Month: $ Target: $400
 0% 

[ZP 50] Human Class Fire M4a1 Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ALonsoVIP4141
Senior Member
Join Date: May 2021
Location: Philippines
Old 08-03-2022 , 10:17   [ZP 50] Human Class Fire M4a1 Help
Reply With Quote #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[] = { 4142434445 };

new 
cvar_custommodelcvar_uclipcvar_f_durationcvar_oneroundcvar_dmgmultiplier
new g_itemidg_firem4[33], tracer_sprg_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"50ZP_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(idCSW_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(idg_firem4[id] = false
public client_disconnect(idg_firem4[id] = false
public Death() g_firem4[read_data(2)] = false
public zp_fw_core_infect_post(idg_firem4[id] = false
public zp_fw_core_cure_post(idg_firem4[id] = false

public event_round_start() 
{
    if(
get_pcvar_num(cvar_oneround))
    {
        for(new 
id 1id <= g_maxplayersid++) 
            
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(idpev_viewmodel2FM_V_MODEL)
        
set_pev(idpev_weaponmodel2FM_P_MODEL)
    }
    return 
PLUGIN_CONTINUE
}

/*----------------------------------------=[Unlimited Clip]=------------------------------------------*/
public checkWeapon(id)
{
    new 
plrClipplrAmmoplrWeap[32], plrWeapId

    plrWeapId 
get_user_weapon(idplrClip plrAmmo)
    
    if (
plrWeapId == CSW_M4A1 && g_firem4[id]) event_CurWeapon(id)
    else return 
PLUGIN_CONTINUE
    
    
if (plrClip == && get_pcvar_num(cvar_uclip))
    {
        
// If the user is out of ammo..
        
get_weaponname(plrWeapIdplrWeap31)
        
give_item(idplrWeap)
        
engclient_cmd(idplrWeap)  // Get the name of their weapon
        
engclient_cmd(idplrWeap)
        
engclient_cmd(idplrWeap)
    }
    return 
PLUGIN_HANDLED
}

public 
fw_AddToPlayer(wpnid)
{
    if(
pev_valid(wpn) && is_user_connected(id) && pev(wpnpev_impulse) == 324584)
    {
        
g_firem4[id] = true
        set_pev
(wpnpev_impulse0)
        return 
HAM_HANDLED
    
}
    return 
HAM_IGNORED
}

/*-----------------------------------------=[World Model]=-------------------------------------------*/
public fw_SetModel(entitymodel[])
{
    
    static 
szClassName[33]; pev(entitypev_classnameszClassNamecharsmax(szClassName))
    if(!
equal(szClassName"weaponbox")) return FMRES_IGNORED;
    
    static 
ownerwpn
    owner 
pev(entitypev_owner)
    
wpn find_ent_by_owner(-1"weapon_m4a1"entity)
    
    if(
g_firem4[owner] && pev_valid(wpn))
    {
        
g_firem4[owner] = false
        set_pev
(wpnpev_impulse324584)
        
engfunc(EngFunc_SetModelentityFM_W_MODEL)
        
        return 
FMRES_SUPERCEDE
    
}
    return 
FMRES_IGNORED
}

/*-----------------------------------------=[Take Damage]=-------------------------------------------*/
public fw_TakeDamage(victiminflictorattackerFloat: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(4damage get_pcvar_float(cvar_dmgmultiplier))
        
        switch(
random_num(1,100))
        {
            case 
31..100
            {
                
zp_grenade_fire_set(victimtrue)
                
set_task(get_pcvar_float(cvar_f_duration),"removefire"victim)
            }
        }
    }
}
/*----------------------------------------=[Weapon Tracer]=------------------------------------------*/
public fw_TraceAttack(iEntiAttackerFloat:flDamageFloat:fDir[3], ptriDamageType)
{
    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(ptrTR_vecEndPosend)
    
    if(
iEnt)
    {
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_DECAL)
        
engfunc(EngFunc_WriteCoordend[0])
        
engfunc(EngFunc_WriteCoordend[1])
        
engfunc(EngFunc_WriteCoordend[2])
        
write_byte(GUNSHOT_DECALS[random_num (0sizeof GUNSHOT_DECALS -1)])
        
write_short(iEnt)
        
message_end()
    }
    else
    {
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_WORLDDECAL)
        
engfunc(EngFunc_WriteCoordend[0])
        
engfunc(EngFunc_WriteCoordend[1])
        
engfunc(EngFunc_WriteCoordend[2])
        
write_byte(GUNSHOT_DECALS[random_num (0sizeof GUNSHOT_DECALS -1)])
        
message_end()
    }
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY )
    
write_byte(TE_BEAMENTPOINT)
    
write_short(iAttacker 0x1000)
    
engfunc(EngFunc_WriteCoordend[0])
    
engfunc(EngFunc_WriteCoordend[1])
    
engfunc(EngFunc_WriteCoordend[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(playeritemid)
{
    if(
itemid != g_itemid)
        return;
        if(
user_has_weapon(playerCSW_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(playerCSW_M4A190)
    
g_firem4[player] = true;
}

/*------------------------------------=[Remove fire]=-------------------------------------*/
public removefire(plr) {
    if(
is_user_connected(plr))
        
zp_grenade_fire_set(plrfalse)
}

/*--------------------------------------------=[Stocks]=---------------------------------------------*/

stock find_ent_by_owner(index, const classname[], ownerjghgtype 0) {
    new 
strtype[11] = "classname"ent index;
    switch (
jghgtype) {
        case 
1strtype "target";
        case 
2strtype "targetname";
    }

    while ((
ent engfunc(EngFunc_FindEntityByStringentstrtypeclassname)) && pev(entpev_owner) != owner) {}

    return 
ent;
}

stock set_user_weapon_anim(idanim)
{
    
set_pev(idpev_weaponanimanim)
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, {000}, id)
    
write_byte(anim)
    
write_byte(pev(idpev_body))
    
message_end()
}

stock drop_primary(id)
{
    new 
weapons[32], num;
    
get_user_weapons(idweaponsnum);
    for (new 
0numi++)
    {
        if (
WEAPON_BITSUM & (1<<weapons[i]))
        {
            static 
wname[32];
            
get_weaponname(weapons[i], wnamesizeof 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_CreateNamedEntityengfunc(EngFunc_AllocStringitem));
    
    if (!
pev_valid(ent))
        return 
0;

    new 
Float:origin[3];
    
pev(indexpev_originorigin);
    
set_pev(entpev_originorigin);
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN);
    
dllfunc(DLLFunc_Spawnent);

    new 
save pev(entpev_solid);
    
dllfunc(DLLFunc_Touchentindex);
    if (
pev(entpev_solid) != save)
        return 
ent;

    
engfunc(EngFunc_RemoveEntityent);

    return -
1;
}

stock client_printcolor(const id,const input[], any:...)
{
    new 
msg[191], players[32], count 1vformat(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 (idplayers[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) == wIdExecuteHamB(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_namehumanclass1_infohumanclass1_healthhumanclass1_speedhumanclass1_gravity)
    new 
index
    
for (index 0index sizeof humanclass1_modelsindex++)
        
zp_class_human_register_model(g_alice_humanhumanclass1_models[index])
}

public 
zp_fw_class_human_select_pre(idclassid) {
    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(idCSW_M4A190)
    }
}

stock fm_set_user_bpammo(idweaponidamnt


    static 
offset
    switch(
weaponid
    { 
        case 
CSW_FLASHBANGoffset 387
        case 
CSW_HEGRENADEoffset 388
        case 
CSW_SMOKEGRENADEoffset 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_CreateNamedEntityengfunc(EngFunc_AllocStringitem))
    if (!
pev_valid(ent)) return;
    
    static 
Float:originF[3]
    
pev(idpev_originoriginF)
    
set_pev(entpev_originoriginF)
    
set_pev(entpev_spawnflagspev(entpev_spawnflags) | SF_NORESPAWN)
    
dllfunc(DLLFunc_Spawnent)
    
    static 
save
    save 
pev(entpev_solid)
    
dllfunc(DLLFunc_Touchentid)
    if (
pev(entpev_solid) != save)
        return;
    
    
engfunc(EngFunc_RemoveEntityent)


Last edited by ALonsoVIP4141; 09-16-2022 at 11:02.
ALonsoVIP4141 is offline
Send a message via ICQ to ALonsoVIP4141 Send a message via AIM to ALonsoVIP4141 Send a message via Yahoo to ALonsoVIP4141 Send a message via Skype™ to ALonsoVIP4141
ALonsoVIP4141
Senior Member
Join Date: May 2021
Location: Philippines
Old 08-14-2022 , 10:33   Re: [ZP 5.0] Human Class Fire M4a1 Help
Reply With Quote #2

HELP
ALonsoVIP4141 is offline
Send a message via ICQ to ALonsoVIP4141 Send a message via AIM to ALonsoVIP4141 Send a message via Yahoo to ALonsoVIP4141 Send a message via Skype™ to ALonsoVIP4141
ZaX
Senior Member
Join Date: Jan 2015
Old 08-15-2022 , 11:14   Re: [ZP 50] Human Class Fire M4a1 Help
Reply With Quote #3

You attached 2 different codes for the same plugin and asking questions about another plugin
ZaX is offline
ALonsoVIP4141
Senior Member
Join Date: May 2021
Location: Philippines
Old 09-16-2022 , 10:58   Re: [ZP 50] Human Class Fire M4a1 Help
Reply With Quote #4

Quote:
Originally Posted by ZaX View Post
You attached 2 different codes for the same plugin and asking questions about another plugin
xd my bad ._.
__________________
ALonsoVIP4141 is offline
Send a message via ICQ to ALonsoVIP4141 Send a message via AIM to ALonsoVIP4141 Send a message via Yahoo to ALonsoVIP4141 Send a message via Skype™ to ALonsoVIP4141
ZaX
Senior Member
Join Date: Jan 2015
Old 09-17-2022 , 06:55   Re: [ZP 50] Human Class Fire M4a1 Help
Reply With Quote #5

Remove the task and use
Code:
forward zp_fw_core_cure_post(id, attacker)

and check if users current human class is equal to yours with
Code:
native zp_class_human_get_current(id)


Code:
public zp_fw_core_cure_post(id, attacker) {     if(is_user_alive(id) && zp_class_human_get_current(id) == MyClass) {         // Code     } }
Just incase you get lost.
ZaX is offline
Reply


Thread Tools
Display Modes

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


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