AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to make the MiniGun to be only for survivors? (https://forums.alliedmods.net/showthread.php?t=335010)

GlobalPlague 11-02-2021 16:30

How to make the MiniGun to be only for survivors?
 
Hello. I downloaded an extra item called MiniGun, but i want the MiniGun to be available only for survivors.

So, to remove the MiniGun from the humans' extra items menu, i changed the MiniGun plugin's main code in the following way:

I opened the .sma file of the MiniGun plugin:

Code:

#include <amxmodx>
#include <engine>
#include <fakemeta_util>
#include <cstrike>
#include <hamsandwich>
#include <zombieplague>
#include <fun>

#define MAX_PLAYERS 32
#define MAX_BLOOD_DISTANCE        64
#define LOADUP_TIME                0.75
#define SHUTDOWN_TIME        1.7
#define SHAKE_FORCE                -5.0 //(must be negative value)
new const GUNSHOT_DECALS[] = {41, 42, 43, 44, 45}        // Gunshot decal list
// Plugin information
new const PLUGIN[] = "Minigun"
new const VERSION[] = "1.65"
new const AUTHOR[] = "CLLlAgOB"
// Weapon information
new const g_item_name[] = { "MiniGUN!" }
const g_item_cost = 30
// other
new bool:has_minigun[33], m249, bool:atk2[33], bool:atk1[33],bool:delay[33],bool:beackup[33],
clipp[33],clipstart,g_itemid_minigun,g_fwid,g_guns_eventids_bitsum,bool:g_fix_punchangle[33],
bool:frstCLIP[33],g_MaxPlayers, Float:g_lastShot[33], g_normal_trace[33],DMGMG,bool:haswhpnnmg[33],
Float:g_nextSound[33], g_plAction[33],bool:canfire[33],oneround,bool:user_bot[33],bool:delayhud[33],
clipstartsuv,bool:survivor[33],bool:is_alive[33],bool:is_connected[33]
// Blood
new g_blood
new g_bloodspray
// CS Player PData Offsets (win32)
const OFFSET_CSTEAMS = 114
// Linux diff's
const OFFSET_LINUX = 5 // offsets 5 higher in Linux builds
// Models
new P_MODEL[] = "models/wpnmod/m134/p_minigun.mdl"
new V_MODEL[] = "models/wpnmod/m134/v_minigun.mdl"
new W_MODEL[] = "models/wpnmod/m134/w_minigun.mdl"
// Sounds
new m_SOUND[][] = {"wpnmod/minigun/hw_shoot1.wav", "wpnmod/minigun/hw_spin.wav", "wpnmod/minigun/hw_spinup.wav", "wpnmod/minigun/hw_spindown.wav"}
new g_noammo_sounds[][] = {"weapons/dryfire_rifle.wav"}
//no recoil
new const g_guns_events[][] = {"events/m249.sc"}
//connect valid?
#define is_user_valid_connected(%1) (1 <= %1 <= g_MaxPlayers && is_connected[%1])

enum {
        anim_idle,
        anim_idle2,
        anim_gentleidle,
        anim_stillidle,
        anim_draw,
        anim_holster,
        anim_spinup,
        anim_spindown,
        anim_spinidle,
        anim_spinfire,
        anim_spinidledown
}

// Types
enum {
        act_none,
        act_load_up,
        act_run
}

public plugin_precache() {
        precache_model(P_MODEL)
        precache_model(V_MODEL)
        precache_model(W_MODEL)
        precache_sound(m_SOUND[0])
        precache_sound(m_SOUND[1])
        precache_sound(m_SOUND[2])
        precache_sound(m_SOUND[3])
        g_blood = precache_model("sprites/blood.spr")
        g_bloodspray = precache_model("sprites/bloodspray.spr")
        g_fwid = register_forward(FM_PrecacheEvent, "fwPrecacheEvent", 1)
}

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
        clipstart = register_cvar("amx_ammo_m249","600")
        clipstartsuv = register_cvar("amx_ammosuv_m249","10000")
        m249 =                register_cvar("amx_minigun_speed","0.1")
        DMGMG =                register_cvar("amx_minigun_damage","2.35")
        oneround =        register_cvar("amx_oneround","0")
        g_itemid_minigun = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
        register_event("CurWeapon","event_curweapon","be", "1=1")
        register_event("DeathMsg","unminigun","a")
        register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
        register_forward(FM_CmdStart, "fwd_CmdStart")
        register_forward(FM_EmitSound,"fwd_emitsound")
        register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
        register_forward(FM_PlayerPostThink, "fwPlayerPostThink", 1)
        register_forward(FM_StartFrame, "fwd_StartFrame")
        register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
        RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
        RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
        RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage")
        register_clcmd("drop","dropcmd", 0)
        g_MaxPlayers = get_maxplayers()
        //events
        register_logevent("event_start", 2, "1=Round_Start")
        register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
        register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
        unregister_forward(FM_PrecacheEvent, g_fwid, 1)
}

// Client joins the game
public client_putinserver(id)
{
        // Player joined
        is_connected[id] = true
}
// Client leaving
public fw_ClientDisconnect(id)
{
        is_connected[id] = false
        is_alive[id] = false
}
public fw_PlayerSpawn_Post(id)
{
        // Not alive or didn't join a team yet
        if (!is_user_alive(id) || !fm_cs_get_user_team(id))
                return;
        // Player spawned
        is_alive[id] = true
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
        //player die
        is_alive[victim] = false
}

public unminigun(){
        new id = read_data(2)
        if(has_minigun[id] && !is_alive[id]) {
                new Float:Aim[3],Float:origin[3]
                VelocityByAim(id, 64, Aim)
                entity_get_vector(id,EV_VEC_origin,origin)
               
                origin[0] += Aim[0]
                origin[1] += Aim[1]
               
                new minigun = create_entity("info_target")
                entity_set_string(minigun,EV_SZ_classname,"minigun")
                entity_set_model(minigun,W_MODEL)       
               
                entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
                entity_set_int(minigun,EV_INT_solid,1)
               
                entity_set_int(minigun,EV_INT_movetype,6)
                entity_set_int(minigun, EV_INT_iuser1, clipp[id])
                entity_set_vector(minigun,EV_VEC_origin,origin)
                has_minigun[id] = false
                remowegun(id)
                return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}

//damage lvl
public player_TakeDamage(victim, inflictor, attacker, Float:damage, damagetype) {
        if(damagetype & DMG_BULLET && haswhpnnmg[attacker] && has_minigun[attacker] == true  && attacker!=victim)
                {
                damage = damage*get_pcvar_float(DMGMG)
                SetHamParamFloat(4, damage)
                return HAM_IGNORED
                }
        return HAM_IGNORED
}


public event_start_freezetime(){
        remove_miniguns()
        static iPlayers[32], iPlayersNum, i
        get_players(iPlayers, iPlayersNum, "a")
        if(get_pcvar_num(oneround)){
                for (i = 0; i <= iPlayersNum; ++i){
                        if(has_minigun[iPlayers[i]]){
                                has_minigun[iPlayers[i]] = false
                                remowegun(iPlayers[i])
                                removesuv(iPlayers[i])
                        }
                }
        } else {
                for (i = 0; i <= iPlayersNum; ++i){
                        g_plAction[iPlayers[i]] = false
                        canfire[iPlayers[i]] = false
                        frstCLIP[iPlayers[i]] = true       
                        set_task(0.1,"event_curweapon",iPlayers[i])
                        removesuv(iPlayers[i])
                        }
        }
}

public removesuv(id){
        if(survivor[id]){
                has_minigun[id] = false
                survivor[id] = false
                remowegun(id)
        }
}

// remove gun and save all guns
public remowegun(id) {
        new wpnList[32]
        new number
        get_user_weapons(id,wpnList,number)
        for (new i = 0;i < number ;i++) {
                if (wpnList[i] == CSW_M249) {
                        fm_strip_user_gun(id, wpnList[i])
                }
        }
}

public event_start(){
        static iPlayers[32], iPlayersNum, i
        get_players(iPlayers, iPlayersNum, "a")
        for (i = 0; i <= iPlayersNum; ++i)
                canfire[iPlayers[i]] = true
}



public fwEvGameWillRestartIn() {
        static iPlayers[32], iPlayersNum, i
        get_players(iPlayers, iPlayersNum, "a")
        for (i = 0; i <= iPlayersNum; ++i)
                has_minigun[iPlayers[i]] = false
}
public client_connect(id){
        canfire[id]= false
        has_minigun[id] = false
        g_normal_trace[id] = 0
        if(is_user_bot(id)) user_bot[id] = true
        else user_bot[id] = false
}

//block sound no ammo in atack
public fwd_emitsound(id, channel, sample[], Float:volume, Float:attn, flag, pitch)
{       
        if (!is_user_valid_connected(id) || !has_minigun[id])
                return FMRES_IGNORED;
        else if((equal(sample, g_noammo_sounds[0])) && has_minigun[id] && haswhpnnmg[id])
                {
                return FMRES_SUPERCEDE
                }       
        return FMRES_IGNORED
}

// someone bought our extra item
public zp_extra_item_selected(id, itemid)
    {
                if (itemid == g_itemid_minigun)        give_weapon(id,0,1)
        }
//infect plaer
public zp_user_infected_pre(player, infector){
        has_minigun[player] = false
        dropcmd(player)
}

public dropcmd(id) {
        if(has_minigun[id] && haswhpnnmg[id] && is_alive[id]) {
                new Float:Aim[3],Float:origin[3]
                VelocityByAim(id, 64, Aim)
                entity_get_vector(id,EV_VEC_origin,origin)
               
                origin[0] += Aim[0]
                origin[1] += Aim[1]
               
                new minigun = create_entity("info_target")
                entity_set_string(minigun,EV_SZ_classname,"minigun")
                entity_set_model(minigun,W_MODEL)       
               
                entity_set_size(minigun,Float:{-2.0,-2.0,-2.0},Float:{5.0,5.0,5.0})
                entity_set_int(minigun,EV_INT_solid,1)
               
                entity_set_int(minigun,EV_INT_movetype,6)
                entity_set_int(minigun, EV_INT_iuser1, clipp[id])
                entity_set_vector(minigun,EV_VEC_origin,origin)
                has_minigun[id] = false
                canfire[id] = false
                remowegun(id)
                g_plAction[id] = false
                return PLUGIN_HANDLED
        }
        return PLUGIN_CONTINUE
}

public pfn_touch(ptr, ptd) {
        if(is_valid_ent(ptr)) {
                new classname[32]
                entity_get_string(ptr,EV_SZ_classname,classname,31)
               
                if(equal(classname, "minigun")) {
                        if(is_valid_ent(ptd)) {
                                new id = ptd
                                if(id > 0 && id < 34) {
                                        if(!has_minigun[id] && is_alive[id] && !zp_get_user_zombie(id)) {
                                                give_weapon(id,entity_get_int(ptr, EV_INT_iuser1), 0)
                                                remove_entity(ptr)
                                        }
                                }
                        }
                }
        }
}

public remove_miniguns() {
        new nextitem  = find_ent_by_class(-1,"minigun")
        while(nextitem) {
                remove_entity(nextitem)
                nextitem = find_ent_by_class(-1,"minigun")
        }
        return PLUGIN_CONTINUE
}

//give wpn
public give_weapon(id, ammo, frst){
        has_minigun[id] = true
        give_item(id,"weapon_m249")
        canfire[id] = true
        clipp[id] = ammo
        if(frst) frstCLIP[id] = true
        else beackup[id] = true
       
}


//set models
public event_curweapon(id){
        if(!is_alive[id] || !is_connected[id] || user_bot[id]) return;       
        new clip, ammo, weapon = get_user_weapon(id, clip, ammo)
        if(zp_get_user_survivor(id) && get_pcvar_num(clipstartsuv)!=0 && !survivor[id]){
                survivor[id] = true
                give_weapon(id,0,1)
        }
        if((has_minigun[id]) && (weapon == CSW_M249)){
                if(g_plAction[id] != act_run && frstCLIP[id]){
                                if(survivor[id]){
                                                clipp[id] = get_pcvar_num(clipstartsuv)
                                        } else {
                                                clipp[id] = get_pcvar_num(clipstart)
                                        }
                                new ent = get_weapon_ent(id,weapon)
                                if(clipp[id] < get_pcvar_num(clipstart)) clipp[id] = get_pcvar_num(clipstart)
                                cs_set_weapon_ammo(ent, clipp[id])
                                frstCLIP[id] = false
                        }
                if(g_plAction[id] != act_run && beackup[id]){
                        new ent = get_weapon_ent(id,weapon)
                        cs_set_weapon_ammo(ent, clipp[id])
                        beackup[id] = false
                }
                if(clipp[id] == 0){
                                new ent = get_weapon_ent(id,weapon)
                                cs_set_weapon_ammo(ent, clipp[id])
                        }
                if(g_plAction[id] == act_run){
                        clipp[id] = clip
                }
                message_begin(MSG_ONE, get_user_msgid("CurWeapon"), {0,0,0}, id)
                write_byte(1)
                write_byte(CSW_KNIFE)
                write_byte(0)
                message_end()
                if(!haswhpnnmg[id]){
                        entity_set_string(id,EV_SZ_viewmodel,V_MODEL)
                        entity_set_string(id,EV_SZ_weaponmodel,P_MODEL)
                        haswhpnnmg[id] = true
                }
                new        Ent = get_weapon_ent(id,weapon)
                new Float:N_Speed
                if(Ent)
                        {
                        N_Speed = get_pcvar_float(m249)
                        new Float:Delay = get_pdata_float( Ent, 46, 4) * N_Speed       
                        if (Delay > 0.0){
                                set_pdata_float( Ent, 46, Delay, 4)
                        }
                }
                ammo_hud(id)
                if(atk1[id]){
                        fire_mode(id, 0)
                }
                if(atk2[id]){
                        fire_mode(id, 1)
                }
        }
        if(weapon != CSW_M249) haswhpnnmg[id] = false
        if((has_minigun[id]) && (!haswhpnnmg[id])) g_plAction[id] = act_none
       
        return;
 }       

//play anim
public native_playanim(player,anim)
{
        set_pev(player, pev_weaponanim, anim)
        message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, player)
        write_byte(anim)
        write_byte(pev(player, pev_body))
        message_end()
}


 //marks on hit
 public native_gi_get_gunshot_decal()
{
        return GUNSHOT_DECALS[random_num(0, sizeof(GUNSHOT_DECALS) - 1)]
}

//hit bulet
public testbulet(id){
        // Find target
        new aimOrigin[3], target, body
        get_user_origin(id, aimOrigin, 3)
        get_user_aiming(id, target, body)
       
        if(target > 0 && target <= g_MaxPlayers)
        {
                new Float:fStart[3], Float:fEnd[3], Float:fRes[3], Float:fVel[3]
                pev(id, pev_origin, fStart)
               
                // Get ids view direction
                velocity_by_aim(id, MAX_BLOOD_DISTANCE, fVel)
               
                // Calculate position where blood should be displayed
                fStart[0] = float(aimOrigin[0])
                fStart[1] = float(aimOrigin[1])
                fStart[2] = float(aimOrigin[2])
                fEnd[0] = fStart[0]+fVel[0]
                fEnd[1] = fStart[1]+fVel[1]
                fEnd[2] = fStart[2]+fVel[2]
               
                // Draw traceline from victims origin into ids view direction to find
                // the location on the wall to put some blood on there
                new res
                engfunc(EngFunc_TraceLine, fStart, fEnd, 0, target, res)
                get_tr2(res, TR_vecEndPos, fRes)
                               
                // Show some blood :)
                message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                write_byte(TE_BLOODSPRITE)
                write_coord(floatround(fStart[0]))
                write_coord(floatround(fStart[1]))
                write_coord(floatround(fStart[2]))
                write_short(g_bloodspray)
                write_short(g_blood)
                write_byte(70)
                write_byte(random_num(1,2))
                message_end()
               
               
        } else {
                new decal = native_gi_get_gunshot_decal()
               
                // Check if the wall hit is an entity
                if(target)
                {
                        // Put decal on an entity
                        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                        write_byte(TE_DECAL)
                        write_coord(aimOrigin[0])
                        write_coord(aimOrigin[1])
                        write_coord(aimOrigin[2])
                        write_byte(decal)
                        write_short(target)
                        message_end()
                } else {
                        // Put decal on "world" (a wall)
                        message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                        write_byte(TE_WORLDDECAL)
                        write_coord(aimOrigin[0])
                        write_coord(aimOrigin[1])
                        write_coord(aimOrigin[2])
                        write_byte(decal)
                        message_end()
                }
               
                // Show sparcles
                message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
                write_byte(TE_GUNSHOTDECAL)
                write_coord(aimOrigin[0])
                write_coord(aimOrigin[1])
                write_coord(aimOrigin[2])
                write_short(id)
                write_byte(decal)
                message_end()
        }
}




//block anim standart wpn
public UpdateClientData_Post( id, sendweapons, cd_handle ){
        if ( !is_alive[id] ) return FMRES_IGNORED;
        if(haswhpnnmg[id] && has_minigun[id]) set_cd(cd_handle, CD_flNextAttack, halflife_time() + 0.001 );     
        return FMRES_HANDLED;
}

 public fwd_CmdStart(id, uc_handle, seed)
{
       
        if(!is_alive[id] || !has_minigun[id]) return FMRES_IGNORED
        if(!canfire[id]) return FMRES_HANDLED
       
        if(haswhpnnmg[id])
        {
                static buttons
                buttons = get_uc(uc_handle, UC_Buttons)               
                if(buttons & IN_ATTACK)
                {
                        atk1[id] = true
                        atk2[id] = false
                       
               
                }
                else if(buttons & IN_ATTACK2)
                {
                        atk2[id] = true
                        atk1[id] = false
                }
                if(atk1[id] && !atk2[id] && (g_plAction[id] == act_none || g_plAction[id] == act_load_up) && clipp[id]>0){
                        buttons &= ~IN_ATTACK
                        buttons &= ~IN_ATTACK2
                        set_uc(uc_handle, UC_Buttons, buttons)
                        fire_mode(id,0)
                } else if(atk2[id] || atk1[id] && clipp[id]==0){
                        fire_mode(id,1)
                }
                       
        }
        return FMRES_IGNORED       
}

// in fire
fire_mode(id, type) {
        static Float:gtime
        gtime = get_gametime()
        g_lastShot[id] = gtime
       
        if(g_nextSound[id] <= gtime && canfire[id]) {
                switch(g_plAction[id]) {
                        case act_none: {
                                native_playanim(id, anim_spinup)
                                emit_sound(id, CHAN_WEAPON, m_SOUND[2], 1.0, ATTN_NORM, 0, PITCH_NORM)
                                g_nextSound[id] = gtime + LOADUP_TIME
                                g_plAction[id] = act_load_up
                        }
                        case act_load_up: {
                                g_nextSound[id] = gtime
                                g_plAction[id] = act_run
                        }
                }
        }
       
        if(g_plAction[id] == act_run) {
                if(type == 0 && clipp[id]>0 && atk1[id]){
                        emit_sound(id, CHAN_WEAPON, m_SOUND[0], 1.0, ATTN_NORM, 0, PITCH_NORM)
                        testbulet(id)
                        if(!delay[id]) {
                                native_playanim(id, anim_spinfire)
                                ammo_hud(id)
                                set_task(0.2,"delayanim",id)
                                delay[id] = true
                                }
                }
                else {
                        if(!delay[id]) {
                                ammo_hud(id)
                                emit_sound(id, CHAN_WEAPON, m_SOUND[1], 1.0, ATTN_NORM, 0, PITCH_NORM)
                                native_playanim(id, anim_spinidle)
                                set_task(0.2,"delayanim",id)
                                delay[id] = true
                        }
                }
        }
        atk1[id] = false
        atk2[id] = false
}

public delayanim(id){
        delay[id] = false
}

//sound and anim
public fwd_StartFrame() {
        static Float:gtime, id
       
        gtime = get_gametime()
       
        for(id = 0; id <= g_MaxPlayers; id++) {
                if(g_plAction[id] != act_none) {
                       
                        if(!(pev(id, pev_button) & IN_ATTACK) && !(pev(id, pev_button) & IN_ATTACK2) && g_lastShot[id] + 0.2 < gtime) {
                                native_playanim(id, anim_spinidledown)
                                emit_sound(id, CHAN_WEAPON, m_SOUND[3], 1.0, ATTN_NORM, 0, PITCH_NORM)
                                g_nextSound[id] = gtime + SHUTDOWN_TIME
                                g_plAction[id] = act_none
                        }
                }
        }
}


// No recoil stuff

public fwPrecacheEvent(type, const name[]) {
        for (new i = 0; i < sizeof g_guns_events; ++i) {
                if (equal(g_guns_events[i], name)) {
                        g_guns_eventids_bitsum |= (1<<get_orig_retval())
                        return FMRES_HANDLED
                }
        }

        return FMRES_IGNORED
}
public fwPlaybackEvent(flags, invoker, eventid) {
        if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_MaxPlayers) || !haswhpnnmg[invoker] || !has_minigun[invoker])
                return FMRES_IGNORED

        g_fix_punchangle[invoker] = true

        return FMRES_HANDLED
}

public fwPlayerPostThink(id) {
        if (g_fix_punchangle[id]) {
                g_fix_punchangle[id] = false
                set_pev(id, pev_punchangle, Float:{0.0, 0.0, 0.0})
                return FMRES_HANDLED
        }

        return FMRES_IGNORED
}

public fwTraceLine(const Float:start[3], const Float:dest[3], ignore_monsters, id, ptr) {
        if (!(1 <= id <= g_MaxPlayers))
                return FMRES_IGNORED

        if (!g_normal_trace[id]) {
                g_normal_trace[id] = ptr
                return FMRES_HANDLED
        }
        if (ptr == g_normal_trace[id] || ignore_monsters != DONT_IGNORE_MONSTERS || !is_alive[id] || !haswhpnnmg[id] || !has_minigun[id])
                return FMRES_IGNORED

        fix_recoil_trace(id, start, ptr)

        return FMRES_SUPERCEDE
}

// show ammo clip
public ammo_hud(id) {
        if(!delayhud[id]) {
                delayhud[id] = true
                new AmmoHud[65]
                new clip = clipp[id]
                format(AmmoHud, 64, "Ammo: %i", clip)
                set_hudmessage(200, 100, 0, 1.0 , 1.0, 0, 0.1, 0.1,0.1)
                show_hudmessage(id,"%s",AmmoHud)
                set_task(0.2,"delayhutmsg",id)
        }
}

public delayhutmsg(id){
        delayhud[id]= false
}

//get weapon id
stock get_weapon_ent(id,wpnid=0,wpnName[]="")
{
        // who knows what wpnName will be
        static newName[24];

        // need to find the name
        if(wpnid) get_weaponname(wpnid,newName,23);

        // go with what we were told
        else formatex(newName,23,"%s",wpnName);

        // prefix it if we need to
        if(!equal(newName,"weapon_",7))
                format(newName,23,"weapon_%s",newName);

        return fm_find_ent_by_owner(get_maxplayers(),newName,id);
}
fix_recoil_trace(id, const Float:start[], ptr) {
        static Float:dest[3]
        pev(id, pev_v_angle, dest)
        engfunc(EngFunc_MakeVectors, dest)
        global_get(glb_v_forward, dest)
        xs_vec_mul_scalar(dest, 9999.0, dest)
        xs_vec_add(start, dest, dest)
        engfunc(EngFunc_TraceLine, start, dest, DONT_IGNORE_MONSTERS, id, ptr)
}
// Get User Team
stock fm_cs_get_user_team(id)
{
        return get_pdata_int(id, OFFSET_CSTEAMS, OFFSET_LINUX);
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2057\\ f0\\ fs16 \n\\ par }
*/

then, i found this:

Code:

// Weapon information
new const g_item_name[] = { "MiniGUN!" }
const g_item_cost = 30

and, i deleted this:

Code:

new const g_item_name[] = { "MiniGUN!" }
after that, i found this part of the code:

Code:

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
        clipstart = register_cvar("amx_ammo_m249","600")
        clipstartsuv = register_cvar("amx_ammosuv_m249","10000")
        m249 =                register_cvar("amx_minigun_speed","0.1")
        DMGMG =                register_cvar("amx_minigun_damage","2.35")
        oneround =        register_cvar("amx_oneround","0")
        g_itemid_minigun = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
        register_event("CurWeapon","event_curweapon","be", "1=1")
        register_event("DeathMsg","unminigun","a")
        register_forward(FM_ClientDisconnect, "fw_ClientDisconnect")
        register_forward(FM_CmdStart, "fwd_CmdStart")
        register_forward(FM_EmitSound,"fwd_emitsound")
        register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
        register_forward(FM_PlayerPostThink, "fwPlayerPostThink", 1)
        register_forward(FM_StartFrame, "fwd_StartFrame")
        register_forward(FM_UpdateClientData, "UpdateClientData_Post", 1)
        RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
        RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
        RegisterHam(Ham_TakeDamage, "player", "player_TakeDamage")
        register_clcmd("drop","dropcmd", 0)
        g_MaxPlayers = get_maxplayers()
        //events
        register_logevent("event_start", 2, "1=Round_Start")
        register_event("TextMsg", "fwEvGameWillRestartIn", "a", "2=#Game_will_restart_in")
        register_event("HLTV", "event_start_freezetime", "a", "1=0", "2=0")
        unregister_forward(FM_PrecacheEvent, g_fwid, 1)
}

and, i deleted this line:

Code:

g_itemid_minigun = zp_register_extra_item(g_item_name, g_item_cost, ZP_TEAM_HUMAN)
So, the MiniGun can no longer be found in the humans' extra items menu, this is what i want. However, survivors not always get the MiniGun. For example, if i start the server now, and i turn a player into survivor many rounds in a row, the player will get the minigun only the first 2-3-4 times i turn him into a survivor. After the 3th or the 4th time, the player will be getting m249, instead of the minigun. The same problem i have for game modes that feature survivors. For example, if i start Armageddon mode (50% survivors - 50% nemesis) a few rounds in a row, only the fist 1 or 2 times the survivors will have miniguns, after that, they will be getting m249.

So, does anyone know how to fix this problem? I want the minigun to be only for survivors, and survivors to be getting minigun automatically every time a player becomes a survivor. Survivors should be getting minigun, instead of m249, they always have to get minigun, instead of m249.

In "zombie_plague_advance.cfg", this is the default weapon of survivor:

Code:

zp_surv_weapon "weapon_m249" // Survivor's weapon (given by default)
Why m249? Because, judging by the minigun plugin code, the minigun is based on m249, meaning m249 is interpreted as minigun by the server.

This option:

Code:

zp_remove_dropped 1 // Time before removing dropped weapons in seconds [0-disabled]
Is about removing all weapons that are dropped by the player by pressing the "G" button. However, i noticed the minigun is not affected by the fact this option is turned on. If you are a survivor and you get minigun, but then you get killed, your minigun will be dropped, but it won't be removed, it won't disappear. When you get respawned in the same round you got killed, you will get m249, instead of minigun, while you can still find your minigun on the place you was killed, and pick it...

Coud it be the server's inability to remove the minigun, as ordered by the .cfg file, is causing the problem? Or maybe i'm doing something wrong with the code?

DJEarthQuake 11-03-2021 16:40

Re: How to make the MiniGun to be only for survivors?
 
Quote:

So, does anyone know how to fix this problem? I want the minigun to be only for survivors, and survivors to be getting minigun automatically every time a player becomes a survivor. Survivors should be getting minigun, instead of m249, they always have to get minigun, instead of m249.
Is this really a cosmetic skin 'glitch' whereby m249 shows and otherwise survivor weapon behaves as a mini-gun, as designed?

GlobalPlague 11-04-2021 01:30

Re: How to make the MiniGun to be only for survivors?
 
Quote:

Originally Posted by DJEarthQuake (Post 2762394)
Is this really a cosmetic skin 'glitch' whereby m249 shows and otherwise survivor weapon behaves as a mini-gun, as designed?

Hello.

No, it's not a skin glitch. When survivors get minigun, they get real minigun that works as designed in the minigun plugin code. When survivors get m249, they get real m249 that works in the same way m249 works in classic CS servers. I mean that when survivors get m249, they don't get minigun that works as designed in the minigun plugin code, while having m249 skin, but actual m249.

Celena Luna 11-04-2021 04:00

Re: How to make the MiniGun to be only for survivors?
 
1 Attachment(s)
Rather than wait for CurWeapon to give weapon to Survivor, I will just give the Minigun to Survivor so it would be more consistent
This is ancient plugin, why are you still using it anyway

PHP Code:

public zp_user_humanized_post(idsurvivor)
{
    if(
survivor)
    {
        
give_weapon(id,0,1)
    }



GlobalPlague 11-04-2021 05:36

Re: How to make the MiniGun to be only for survivors?
 
Quote:

Originally Posted by Celena Luna (Post 2762437)
Rather than wait for CurWeapon to give weapon to Survivor, I will just give the Minigun to Survivor so it would be more consistent
This is ancient plugin, why are you still using it anyway

PHP Code:

public zp_user_humanized_post(idsurvivor)
{
    if(
survivor)
    {
        
give_weapon(id,0,1)
    }



Thanks. It works.

Why am i using it? Well, because there is no newer version of the minigun plugin or, another plugin that add better weapon for survivor. :)


All times are GMT -4. The time now is 11:29.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.