Raised This Month: $51 Target: $400
 12% 

ZM VIP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Anz
Junior Member
Join Date: May 2019
Location: Morocco
Old 05-15-2019 , 18:38   ZM VIP
Reply With Quote #1

hello
i have a zombie plague server 5.0.8 , i have used zm vip by aaarnas

this one :
zm_vip_en.zip
i wanted to add the vip human model and the zombie model
so i tried 1.9.1 beta
but i could not add extra items to it
if you could help me to add the vip extra items
like i want to make golden ak47 for free but only for vips , and the vip can use it 1 time in round
the extra items :
SandBags (3)
Golden Ak (1)
Sawn Off Shoutgun (1)
Plasma Gun (1)
i tried to make them for vip but it could not work
i want to make them for free with no ammo and visible in the vip menu but only 1 time ( i want to use zm vip beta 1.9.1)
the extra items sma :
zm_vip_en.zip

zp_extra_goldenak.sma

zp_extra_sawnoff.sma

zp_extra_plasmagun.sma

if some one could help me and show me how to make them for free for vip 1 time in round , i will really appreciate the help
but only for vips
Thank you
__________________
Lord Of Darkness
Anz is offline
Anz
Junior Member
Join Date: May 2019
Location: Morocco
Old 05-15-2019 , 18:40   Re: ZM VIP
Reply With Quote #2

golden ak

PHP Code:
/*
[ZP] Extra Item: Golden Ak 47
Team: Humans

Description: This plugin adds a new weapon for Human Teams.
Weapon Cost: 30

Features:
- This weapon do more damage
- This weapon has zoom
- Launch Lasers
- This weapon has unlimited bullets

Credits:

KaOs - For his Dual MP5 mod

Cvars:


- zp_goldenak_dmg_multiplier <5> - Damage Multiplier for Golden Ak 47
- zp_goldenak_gold_bullets <1|0> - Golden bullets effect ?
- zp_goldenak_custom_model <1|0> - Golden ak Custom Model
- zp_goldenak_unlimited_clip <1|0> - Golden ak Unlimited Clip 

*/



#include <amxmodx>
#include <fakemeta>
#include <fun>
#include <hamsandwich>
#include <cstrike>
#include <zombieplague>

#define is_valid_player(%1) (1 <= %1 <= 32)

new AK_V_MODEL[64] = "models/zombie_plague/v_golden_ak47.mdl"
new AK_P_MODEL[64] = "models/zombie_plague/p_golden_ak47.mdl"

/* Pcvars */
new cvar_dmgmultipliercvar_goldbullets,  cvar_custommodelcvar_uclip

// Item ID
new g_itemid

new bool:g_HasAk[33]

new 
g_hasZoom33 ]
new 
bullets33 ]

// Sprite
new m_spriteTexture

const Wep_ak47 = ((1<<CSW_AK47))

public 
plugin_init()
{
    
    
/* CVARS */
    
cvar_dmgmultiplier register_cvar("zp_goldenak_dmg_multiplier""5")
    
cvar_custommodel register_cvar("zp_goldenak_custom_model""1")
    
cvar_goldbullets register_cvar("zp_goldenak_gold_bullets""1")
    
cvar_uclip register_cvar("zp_goldenak_unlimited_clip""1")
    
    
// Register The Plugin
    
register_plugin("[ZP] Extra: Golden Ak 47""1.1""AlejandroSk")
    
// Register Zombie Plague extra item
    
g_itemid zp_register_extra_item("Golden Ak 47"30ZP_TEAM_HUMAN)
    
// Death Msg
    
register_event("DeathMsg""Death""a")
    
// Weapon Pick Up
    
register_event("WeapPickup","checkModel","b","1=19")
    
// Current Weapon Event
    
register_event("CurWeapon","checkWeapon","be","1=1")
    
register_event("CurWeapon""make_tracer""be""1=1""3>0")
    
// Ham TakeDamage
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
register_forwardFM_CmdStart"fw_CmdStart" )
    
RegisterHam(Ham_Spawn"player""fwHamPlayerSpawnPost"1)
    
}

public 
client_connect(id)
{
    
g_HasAk[id] = false
}

public 
client_disconnect(id)
{
    
g_HasAk[id] = false
}

public 
Death()
{
    
g_HasAk[read_data(2)] = false
}

public 
fwHamPlayerSpawnPost(id)
{
    
g_HasAk[id] = false
}

public 
plugin_precache()
{
    
precache_model(AK_V_MODEL)
    
precache_model(AK_P_MODEL)
    
m_spriteTexture precache_model("sprites/dot.spr")
    
precache_sound("weapons/zoom.wav")
}

public 
zp_user_infected_post(id)
{
    if (
zp_get_user_zombie(id))
    {
        
g_HasAk[id] = false
    
}
}

public 
checkModel(id)
{
    if ( 
zp_get_user_zombie(id) )
        return 
PLUGIN_HANDLED
    
    
new szWeapID read_data(2)
    
    if ( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && get_pcvar_num(cvar_custommodel) )
    {
        
set_pev(idpev_viewmodel2AK_V_MODEL)
        
set_pev(idpev_weaponmodel2AK_P_MODEL)
    }
    return 
PLUGIN_HANDLED
}

public 
checkWeapon(id)
{
    new 
plrClipplrAmmoplrWeap[32]
    new 
plrWeapId
    
    plrWeapId 
get_user_weapon(idplrClip plrAmmo)
    
    if (
plrWeapId == CSW_AK47 && g_HasAk[id])
    {
        
checkModel(id)
    }
    else 
    {
        return 
PLUGIN_CONTINUE
    
}
    
    if (
plrClip == && get_pcvar_num(cvar_uclip))
    {
        
// If the user is out of ammo..
        
get_weaponname(plrWeapIdplrWeap31)
        
// Get the name of their weapon
        
give_item(idplrWeap)
        
engclient_cmd(idplrWeap
        
engclient_cmd(idplrWeap)
        
engclient_cmd(idplrWeap)
    }
    return 
PLUGIN_HANDLED
}



public 
fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if ( 
is_valid_playerattacker ) && get_user_weapon(attacker) == CSW_AK47 && g_HasAk[attacker] )
    {
        
SetHamParamFloat(4damage get_pcvar_floatcvar_dmgmultiplier ) )
    }
}

public 
fw_CmdStartiduc_handleseed )
{
    if( !
is_user_aliveid ) ) 
        return 
PLUGIN_HANDLED
    
    
if( ( get_ucuc_handleUC_Buttons ) & IN_ATTACK2 ) && !( pevidpev_oldbuttons ) & IN_ATTACK2 ) )
    {
        new 
szClipszAmmo
        
new szWeapID get_user_weaponidszClipszAmmo )
        
        if( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && !g_hasZoom[id] == true)
        {
            
g_hasZoom[id] = true
            cs_set_user_zoom
idCS_SET_AUGSG552_ZOOM)
            
emit_soundidCHAN_ITEM"weapons/zoom.wav"0.202.400100 )
        }
        
        else if ( 
szWeapID == CSW_AK47 && g_HasAk[id] == true && g_hasZoom[id])
        {
            
g_hasZoomid ] = false
            cs_set_user_zoom
idCS_RESET_ZOOM)
            
        }
        
    }
    return 
PLUGIN_HANDLED
}


public 
make_tracer(id)
{
    if (
get_pcvar_num(cvar_goldbullets))
    {
        new 
clip,ammo
        
new wpnid get_user_weapon(id,clip,ammo)
        new 
pteam[16]
        
        
get_user_team(idpteam15)
        
        if ((
bullets[id] > clip) && (wpnid == CSW_AK47) && g_HasAk[id]) 
        {
            new 
vec1[3], vec2[3]
            
get_user_origin(idvec11// origin; your camera point.
            
get_user_origin(idvec24// termina; where your bullet goes (4 is cs-only)
            
            
            //BEAMENTPOINTS
            
message_beginMSG_BROADCAST,SVC_TEMPENTITY)
            
write_byte (0)     //TE_BEAMENTPOINTS 0
            
write_coord(vec1[0])
            
write_coord(vec1[1])
            
write_coord(vec1[2])
            
write_coord(vec2[0])
            
write_coord(vec2[1])
            
write_coord(vec2[2])
            
write_shortm_spriteTexture )
            
write_byte(1// framestart
            
write_byte(5// framerate
            
write_byte(2// life
            
write_byte(10// width
            
write_byte(0// noise
            
write_byte255 )     // r, g, b
            
write_byte215 )       // r, g, b
            
write_byte)       // r, g, b
            
write_byte(200// brightness
            
write_byte(150// speed
            
message_end()
        }
    
        
bullets[id] = clip
    
}
    
}

public 
zp_extra_item_selected(playeritemid)
{
    if ( 
itemid == g_itemid )
    {
        if ( 
user_has_weapon(playerCSW_AK47) )
        {
            
drop_prim(player)
        }
        
        
give_item(player"weapon_ak47")
        
client_print(playerprint_chat"[ZP] You bought Golden Ak - 47")
        
g_HasAk[player] = true;
    }
}

stock drop_prim(id
{
    new 
weapons[32], num
    get_user_weapons
(idweaponsnum)
    for (new 
0numi++) {
        if (
Wep_ak47 & (1<<weapons[i])) 
        {
            static 
wname[32]
            
get_weaponname(weapons[i], wnamesizeof wname 1)
            
engclient_cmd(id"drop"wname)
        }
    }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1034\\ f0\\ fs16 \n\\ par }
*/ 
__________________
Lord Of Darkness
Anz is offline
Anz
Junior Member
Join Date: May 2019
Location: Morocco
Old 05-15-2019 , 18:43   Re: ZM VIP
Reply With Quote #3

sawn off shotgun
PHP Code:
/*================================================================================

    [ZP] Extra Item: Sawn-Off Shotgun
    Copyright (C) 2009 by meTaLiCroSS
    Request maded by Clear
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    In addition, as a special exception, the author gives permission to
    link the code of this program with the Half-Life Game Engine ("HL
    Engine") and Modified Game Libraries ("MODs") developed by Valve,
    L.L.C ("Valve"). You must obey the GNU General Public License in all
    respects for all of the code used other than the HL Engine and MODs
    from Valve. If you modify this file, you may extend this exception
    to your version of the file, but you are not obligated to do so. If
    you do not wish to do so, delete this exception statement from your
    version.

=================================================================================*/

#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
#include <xs>
#include <zombieplague>

/*================================================================================
 [Customization]
=================================================================================*/

// Item Cost
new const g_SawnOff_Cost 30

// Models
new const sawnoff_model_v[] = "models/v_sawn_off_shotgun.mdl"
new const sawnoff_model_p[] = "models/p_sawn_off_shotgun.mdl"
new const sawnoff_model_w[] = "models/w_sawn_off_shotgun.mdl"

// ---------------------------------------------------------------
// ------------------ Customization ends here!! ------------------
// ---------------------------------------------------------------

// Offsets
#if cellbits == 32
const OFFSET_CLIPAMMO 51
#else
const OFFSET_CLIPAMMO 65
#endif
const OFFSET_LINUX 5
const OFFSET_LINUX_WEAPONS 4
const OFFSET_LASTPRIMARYITEM 368

// Version
#define VERSION "0.4.5"

// Arrays
new g_sawnoff_shotgun[33], g_currentweapon[33]

// Variables
new g_SawnOffg_MaxPlayers

// Cvar Pointers
new cvar_enablecvar_oneroundcvar_knockbackcvar_knockbackpowercvar_uclipcvar_damage

/*================================================================================
 [Init and Precache]
=================================================================================*/

public plugin_init() 
{
    
// Plugin Info
    
register_plugin("[ZP] Extra Item: Sawn-Off Shotgun"VERSION"meTaLiCroSS")
    
    
// Ham Forwards
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
    
    
// Fakemeta Forwards
    
register_forward(FM_SetModel"fw_SetModel")
    
    
// Event: Round Start
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
    
// Message: Cur Weapon
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
    
    
// CVARS
    
register_cvar("zp_extra_sawnoff"VERSIONFCVAR_SERVER|FCVAR_SPONLY)
    
cvar_enable register_cvar("zp_sawnoff_enable""1")
    
cvar_uclip register_cvar("zp_sawnoff_unlimited_clip""1")
    
cvar_damage register_cvar("zp_sawnoff_damage_mult""4.0")
    
cvar_oneround register_cvar("zp_sawnoff_oneround""0")
    
cvar_knockback register_cvar("zp_sawnoff_knockback""1")
    
cvar_knockbackpower register_cvar("zp_sawnoff_kbackpower""10.0")
    
    
// Variables
    
g_MaxPlayers get_maxplayers()
    
g_SawnOff zp_register_extra_item("Sawn-Off Shotgun"g_SawnOff_CostZP_TEAM_HUMAN)
    
}

public 
plugin_precache()
{
    
// Precaching models
    
precache_model(sawnoff_model_v)
    
precache_model(sawnoff_model_p)
    
precache_model(sawnoff_model_w)
}

/*================================================================================
 [Main Functions]
=================================================================================*/

// Round Start Event
public event_round_start()
{
    
// Get all the players
    
for(new id 1id <= g_MaxPlayersid++)
    {
        
// Check
        
if(get_pcvar_num(cvar_oneround) || !get_pcvar_num(cvar_enable))
        {
            
// Striping Sawn Off
            
if(g_sawnoff_shotgun[id])
            {
                
g_sawnoff_shotgun[id] = false;
                
ham_strip_weapon(id"weapon_m3")
            }
        }
    }
}

// Message Current Weapon
public message_cur_weapon(msg_idmsg_destid)
{
    
// Doesn't have a Sawn Off
    
if (!g_sawnoff_shotgun[id])
        return 
PLUGIN_CONTINUE
    
    
// Isn't alive / not active weapon
    
if (!is_user_alive(id) || get_msg_arg_int(1) != 1)
        return 
PLUGIN_CONTINUE
        
    
// Get Weapon Clip
    
new clip get_msg_arg_int(3)
    
    
// Update Weapon Array
    
g_currentweapon[id] = get_msg_arg_int(2// get weapon ID
    
    // Weapon isn't M3
    
if(g_currentweapon[id] != CSW_M3)
        return 
PLUGIN_CONTINUE;
        
    
// Replace Models
    
entity_set_string(idEV_SZ_viewmodelsawnoff_model_v)
    
entity_set_string(idEV_SZ_weaponmodelsawnoff_model_p)
    
    
// Check cvar
    
if(get_pcvar_num(cvar_uclip))
    {    
        
// Set Ammo HUD in 8
        
set_msg_arg_int(3get_msg_argtype(3), 8)
            
        
// Check clip if more than 2
        
if (clip 2)
        {
            
// Update weapon ammo
            
fm_set_weapon_ammo(find_ent_by_owner(-1"weapon_m3"id), 8)
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

// Touch fix (when user drop the Sawn off, already has the Sawn off.
public touch_fix(id)
{
    if(
g_sawnoff_shotgun[id])
        
g_sawnoff_shotgun[id] = false;
}

/*================================================================================
 [Main Forwards]
=================================================================================*/

public fw_PlayerKilled(victimattackershouldgib)
{
    
// Victim has a Sawn off
    
if(g_sawnoff_shotgun[victim])
        
g_sawnoff_shotgun[victim] = false;
}

public 
fw_SetModel(entitymodel[])
{
    
// Entity is not valid
    
if(!is_valid_ent(entity))
        return 
FMRES_IGNORED;
        
    
// Entity model is not a M3
    
if(!equali(model"models/w_m3.mdl")) 
        return 
FMRES_IGNORED;
        
    
// Get owner and entity classname
    
new owner entity_get_edict(entityEV_ENT_owner)
    new 
classname[33]
    
entity_get_string(entityEV_SZ_classnameclassnamecharsmax(classname))
    
    
// Entity classname is a weaponbox
    
if(equal(classname"weaponbox"))
    {
        
// The weapon owner has a Sawn Off
        
if(g_sawnoff_shotgun[owner])
        {
            
// Striping Sawn off and set New Model
            
g_sawnoff_shotgun[owner] = false;
            
entity_set_model(entitysawnoff_model_w)
            
set_task(0.1"touch_fix"owner)
            
            return 
FMRES_SUPERCEDE
        
}
    }
    
    return 
FMRES_IGNORED

}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    
// Attacker isn't a Player (1 in 32)
    
if(!(<= attacker <= g_MaxPlayers))
        return 
HAM_IGNORED;
        
    
// Attacker's weapon isn't a M3
    
if(g_currentweapon[attacker] != CSW_M3)
        return 
HAM_IGNORED;
        
    
// User doesn't have a Sawn Off
    
if(!g_sawnoff_shotgun[attacker])
        return 
HAM_IGNORED;
        
    
SetHamParamFloat(4damage get_pcvar_float(cvar_damage) )
    
    return 
HAM_IGNORED;
}

public 
fw_TraceAttack(victimattackerFloat:damageFloat:direction[3], tracehandledamage_type)
{
    
// Player is allowed to make a Knockback
    
if(!allowed_knockback(victimattacker))
        return 
HAM_IGNORED;
        
    
// Check damage type
    
if(!(damage_type DMG_BULLET))
        return 
HAM_IGNORED;
        
    
// Make Knockback...
    
new Float:velocity[3]; pev(victimpev_velocityvelocity)
    
xs_vec_mul_scalar(directionget_pcvar_float(cvar_knockbackpower), direction)
    
xs_vec_add(velocitydirectiondirection)
    
entity_set_vector(victimEV_VEC_velocitydirection)
         
    return 
HAM_IGNORED;
 
}

public 
pfn_touch(entitytoucher)
{
    new 
model[33], toucherclass[33], entityclass[33]
    
    
// Get toucher Classname
    
if((toucher 0) && is_valid_ent(toucher)) entity_get_string(toucherEV_SZ_classnametoucherclasscharsmax(toucherclass))
    
    
// Get entity Classname
    
if((entity 0) && is_valid_ent(entity)) entity_get_string(entityEV_SZ_classnameentityclasscharsmax(entityclass))
    
    
// Now check if is a Weapon and is a Player
    
if(equali(toucherclass"player") && equali(entityclass"weaponbox"))
    {
        
// Get Model
        
entity_get_string(entityEV_SZ_modelmodelcharsmax(model))
        
        
// Check Model
        
if(equali(modelsawnoff_model_w))
            if(
allowed_touch(toucher)) // Player is allowed to pickup the weapon
                
g_sawnoff_shotgun[toucher] = true // Set Weapon
    
}
}

/*================================================================================
 [Internal Functions]
=================================================================================*/

allowed_knockback(victimattacker)
{
    
// Obviously, doesn't is allowed to be Knockbacked (WTF)
    
if(!g_sawnoff_shotgun[attacker] || !get_pcvar_num(cvar_knockback) || g_currentweapon[attacker] != CSW_M3 || !zp_get_user_zombie(victim))
        return 
false;
    
    return 
true;
}

allowed_touch(toucher)
{
    
// Can't touch the Weapon
    
if(zp_get_user_survivor(toucher) || zp_get_user_zombie(toucher) || fm_get_user_lastprimaryitem(toucher) || g_sawnoff_shotgun[toucher])
        return 
false;
        
    return 
true;
}

/*================================================================================
 [Zombie Plague Forwards]
=================================================================================*/

public zp_extra_item_selected(iditemid)
{
    
// Item is the Sawn-Off
    
if(itemid == g_SawnOff)
    {
        if(!
get_pcvar_num(cvar_enable))
        {
            
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + g_SawnOff_Cost)
            
client_print(idprint_chat"[ZP] The Sawn-Off Shotgun is Disabled")
            
            return;
        }
        
        
// Already has an M3
        
if(g_sawnoff_shotgun[id] && user_has_weapon(idCSW_M3))
        {
            
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + g_SawnOff_Cost)
            
client_print(idprint_chat"[ZP] You already have a Sawn-Off Shotgun")
            
            return;
        }
        
        
// Array
        
g_sawnoff_shotgun[id] = true
        
        
// Weapon
        
ham_give_weapon(id"weapon_m3")
        
        
// Message
        
client_print(idprint_chat"[ZP] You now have a Sawn-Off Shotgun")
        
    }
}

public 
zp_user_infected_post(infectedinfector)
{
    
// Infected has a M3
    
if(g_sawnoff_shotgun[infected])
        
g_sawnoff_shotgun[infected] = false;
}

public 
zp_user_humanized_post(player)
{
    
// Is Survivor
    
if(zp_get_user_survivor(player) && g_sawnoff_shotgun[player])
        
g_sawnoff_shotgun[player] = false;
}

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

stock ham_give_weapon(idweapon[])
{
    if(!
equal(weapon,"weapon_",7)) 
        return 
0

    
new wEnt create_entity(weapon)
    
    if(!
is_valid_ent(wEnt)) 
        return 
0

    entity_set_int
(wEntEV_INT_spawnflagsSF_NORESPAWN)
    
DispatchSpawn(wEnt)

    if(!
ExecuteHamB(Ham_AddPlayerItem,id,wEnt))
    {
        if(
is_valid_ent(wEnt)) entity_set_int(wEntEV_INT_flagsentity_get_int(wEntEV_INT_flags) | FL_KILLME)
        return 
0
    
}

    
ExecuteHamB(Ham_Item_AttachToPlayer,wEnt,id)
    return 
1
}

stock ham_strip_weapon(idweapon[])
{
    if(!
equal(weapon,"weapon_",7)) 
        return 
0
    
    
new wId get_weaponid(weapon)
    
    if(!
wId) return 0
    
    
new wEnt
    
    
while((wEnt find_ent_by_class(wEntweapon)) && entity_get_edict(wEntEV_ENT_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_KillwEnt)
    
    
entity_set_int(idEV_INT_weaponsentity_get_int(idEV_INT_weapons) & ~(1<<wId))

    return 
1
}  

stock fm_set_weapon_ammo(entityamount)
{
    
set_pdata_int(entityOFFSET_CLIPAMMOamountOFFSET_LINUX_WEAPONS);
}

stock fm_get_user_lastprimaryitem(id// Thanks to joaquimandrade
{
    if(
get_pdata_cbase(idOFFSET_LASTPRIMARYITEM) != -1)
        return 
1;
        
    return 
0;




plasmagun
PHP Code:
/*================================================================================
 
            ---------------------------
            [ZP] Extra Item: Plasma Gun
            ---------------------------

        Plasma Gun
        Copyright (C) 2017 by Crazy

        -------------------
        -*- Description -*-
        -------------------

        This plugin add a new weapon into your zombie plague mod with
        the name of Plasma Gun. That weapon launch powerfull green lasers!
        When the bullet of this weapon hit any object, a nice effect appers!

        ----------------
        -*- Commands -*-
        ----------------

        * zp_give_plasma_gun <target> - Give the item to target.

        -------------
        -*- Cvars -*-
        -------------

        * zp_plasma_gun_ammo <number> - Ammo amout.
        * zp_plasma_gun_clip <number> - Clip amout. (Max: 100)
        * zp_plasma_gun_one_round <0/1> - Only one round.
        * zp_plasma_gun_damage <number> - Damage multiplier.
        * zp_plasma_gun_unlimited <0/1> - Unlimited ammunition.

        ------------------
        -*- Change Log -*-
        ------------------

        * v0.1: (Mar 2017)
            - First release;

        ---------------
        -*- Credits -*-
        ---------------

        * MeRcyLeZZ: for the nice zombie plague mod.
        * Crazy: created the extra item code.
        * deanamx: for the nice weapon model.
        * And all zombie-mod players that use this weapon.


=================================================================================*/

#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>
#include <cs_ham_bots_api>

/*================================================================================
 [Plugin Customization]
=================================================================================*/

// Item Name
#define ITEM_NAME "Plasma Gun"

// Item Cost
#define ITEM_COST 70

/*================================================================================
 Customization ends here! Yes, that's it. Editing anything beyond
 here is not officially supported. Proceed at your own risk...
=================================================================================*/

new const PLUGIN_VERSION[] = "v0.1";

new const 
V_PLASMAGUN_MDL[64] = "models/zombie_plague/v_plasma_gun.mdl";
new const 
P_PLASMAGUN_MDL[64] = "models/zombie_plague/p_plasma_gun.mdl";
new const 
W_PLASMAGUN_MDL[64] = "models/zombie_plague/w_plasma_gun.mdl";

new const 
PLASMAGUN_SOUNDS[][] = { "weapons/plasmagun_aug-1.wav""weapons/plasmagun_aug-2.wav""weapons/plasmagun_clipin1.wav",  "weapons/plasmagun_clipin2.wav""weapons/plasmagun_clipout.wav""weapons/plasmagun_draw.wav""weapons/plasmagun_exp.wav""weapons/plasmagun_idle.wav" };

new 
g_has_plasmagun[33], g_plasmagung_msgWeaponListg_plasmabombg_xenobeamg_event_plasmagung_playername[33][32], g_maxplayersg_primary_attackg_plasmagun_reload_clip[33], cvar_plasmagun_clipcvar_plasmagun_ammocvar_plasmagun_damagecvar_plasmagun_oneroundcvar_plasgun_infinit;

new const 
GUNSHOT_DECALS[] = { 4142434445 };

const 
m_iClip 51;
const 
m_flNextAttack 83;
const 
m_fInReload 54;

const 
OFFSET_WEAPON_OWNER 41;
const 
OFFSET_LINUX_WEAPONS 4;
const 
OFFSET_LINUX 5;
const 
OFFSET_ACTIVE_ITEM 373;

const 
PLASMAGUN_KEY 054687;

const 
WEAPON_BITSUM = ((1<<CSW_SCOUT) | (1<<CSW_XM1014) | (1<<CSW_MAC10) | (1<<CSW_AUG) | (1<<CSW_UMP45) | (1<<CSW_SG550) | (1<<CSW_P90) | (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_GALIL));

enum
{
    
idle 0,
    
reload,
    
draw,
    
shoot1,
    
shoot2,
    
shoot3
}

public 
plugin_init()
{
    
/* Plugin register */
    
register_plugin("[ZP] Extra Item: Plasma Gun"PLUGIN_VERSION"Crazy");

    
/* Item register */
    
g_plasmagun zp_register_extra_item(ITEM_NAMEITEM_COSTZP_TEAM_HUMAN);

    
/* Events */
    
register_event("HLTV""event_round_start""a""1=0""2=0");

    
/* Messages */
    
register_message(get_user_msgid("CurWeapon"), "message_cur_weapon");

    
/* Admin command */
    
register_concmd("zp_give_plasmagun""cmd_give_plasmagun"0);

    
/* Forwards */
    
register_forward(FM_UpdateClientData"fw_UpdateData_Post"1);
    
register_forward(FM_SetModel"fw_SetModel");
    
register_forward(FM_PlaybackEvent"fw_PlaybackEvent");

    
/* Ham Forwards */
    
RegisterHam(Ham_TraceAttack"worldspawn""fw_TraceAttack_Post"1);
    
RegisterHam(Ham_TraceAttack"func_breakable""fw_TraceAttack_Post"1);
    
RegisterHam(Ham_TraceAttack"func_wall""fw_TraceAttack_Post"1);
    
RegisterHam(Ham_TraceAttack"func_door""fw_TraceAttack_Post"1);
    
RegisterHam(Ham_TraceAttack"func_door_rotating""fw_TraceAttack_Post"1);
    
RegisterHam(Ham_TraceAttack"func_plat""fw_TraceAttack_Post"1);
    
RegisterHam(Ham_TraceAttack"func_rotating""fw_TraceAttack_Post"1);
    
RegisterHam(Ham_Item_Deploy"weapon_aug""fw_Item_Deploy_Post"1);
    
RegisterHam(Ham_Item_AddToPlayer"weapon_aug""fw_Item_AddToPlayer_Post"1);
    
RegisterHam(Ham_Item_PostFrame"weapon_aug""fw_Item_PostFrame");
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_aug""fw_PrimaryAttack");
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_aug""fw_PrimaryAttack_Post"1);
    
RegisterHam(Ham_Weapon_Reload"weapon_aug""fw_Reload");
    
RegisterHam(Ham_Weapon_Reload"weapon_aug""fw_Reload_Post"1);
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage");
    
RegisterHamBots(Ham_TakeDamage"fw_TakeDamage");

    
/* Cvars */
    
cvar_plasmagun_clip register_cvar("zp_plasma_gun_clip""30");
    
cvar_plasmagun_ammo register_cvar("zp_plasma_gun_ammo""200");
    
cvar_plasmagun_damage register_cvar("zp_plasma_gun_damage""2.5");
    
cvar_plasmagun_oneround register_cvar("zp_plasma_gun_one_round""0");
    
cvar_plasgun_infinit register_cvar("zp_plasma_gun_unlimited""0");

    
/* Max Players */
    
g_maxplayers get_maxplayers()

    
/* Message hook */
    
g_msgWeaponList get_user_msgid("WeaponList");
}

public 
plugin_precache()
{
    
engfunc(EngFunc_PrecacheModelV_PLASMAGUN_MDL);
    
engfunc(EngFunc_PrecacheModelP_PLASMAGUN_MDL);
    
engfunc(EngFunc_PrecacheModelW_PLASMAGUN_MDL);

    
engfunc(EngFunc_PrecacheGeneric"sprites/weapon_plasmagun.txt");
    
engfunc(EngFunc_PrecacheGeneric"sprites/640hud3_plasma.spr");
    
engfunc(EngFunc_PrecacheGeneric"sprites/640hud91_plasma.spr");

    
g_plasmabomb engfunc(EngFunc_PrecacheModel"sprites/plasmabomb.spr");
    
g_xenobeam engfunc(EngFunc_PrecacheModel"sprites/xenobeam.spr");

    for (new 
0sizeof PLASMAGUN_SOUNDSi++)
    
engfunc(EngFunc_PrecacheSoundPLASMAGUN_SOUNDS[i]);

    
register_forward(FM_PrecacheEvent"fw_PrecacheEvent_Post"1);
    
register_clcmd("weapon_plasmagun""cmd_plasma_selected");
}

public 
zp_user_infected_post(id)
{
    
g_has_plasmagun[id] = false;
}

public 
zp_user_humanized_post(id)
{
    
g_has_plasmagun[id] = false;
}

public 
client_putinserver(id)
{
    
g_has_plasmagun[id] = false;

    
get_user_name(idg_playername[id], charsmax(g_playername[]));
}

public 
event_round_start()
{
    for (new 
id 0id <= g_maxplayersid++)
    {
        if (
get_pcvar_num(cvar_plasmagun_oneround))
        
g_has_plasmagun[id] = false;
    }
}

public 
cmd_give_plasmagun(idlevelcid)
{
    if ((
get_user_flags(id) & level) != level)
        return 
PLUGIN_HANDLED;

    static 
arg[32], player;
    
read_argv(1argcharsmax(arg));
    
player cmd_target(idarg, (CMDTARGET_ONLY_ALIVE CMDTARGET_ALLOW_SELF));
    
    if (!
player)
        return 
PLUGIN_HANDLED;

    if (
g_has_plasmagun[player])
    {
        
client_print(idprint_chat"[ZP] The %s already have the %s."g_playername[player], ITEM_NAME);
        return 
PLUGIN_HANDLED;
    }

    
give_plasmagun(player);
    
    
client_print(playerprint_chat"[ZP] You won a %s from %s!"ITEM_NAMEg_playername[id]);

    return 
PLUGIN_HANDLED;
}

public 
cmd_plasma_selected(client)
{
    
engclient_cmd(client"weapon_aug");
    return 
PLUGIN_HANDLED;
}

public 
message_cur_weapon(msg_idmsg_destmsg_entity)
{
    if (!
is_user_alive(msg_entity))
        return;

    if (!
g_has_plasmagun[msg_entity])
        return;

    if (
get_user_weapon(msg_entity) != CSW_AUG)
        return;

    if (
get_msg_arg_int(1) != 1)
        return;

    if (
get_pcvar_num(cvar_plasgun_infinit))
    {
        static 
ent;
        
ent fm_cs_get_current_weapon_ent(msg_entity);

        if (!
pev_valid(ent))
            return;

        
cs_set_weapon_ammo(entget_pcvar_num(cvar_plasmagun_clip));
        
set_msg_arg_int(3get_msg_argtype(3), get_pcvar_num(cvar_plasmagun_clip));
    }
}

public 
zp_extra_item_selected(iditemid)
{
    if (
itemid != g_plasmagun)
        return;

    if (
g_has_plasmagun[id])
    {
        
client_print(idprint_chat"[ZP] You already have the %s."ITEM_NAME);
        return;
    }

    
give_plasmagun(id);

    
client_print(idprint_chat"[ZP] You bought the %s."ITEM_NAME);
}

public 
fw_UpdateData_Post(idsendweaponscd_handle)
{
    if (!
is_user_alive(id))
        return 
FMRES_IGNORED;

    if (!
g_has_plasmagun[id])
        return 
FMRES_IGNORED;

    if (
get_user_weapon(id) != CSW_AUG)
        return 
FMRES_IGNORED;

    
set_cd(cd_handleCD_flNextAttackhalflife_time() + 0.001);

    return 
FMRES_IGNORED;
}

public 
fw_SetModel(ent, const model[])
{
    if (!
pev_valid(ent))
        return 
FMRES_IGNORED;

    if (!
equal(model"models/w_aug.mdl"))
        return 
HAM_IGNORED;

    static 
class_name[33];
    
pev(entpev_classnameclass_namecharsmax(class_name));

    if (!
equal(class_name"weaponbox"))
        return 
FMRES_IGNORED;

    static 
ownerweapon;
    
owner pev(entpev_owner);
    
weapon find_ent_by_owner(-1"weapon_aug"ent);

    if (!
g_has_plasmagun[owner] || !pev_valid(weapon))
        return 
FMRES_IGNORED;

    
g_has_plasmagun[owner] = false;

    
set_pev(weaponpev_impulsePLASMAGUN_KEY);

    
engfunc(EngFunc_SetModelentW_PLASMAGUN_MDL);

    return 
FMRES_SUPERCEDE;
}

public 
fw_PlaybackEvent(flagsinvokereventidFloat:delayFloat:origin[3], Float:angles[3], Float:fparam1Float:fparam2iParam1iParam2bParam1bParam2)
{
    if ((
eventid != g_event_plasmagun) || !g_primary_attack)
        return 
FMRES_IGNORED;

    if (!(
<= invoker <= g_maxplayers))
        return 
FMRES_IGNORED;

    
playback_event(flags FEV_HOSTONLYinvokereventiddelayoriginanglesfparam1fparam2iParam1iParam2bParam1bParam2);

    return 
FMRES_SUPERCEDE;
}

public 
fw_PrecacheEvent_Post(type, const name[])
{
    if (!
equal("events/aug.sc"name))
        return 
HAM_IGNORED;

    
g_event_plasmagun get_orig_retval()

    return 
FMRES_HANDLED;
}

public 
fw_Item_Deploy_Post(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[id])
        return 
HAM_IGNORED;

    
set_pev(idpev_viewmodel2V_PLASMAGUN_MDL);
    
set_pev(idpev_weaponmodel2P_PLASMAGUN_MDL);

    
play_weapon_anim(iddraw);

    return 
HAM_IGNORED;
}

public 
fw_Item_AddToPlayer_Post(entid)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    if (!
is_user_connected(id))
        return 
HAM_IGNORED;

    if (
pev(entpev_impulse) == PLASMAGUN_KEY)
    {
        
g_has_plasmagun[id] = true;
        
set_pev(entpev_impulse0);
    }

    
message_begin(MSG_ONEg_msgWeaponList_id)
    
write_string((g_has_plasmagun[id] ? "weapon_plasmagun" "weapon_aug"))
    
write_byte(4)
    
write_byte(90)
    
write_byte(-1)
    
write_byte(-1)
    
write_byte(0)
    
write_byte(14)
    
write_byte(CSW_AUG)
    
write_byte(0)
    
message_end()

    return 
HAM_IGNORED;
}

public 
fw_Item_PostFrame(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[id])
        return 
HAM_IGNORED;

    static 
cvar_clipcvar_clip get_pcvar_num(cvar_plasmagun_clip);

    new 
clip get_pdata_int(entm_iClipOFFSET_LINUX_WEAPONS);
    new 
bpammo cs_get_user_bpammo(idCSW_AUG);

    new 
Float:flNextAttack get_pdata_float(idm_flNextAttackOFFSET_LINUX);
    new 
fInReload get_pdata_int(entm_fInReloadOFFSET_LINUX_WEAPONS);

    if (
fInReload && flNextAttack <= 0.0)
    {
        new 
temp_clip min(cvar_clip clipbpammo);

        
set_pdata_int(entm_iClipclip temp_clipOFFSET_LINUX_WEAPONS);

        
cs_set_user_bpammo(idCSW_AUGbpammo-temp_clip);

        
set_pdata_int(entm_fInReload0OFFSET_LINUX_WEAPONS);

        
fInReload 0;
    }

    return 
HAM_IGNORED;
}

public 
fw_PrimaryAttack(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[id])
        return 
HAM_IGNORED;

    if (!
cs_get_weapon_ammo(ent))
        return 
HAM_IGNORED;

    
g_primary_attack true;

    return 
HAM_IGNORED;
}

public 
fw_PrimaryAttack_Post(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[id])
        return 
HAM_IGNORED;

    if (!
cs_get_weapon_ammo(ent))
        return 
HAM_IGNORED;

    
g_primary_attack false;

    
play_weapon_anim(idrandom_num(shoot1shoot2));

    
emit_sound(idCHAN_WEAPONPLASMAGUN_SOUNDS[random_num(01)], VOL_NORMATTN_NORM0PITCH_NORM);

    
make_xenobeam(id);

    return 
HAM_IGNORED;
}

public 
fw_Reload(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[id])
        return 
HAM_IGNORED;

    
g_plasmagun_reload_clip[id] = -1;

    static 
cvar_clipcvar_clip get_pcvar_num(cvar_plasmagun_clip);

    new 
clip get_pdata_int(entm_iClipOFFSET_LINUX_WEAPONS);
    new 
bpammo cs_get_user_bpammo(idCSW_AUG);

    if (
bpammo <= 0)
        return 
HAM_SUPERCEDE;

    if (
clip >= cvar_clip)
        return 
HAM_SUPERCEDE;
    
    
g_plasmagun_reload_clip[id] = clip;

    return 
HAM_IGNORED;
}

public 
fw_Reload_Post(ent)
{
    if (!
pev_valid(ent))
        return 
HAM_IGNORED;

    new 
id get_pdata_cbase(entOFFSET_WEAPON_OWNEROFFSET_LINUX_WEAPONS);

    if (!
is_user_alive(id))
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[id])
        return 
HAM_IGNORED;

    if (
g_plasmagun_reload_clip[id] == -1)
        return 
HAM_IGNORED;

    
set_pdata_int(entm_iClipg_plasmagun_reload_clip[id], OFFSET_LINUX_WEAPONS);
    
set_pdata_int(entm_fInReload1OFFSET_LINUX_WEAPONS);

    
play_weapon_anim(idreload);

    return 
HAM_IGNORED;
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damagedmg_bits)
{
    if (!
is_user_alive(attacker))
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[attacker])
        return 
HAM_IGNORED;

    if (
get_user_weapon(attacker) != CSW_AUG)
        return 
HAM_IGNORED;

    
SetHamParamFloat(OFFSET_LINUX_WEAPONSdamage get_pcvar_float(cvar_plasmagun_damage));

    return 
HAM_IGNORED;
}

public 
fw_TraceAttack_Post(entattackerFloat:damageFloat:dir[3], ptrdmg_bits)
{
    if (!
is_user_alive(attacker))
        return 
HAM_IGNORED;

    if (
get_user_weapon(attacker) != CSW_AUG)
        return 
HAM_IGNORED;

    if (!
g_has_plasmagun[attacker])
        return 
HAM_IGNORED;

    static 
Float:end[3];
    
get_tr2(ptrTR_vecEndPosend);

    if(
ent)
    {
        
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(ent)
        
message_end()
    }
    else
    {
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_SPRITE)
        
engfunc(EngFunc_WriteCoordend[0])
        
engfunc(EngFunc_WriteCoordend[1])
        
engfunc(EngFunc_WriteCoordend[2])
        
write_short(g_plasmabomb)
        
write_byte(10)
        
write_byte(200)
        
message_end()
    }

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_GUNSHOTDECAL)
    
engfunc(EngFunc_WriteCoordend[0])
    
engfunc(EngFunc_WriteCoordend[1])
    
engfunc(EngFunc_WriteCoordend[2])
    
write_short(attacker)
    
write_byte(GUNSHOT_DECALS[random_num (0sizeof GUNSHOT_DECALS -1)])
    
message_end()

    return 
HAM_IGNORED;
}

give_plasmagun(id)
{
    
drop_primary(id);

    
g_has_plasmagun[id] = true;

    new 
weapon fm_give_item(id"weapon_aug");

    
cs_set_weapon_ammo(weaponget_pcvar_num(cvar_plasmagun_clip));
    
cs_set_user_bpammo(idCSW_AUGget_pcvar_num(cvar_plasmagun_ammo));
}

play_weapon_anim(idframe)
{
    
set_pev(idpev_weaponanimframe);

    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player id)
    
write_byte(frame)
    
write_byte(pev(idpev_body))
    
message_end()
}

drop_primary(id)
{
    static 
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);
        }
    }
}

make_xenobeam(id)
{
    static 
originF[3];
    
get_user_origin(idoriginF3);

    
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
    
write_byte(TE_BEAMENTPOINT)
    
write_short(id 0x1000)
    
write_coord(originF[0])
    
write_coord(originF[1])
    
write_coord(originF[2])
    
write_short(g_xenobeam)
    
write_byte(0)
    
write_byte(0)
    
write_byte(1)
    
write_byte(20)
    
write_byte(0)
    
write_byte(110)
    
write_byte(251)
    
write_byte(110)
    
write_byte(200)
    
write_byte(5)
    
message_end()
}

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_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 fm_cs_get_current_weapon_ent(id)
{
    if (
pev_valid(id) != 2)
        return -
1;
    
    return 
get_pdata_cbase(idOFFSET_ACTIVE_ITEMOFFSET_LINUX);



Sandbags
PHP Code:
/*================================================================================
    
    -----------------------------------
    -*- [ZP] Sandbags -*-
    -----------------------------------
    
    ~~~~~~~~~~~~~~~
    - Description -
    ~~~~~~~~~~~~~~~
    
    Original by SAMURAI, Upgraded to zp by LARP
    [email protected] (Chile) Languaje spanish!
    
================================================================================*/


#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>
#include <fun>
#include <zombieplague.inc>

// The sizes of models
#define PALLET_MINS Float:{ -27.260000, -22.280001, -22.290001 }
#define PALLET_MAXS Float:{  27.340000,  26.629999,  29.020000 }


// from fakemeta util by VEN
#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)
#define fm_remove_entity(%1) engfunc(EngFunc_RemoveEntity, %1)
// this is mine
#define fm_drop_to_floor(%1) engfunc(EngFunc_DropToFloor,%1)

// cvars
new pnumpluginremove_nrndmaxpalletsphealth;

// num of pallets with bags
new palletscout 0;

/* Models for pallets with bags .
  Are available 2 models, will be set a random of them  */
new g_models[][] =
{
    
"models/pallet_with_bags2.mdl",
    
"models/pallet_with_bags.mdl"
}

new 
stuck[33]
new 
g_bolsas[33];
new 
cvar[3]

new const 
Float:size[][3] = {
    {
0.00.01.0}, {0.00.0, -1.0}, {0.01.00.0}, {0.0, -1.00.0}, {1.00.00.0}, {-1.00.00.0}, {-1.01.01.0}, {1.01.01.0}, {1.0, -1.01.0}, {1.01.0, -1.0}, {-1.0, -1.01.0}, {1.0, -1.0, -1.0}, {-1.01.0, -1.0}, {-1.0, -1.0, -1.0},
    {
0.00.02.0}, {0.00.0, -2.0}, {0.02.00.0}, {0.0, -2.00.0}, {2.00.00.0}, {-2.00.00.0}, {-2.02.02.0}, {2.02.02.0}, {2.0, -2.02.0}, {2.02.0, -2.0}, {-2.0, -2.02.0}, {2.0, -2.0, -2.0}, {-2.02.0, -2.0}, {-2.0, -2.0, -2.0},
    {
0.00.03.0}, {0.00.0, -3.0}, {0.03.00.0}, {0.0, -3.00.0}, {3.00.00.0}, {-3.00.00.0}, {-3.03.03.0}, {3.03.03.0}, {3.0, -3.03.0}, {3.03.0, -3.0}, {-3.0, -3.03.0}, {3.0, -3.0, -3.0}, {-3.03.0, -3.0}, {-3.0, -3.0, -3.0},
    {
0.00.04.0}, {0.00.0, -4.0}, {0.04.00.0}, {0.0, -4.00.0}, {4.00.00.0}, {-4.00.00.0}, {-4.04.04.0}, {4.04.04.0}, {4.0, -4.04.0}, {4.04.0, -4.0}, {-4.0, -4.04.0}, {4.0, -4.0, -4.0}, {-4.04.0, -4.0}, {-4.0, -4.0, -4.0},
    {
0.00.05.0}, {0.00.0, -5.0}, {0.05.00.0}, {0.0, -5.00.0}, {5.00.00.0}, {-5.00.00.0}, {-5.05.05.0}, {5.05.05.0}, {5.0, -5.05.0}, {5.05.0, -5.0}, {-5.0, -5.05.0}, {5.0, -5.0, -5.0}, {-5.05.0, -5.0}, {-5.0, -5.0, -5.0}
}

new const 
g_item_name[] = { "15 Sandbags" }
const 
g_item_bolsas 0
new g_itemid_bolsas
new ZPSTUCKg_BINDMODEg_MSGMODE

/*************************************************************
************************* AMXX PLUGIN *************************
**************************************************************/


public plugin_init() 
{
    
/* Register the plugin */
    //register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
    
    
register_plugin("[ZP] Extra: SandBags""1.1""LARP")
    
set_task(0.1,"checkstuck",0,"",0,"b")
    
g_itemid_bolsas zp_register_extra_item(g_item_nameg_item_bolsasZP_TEAM_HUMAN)
    
/* Register the cvars */
    
g_BINDMODE    register_cvar("zp_pb_bind","0");        //Auto bind L Key!
    
g_MSGMODE    register_cvar("zp_pb_msg","1");        //
    
ZPSTUCK register_cvar("zp_pb_stuck","1")
    
pnumplugin register_cvar("zp_pb_enable","1"); // 1 = ON ; 0 = OFF
    
remove_nrnd register_cvar("zp_pb_remround","1");
    
maxpallets register_cvar("zp_pb_limit","200"); // max number of pallets with bags
    
phealth register_cvar("zp_pb_health","200"); // set the health to a pallet with bags
    
    /* Game Events */
    
register_event("HLTV","event_newround""a","1=0""2=0"); // it's called every on new round
    
    /* This is for menuz: */
    
register_menucmd(register_menuid("\ySand Bags:"), 1023"menu_command" );
    
register_clcmd("say /pb","show_the_menu");
    
register_clcmd("/pb","show_the_menu");
    
//cvar[0] = register_cvar("zp_autounstuck","1")
    
cvar[1] = register_cvar("zp_pb_stuckeffects","1")
    
cvar[2] = register_cvar("zp_pb_stuckwait","7")

}


public 
plugin_precache()
{
    for(new 
i;sizeof g_models;i++)
        
engfunc(EngFunc_PrecacheModel,g_models[i]);
}

public 
show_the_menu(id,level,cid)
{
    
// check if user doesen't have admin 
    /*if( ! cmd_access( id,level, cid , 0 ))
        return PLUGIN_HANDLED;
    */
    
    // check if the plugin cvar is turned off
    
if( ! get_pcvar_numpnumplugin ) )
        return 
PLUGIN_HANDLED;
        
        
    
// check if user isn't alive
    
if( ! is_user_aliveid ) )
    {
        
client_printidprint_chat"" ); //msg muerto
        
return PLUGIN_HANDLED;
    }
            
    if ( !
zp_get_user_zombie(id) )
    {        
        new 
szMenuBody[256];
        new 
keys;
        
        new 
nLen formatszMenuBody255"\ySand Bags:^n" );
        
nLen += formatszMenuBody[nLen], 255-nLen"^n\w1. Place a Sandbags (%i Remaining)"g_bolsas[id] );
        
//nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. Remove a pallet with bags" );
        
nLen += formatszMenuBody[nLen], 255-nLen"^n^n\w0. Exit" );

        
keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<9)

        
show_menuidkeysszMenuBody, -);

        
// depends what you want, if is continue will appear on chat what the admin sayd
        
return PLUGIN_HANDLED;
    }
    
client_print(idprint_chat"[ZP] The zombies can not use this command!")
    return 
PLUGIN_HANDLED;
}


public 
menu_command(id,key,level,cid)
{
    
    switch( 
key )
    {
        
// place a pallet with bags
        
case 0
        {
            if ( !
zp_get_user_zombie(id) )
            {
                new 
money g_bolsas[id]
                if ( 
money )
                {
                    if ( 
get_pcvar_num(g_MSGMODE) == )
                        {
                            
set_hudmessage(001000.800.8006.02.01.01.0)
                            
show_hudmessage(id"You do not have to^nplace sandbags")
                            return 
PLUGIN_CONTINUE
                        
}
                    
client_print(idprint_chat"[ZP] You do not have to place sandbags!")
                    return 
PLUGIN_CONTINUE
                
}
                
g_bolsas[id]-= 1
                place_palletwbags
(id);
                
show_the_menu(id,level,cid);
                return 
PLUGIN_CONTINUE    
            
}
            
client_print(idprint_chat"[ZP] The zombies can not use this!!")
            return 
PLUGIN_CONTINUE    
        
}
        
        
// remove a pallet with bags
        /*case 1:
        {
            if ( !zp_get_user_zombie(id) )
            {
                new ent, body, class[32];
                get_user_aiming(id, ent, body);
                if (pev_valid(ent)) 
                {
                    pev(ent, pev_classname, class, 31);
                    
                    if (equal(class, "amxx_pallets")) 
                    {
                        g_bolsas[id]+= 1
                        fm_remove_entity(ent);
                    }
                    
                    else
                        client_print(id, print_chat, "[ZP] You are not aiming at a pallet with bags");
                }
                else
                    client_print(id, print_chat, "[ZP] You are not aiming at a valid entity !");
                    
                show_the_menu(id,level,cid);
            }
        }
        */
        
        // remove all pallets with bags
        /*case 2:
        {
            g_bolsas[id]= 0
            remove_allpalletswbags();
            client_print(id,print_chat,"[AMXX] You removed all pallets with bags !");
            show_the_menu(id,level,cid);
        }
            */
            
    
}
    
    return 
PLUGIN_HANDLED;
}



public 
place_palletwbags(id)
{
    
    if( 
palletscout == get_pcvar_num(maxpallets) )
    {
        
client_print(id,print_chat,"[ZP] For security reasons only allow %d Sandbags on the server!",get_pcvar_num(maxpallets));
        return 
PLUGIN_HANDLED;
    }
    
    
// create a new entity 
    
new ent engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"func_wall"));
    
    
    
// set a name to the entity
    
set_pev(ent,pev_classname,"amxx_pallets");
    
    
// set model        
    
engfunc(EngFunc_SetModel,ent,g_models[random(sizeof g_models)]);
    
    
// register a new var. for origin
    
static Float:xorigin[3];
    
get_user_hitpoint(id,xorigin);
    
    
    
// check if user is aiming at the air 
    
if(engfunc(EngFunc_PointContents,xorigin) == CONTENTS_SKY)
    {
        
client_print(id,print_chat,"[ZP] You can not put sandbags in the sky!");
        return 
PLUGIN_HANDLED;
    }
    
    
    
// set sizes
    
static Float:p_mins[3], Float:p_maxs[3];
    
p_mins PALLET_MINS;
    
p_maxs PALLET_MAXS;
    
engfunc(EngFunc_SetSizeentp_minsp_maxs);
    
set_pev(entpev_minsp_mins);
    
set_pev(entpev_maxsp_maxs );
    
set_pev(entpev_absminp_mins);
    
set_pev(entpev_absmaxp_maxs );

    
    
// set the rock of origin where is user placed
    
engfunc(EngFunc_SetOriginentxorigin);
    
    
    
// make the rock solid
    
set_pev(ent,pev_solid,SOLID_BBOX); // touch on edge, block
    
    // set the movetype
    
set_pev(ent,pev_movetype,MOVETYPE_FLY); // no gravity, but still collides with stuff
    
    // now the damage stuff, to set to take it or no
    // if you set the cvar "pallets_wbags_health" 0, you can't destroy a pallet with bags
    // else, if you want to make it destroyable, just set the health > 0 and will be
    // destroyable.
    
new Float:p_cvar_health get_pcvar_float(phealth);
    switch(
p_cvar_health)
    {
        case 
0.0 :
        {
            
set_pev(ent,pev_takedamage,DAMAGE_NO);
        }
        
        default :
        {
            
set_pev(ent,pev_health,p_cvar_health);
            
set_pev(ent,pev_takedamage,DAMAGE_YES);
        }
    }
    
            
    static 
Float:rvec[3];
    
pev(id,pev_v_angle,rvec);
    
    
rvec[0] = 0.0;
    
    
set_pev(ent,pev_angles,rvec);
    
    
// drop entity to floor
    
fm_drop_to_floor(ent);
    
    
// num ..
    
palletscout++;
    
    
// confirm message
    
if ( get_pcvar_num(g_MSGMODE) == )
    {
        
set_hudmessage(001000.800.8006.02.01.01.0)
        
show_hudmessage(id"You placed a SandBag^n%i Remaining"g_bolsas[id])
        return 
PLUGIN_HANDLED
    
}
    
client_print(idprint_chat"[ZP] You have placed a Sandbag.")
    return 
PLUGIN_HANDLED;
}
    
/* ====================================================
get_user_hitpoin stock . Was maked by P34nut, and is 
like get_user_aiming but is with floats and better :o
====================================================*/    
stock get_user_hitpoint(idFloat:hOrigin[3]) 
{
    if ( ! 
is_user_aliveid ))
        return 
0;
    
    new 
Float:fOrigin[3], Float:fvAngle[3], Float:fvOffset[3], Float:fvOrigin[3], Float:feOrigin[3];
    new 
Float:fTemp[3];
    
    
pev(idpev_originfOrigin);
    
pev(idpev_v_anglefvAngle);
    
pev(idpev_view_ofsfvOffset);
    
    
xs_vec_add(fOriginfvOffsetfvOrigin);
    
    
engfunc(EngFunc_AngleVectorsfvAnglefeOriginfTempfTemp);
    
    
xs_vec_mul_scalar(feOrigin9999.9feOrigin);
    
xs_vec_add(fvOriginfeOriginfeOrigin);
    
    
engfunc(EngFunc_TraceLinefvOriginfeOrigin0id);
    
global_get(glb_trace_endposhOrigin);
    
    return 
1;



/* ====================================================
This is called on every round, at start up,
with HLTV logevent. So if the "pallets_wbags_nroundrem"
cvar is set to 1, all placed pallets with bugs will be
removed.
====================================================*/
public event_newround()
{
    if( 
get_pcvar_num remove_nrnd ) == 1)
        
remove_allpalletswbags();
        
}


/* ====================================================
This is a stock to help for remove all pallets with
bags placed . Is called on new round if the cvar
"pallets_wbags_nroundrem" is set 1.
====================================================*/
stock remove_allpalletswbags()
{
    new 
pallets = -1;
    while((
pallets fm_find_ent_by_class(pallets"amxx_pallets")))
        
fm_remove_entity(pallets);
        
    
palletscout 0;
}

public 
checkstuck() {
    if ( 
get_pcvar_num(ZPSTUCK) == )
    {
        static 
players[32], pnumplayer
        get_players
(playerspnum)
        static 
Float:origin[3]
        static 
Float:mins[3], hull
        
static Float:vec[3]
        static 
o,i
        
for(i=0i<pnumi++){
            
player players[i]
            if (
is_user_connected(player) && is_user_alive(player)) {
                
pev(playerpev_originorigin)
                
hull pev(playerpev_flags) & FL_DUCKING HULL_HEAD HULL_HUMAN
                
if (!is_hull_vacant(originhull,player) && !get_user_noclip(player) && !(pev(player,pev_solid) & SOLID_NOT)) {
                    ++
stuck[player]
                    if(
stuck[player] >= get_pcvar_num(cvar[2])) {
                        
pev(playerpev_minsmins)
                        
vec[2] = origin[2]
                        for (
o=0sizeof size; ++o) {
                            
vec[0] = origin[0] - mins[0] * size[o][0]
                            
vec[1] = origin[1] - mins[1] * size[o][1]
                            
vec[2] = origin[2] - mins[2] * size[o][2]
                            if (
is_hull_vacant(vechull,player)) {
                                
engfunc(EngFunc_SetOriginplayervec)
                                
effects(player)
                                
set_pev(player,pev_velocity,{0.0,0.0,0.0})
                                
sizeof size
                            
}
                        }
                    }
                }
                else
                {
                    
stuck[player] = 0
                
}
            }
        }
    
    }
    
}

stock bool:is_hull_vacant(const Float:origin[3], hull,id) {
    static 
tr
    engfunc
(EngFunc_TraceHulloriginorigin0hullidtr)
    if (!
get_tr2(trTR_StartSolid) || !get_tr2(trTR_AllSolid)) //get_tr2(tr, TR_InOpen))
        
return true
    
    
return false
}

public 
effects(id) {
    if(
get_pcvar_num(cvar[1])) {
        
set_hudmessage(255,150,50, -1.00.6506.01.5,0.1,0.7// HUDMESSAGE
        
show_hudmessage(id,"Automatic Unstuck!"// HUDMESSAGE
        
message_begin(MSG_ONE_UNRELIABLE,105,{0,0,0},id )      
        
write_short(1<<10)   // fade lasts this long duration
        
write_short(1<<10)   // fade lasts this long hold time
        
write_short(1<<1)   // fade type (in / out)
        
write_byte(20)            // fade red
        
write_byte(255)    // fade green
        
write_byte(255)        // fade blue
        
write_byte(255)    // fade alpha
        
message_end()
        
client_cmd(id,"spk fvox/blip.wav")
    }
}

public 
zp_extra_item_selected(playeritemid)
{
    if (
itemid == g_itemid_bolsas)
    {
        
g_bolsas[player]+= 15
        cmd_bind
(player)
        
set_task(0.3,"show_the_menu",player)
        if ( 
get_pcvar_num(g_MSGMODE) == )
        {
            
set_hudmessage(001000.800.8006.02.01.01.0)
            
show_hudmessage(player"Plugin By LARP^n    Chile 2008")
        }
    }

}

public 
cmd_bind(id)
{
    if ( 
get_pcvar_num(g_BINDMODE) == )
    {
        
client_print(idprint_chat"[ZP] You have %i sandbags, to use with the key 'L'"g_bolsas[id])
        
client_cmd(id,"bind l /pb")
        return 
PLUGIN_HANDLED
    
}
    
client_print(idprint_chat"[ZP] You have %i sandbags, to use type 'say /pb'"g_bolsas[id])
    return 
PLUGIN_HANDLED


__________________
Lord Of Darkness
Anz is offline
Reply



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 02:16.


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