Raised This Month: $ Target: $400
 0% 

Subplugin Submission [ZP] Extra Item: Grenade Launcher


Post New Thread Reply   
 
Thread Tools Display Modes
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 08-26-2011 , 21:49   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #131

@NiHi
I know how , just edit the clip to 10 and bpammo to 0 . If player buy it using the , and . it will still will be 10|0 clip . I've done that works fine .

P.S : Is it good if u can block the buy ammo command for this M79
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
arnux
BANNED
Join Date: Sep 2010
Old 08-30-2011 , 15:20   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #132

Hello,

First of all THANK YOU for this plugin, I really like it!

Could you please fix this error:

PHP Code:
Info (map "zm_dust2_new") (file "addons/amxmodx/logs/error_20110830.log")
L 08/30/2011 13:57:14: [AMXXDisplaying debug trace (plugin "zp_extra_m79.amxx")
L 08/30/2011 13:57:14: [AMXXRun time error 4index out of bounds 
L 08
/30/2011 13:57:14: [AMXX]    [0zp_extra_m79.sma::fw_LauncherDeploy_Post (line 566)
L 08/30/2011 13:57:15: [AMXXDisplaying debug trace (plugin "zp_extra_m79.amxx"
I'm using secondary weapon version.

Thank you in advance,
Arnas.
arnux is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 08-31-2011 , 00:25   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #133

His not checking this thread anymore , post your .sma here.
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
arnux
BANNED
Join Date: Sep 2010
Old 08-31-2011 , 05:18   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #134

Here is the sma:

PHP Code:
/*
    [ZP] Extra Item: M79 Grenade Launcher
    Copyright (C) 2009-2010 by NiHiLaNTh

    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.

    --- Introduction ---
    This plugin add new weapon to zombie plague - m79 grenade launcher.This
    is powerful weapon which shoot with grenades.It has 1 grenade in a clip
    and 10 in back pack.Also you can buy grenades for M79.To get this plugin
    work correctly, put plugin name in plugins-zplague.ini BEFORE MAIN PLUGIN.
    
    --- CVARs ---
    zp_m79_maxdmg 450 -- Maximal damage
    zp_m79_radius 500 -- Damage radius
    zp_m79_oneround 1 -- If 1 weapon will stay only 1 round
    zp_m79_knockback 10 -- Knockback power
    
    --- Credits ---
    NiHiLaNTh - Plugin
    Shalun - M79 model
    meTaLiCroSS - FM_SetModel, EV_INT_WEAPONKEY
    Arkshine - Play weapon animation stock/grenade angles
    
    --- Changelog ---
    v1.0 - Initial release 
    v1.1 - Completely rewrited plugin
    v1.2 - Fixed bug with unlimited ammo(Clip ammo updating correctly)
         - Removed a lot of unnecessary code
         - Fixed bug with reloading
    v1.3 - Fixed bug when m79 didnt disappear when zp_m79_oneround was set to 1     
*/
#include < zmvip >
#include < amxmodx >
#include < cstrike >
#include < engine >
#include < fakemeta >
#include < fakemeta_util >
#include < fun >
#include < hamsandwich >
#include < zombieplague >

// Version
#define VERSION "1.3"

// Maxplayers
#define MAXPLAYERS        32

// FCVAR stuff
#define FCVAR_FLAGS        ( FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED )

// Null
#define NULLENT            -1

// EV_INT field used to store ak47 index
#define EV_INT_WEAPONKEY    EV_INT_impulse

// pev_ field used to stor m79 bpammo
#define pev_weaponammo        pev_iuser2

// M79 weapon key
#define M79_WEAPONKEY        1756

// CS offsets
#define OFFSET_PLAYER        41
#define OFFSET_NEXTPRIMATTACK    46
#define OFFSET_NEXTSECATTACK    47
#define OFFSET_WEAPONIDLE    48
#define OFFSET_PRIMAMMOTYPE    49
#define OFFSET_CLIP        51
#define OFFSET_RELOAD        54
#define OFFSET_NEXTATTACK    83
#define OFFSET_PLAYERSLOT    376
#define LINUX_DIFF        4
#define LINUX_DIFF_WPN        5

//================================ Customization starts below ==============================
#define MAXCLIP            1 // I strictly recommend you to dont change this value!^^
#define MAXBPAMMO        10 // Bp ammo
#define RELOAD_TIME        3.2 // Don't set this lower that 3.0
#define REFIRE_RATE        1.5 // Refire rate
#define TRAIL_RED        255 // (0-255).Red amount in trail
#define TRAIL_GREEN        255 // (0-255).Green amount in trail
#define TRAIL_BLUE        255 // (0-255).Blue amount in trail

// Grenade model
new const grenade_model [ ] = "models/grenade.mdl"

// Sounds
new const fire_sound [ ] [ ] = { "weapons/m79_fire1.wav""weapons/m79_fire2.wav" }
new const 
sound_buy [ ] [ ] =  { "items/9mmclip1.wav" }
//================================ Customization end! =======================================
// Models
new const p_m79 [ ] = "models/p_m79.mdl"
new const v_m79 [ ] = "models/v_m79.mdl" // You should'nt change this model
new const w_m79 [ ] = "models/w_m79.mdl"

// Little note about sounds listed below.If you are using original weapon models (which are
// provdied in this plugin) DON'T CHANGE SOUND PATHS, or you'll not hear reload sound.
new const sound_reload [ ] [ ] = { "weapons/m79_clipin.wav""weapons/m79_clipon.wav""weapons/m79_clipout.wav" }

// Entities
new const g_DefaultEntity [ ] = "info_target"
new const g_GrenadeEntity [ ] = "zp_m79_grenade"
new const g_AkEntity [ ] = "weapon_deagle"
new const g_PlayerEntity [ ] = "player"

// Cached sprite indexes
new m_iTrailm_iExplo

// Player variables
new g_hasLauncher MAXPLAYERS+
new 
Float:g_LastShotTime MAXPLAYERS+]
new 
g_CurrentWeapon MAXPLAYERS+]

// Global variables
new g_MaxPlayersg_Restarted

// Booleans
new bool:bIsAlive MAXPLAYERS+]

// CVAR pointers
new cvar_maxdmgcvar_radiuscvar_oneroundcvar_knockback

// Item IDs
new g_m79g_m79nade

// Message ID
new g_msgScoreInfog_msgDeathMsgg_msgAmmoPickupg_msgCurWeapong_msgAmmoX

// Animation sequences
enum
{
    
m79_idle,
    
m79_shoot1// Shoot & Reload
    
m79_shoot2,
    
m79_draw
}

// Primary weapons bit-sum
//const PRIMARY_WEAPONS_BITSUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(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_P90)
const SECONDARY_WEAPONS_BITSUM = (1<<CSW_GLOCK18)|(1<<CSW_USP)|(1<<CSW_P228)|(1<<CSW_DEAGLE)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)

// Precache
public plugin_precache ( )
{
    
// Models
    
precache_model p_m79 )
    
precache_model v_m79 )
    
precache_model w_m79 )
    
precache_model grenade_model )
    
    
// Sound
    
new i
    
for ( sizeof fire_soundi++ )
        
precache_sound fire_sound ] )
    for ( 
sizeof sound_buyi++ )
        
precache_sound sound_buy ] )    
    for ( 
0sizeof sound_reloadi++ )
        
precache_sound sound_reload ] )

    
// Sprites
    
m_iTrail precache_model "sprites/laserbeam.spr" )
    
m_iExplo precache_model "sprites/zerogxplode.spr" )
}

// Initialization
public plugin_init ( )
{
    
// New plugin
    
register_plugin "[ZP] Extra Item:M79"VERSION"NiHiLaNTh" )
    
    
// Game-Monitor support
    
register_cvar "zp_m79_version"VERSIONFCVAR_FLAGS )
    
    
// New extra items
    
g_m79 zv_register_extra_item "M79""Grenade Launcher"25ZP_TEAM_HUMAN )
    
//g_m79nade = zp_register_extra_item ( "40mm M79 Grenade", 5, ZP_TEAM_HUMAN )
    
    // Buyammo1 commands from zombie plague
    
register_clcmd "buyammo1""clcmd_buyammo1" )
    
register_clcmd "buyammo2""clcmd_buyammo1" )
    
    
// Events
    
register_event("CurWeapon""Event_CurrentWeapon""be""1=1")
    
register_event("HLTV""Event_NewRound""a""1=0""2=0")
    
register_event("TextMsg""Event_GameRestart""a""2=#Game_Commencing""2=#Game_will_restart_in")
    
register_event "DeathMsg""Event_DeathMsg""a" )
    
    
// Forwards
    
register_forward FM_CmdStart"fw_CmdStart" )
    
register_forward FM_UpdateClientData"fw_UpdateClientData_Post")
    
register_forward FM_SetModel"fw_SetModel" )
    
RegisterHam Ham_Item_Deployg_AkEntity"fw_LauncherDeploy_Post")
    
RegisterHam Ham_Item_AddToPlayerg_AkEntity"fw_LauncherAddToPlayer" )
    
RegisterHam Ham_Item_PostFrameg_AkEntity"fw_LauncherPostFrame" )
    
RegisterHam Ham_Spawng_PlayerEntity"fw_PlayerSpawn_Post")
    
    
// Touch
    
register_touch g_GrenadeEntity"*""touch_m79nade" )
    
    
// CVARs
    
cvar_maxdmg register_cvar "zp_m79_maxdmg""450" )
    
cvar_radius register_cvar "zp_m79_radius""500" )
    
cvar_oneround register_cvar "zp_m79_oneround""0" )
    
cvar_knockback register_cvar "zp_m79_knockback" ,"1" )
    
    
// Message
    
g_msgScoreInfo get_user_msgid "ScoreInfo" )
    
g_msgDeathMsg get_user_msgid "DeathMsg" )
    
g_msgAmmoPickup get_user_msgid "AmmoPickup" )
    
g_msgCurWeapon get_user_msgid "CurWeapon" )
    
g_msgAmmoX get_user_msgid "AmmoX" )

    
// Maxplayers
    
g_MaxPlayers get_maxplayers ( )
}

// Connected
public client_connect Player )
{
    
bIsAlive Player ] = false
}

// Disconnect
public client_disconnect Player )
{
    
// Update
    
g_hasLauncher Player ] = false
    bIsAlive 
Player ] = false
}

// User infected post
public zp_user_infected_post PlayerInfector )
{
    
g_hasLauncher Player ] = false
}

// User transfered into Survivor
public zp_user_humanized_post PlayerSurvivor )
{
    
g_hasLauncher Survivor ] = false
}

// Buy ammo attempt
public clcmd_buyammo1 Player )
{
    
// Block ammo buying while holding M79
    
if ( g_hasLauncher Player ] )
        return 
PLUGIN_HANDLED
        
    
return PLUGIN_CONTINUE
}

// Buy an extra item
public zv_extra_item_selected PlayerItem )
{
    
// M79
    
if ( Item == g_m79 )
    {
        
// Already own it
        
if ( g_hasLauncher Player ] )
        {
            
// Warning
            
client_print Playerprint_chat"[ZP] Already have M79 Grenade Launcher" )
            return 
ZP_PLUGIN_HANDLED
        
}
        else
        {
            
// Drop primary guns
            
drop_primary_weapons Player 
            
            
// Update array
            
g_hasLauncher Player ] = true
            
            
// Ak47
            
give_item Playerg_AkEntity )
            
            
// Clip ammo
            
new ak find_ent_by_owner NULLENTg_AkEntityPlayer )
            
set_pdata_int akOFFSET_CLIPMAXCLIPLINUX_DIFF )
            
            
// BP ammo
            
cs_set_user_bpammo PlayerCSW_DEAGLEMAXBPAMMO )
        }
    }
    
// M79 grenade
    
else if ( Item == g_m79nade )
    {    
        
// Don't have Launcher
        
if ( !g_hasLauncher Player ] )
        {
            
client_print Playerprint_chat"[ZP] You don't have M79 Grenade Launcher" )
            return 
ZP_PLUGIN_HANDLED
        
}
        
        
// Too many grenades
        
new bpammo cs_get_user_bpammo PlayerCSW_DEAGLE )
        if ( 
bpammo >= MAXBPAMMO )
        {
            
client_print Playerprint_chat"[ZP] You cannot buy more Grenades" )
            return 
ZP_PLUGIN_HANDLED
        
}
        else
        {
            
// Ammo pickup
            
message_begin MSG_ONEg_msgAmmoPickup_Player )
            
write_byte 12 // Ammo ID
            
write_byte // Ammo amount
            
message_end ( )
            
            
// Buy sound
            
emit_sound PlayerCHAN_ITEMsound_buy[random_num(0sizeof sound_buy-1)], VOL_NORMATTN_NORM0PITCH_NORM )
            
            
// Increase bp ammo
            
cs_set_user_bpammo PlayerCSW_DEAGLEbpammo+)
    
        }
    }        
        
    return 
PLUGIN_CONTINUE
}

// Current weapon player is holding
public Event_CurrentWeapon Player )
{
    
// Not alive or dont have M79
    
if ( !bIsAlive Player ] || !g_hasLauncher Player ] )
        return 
PLUGIN_CONTINUE
        
    
// Update
    
g_CurrentWeapon Player ] = read_data )
        
    
// AK47    
    
if ( g_CurrentWeapon Player ] == CSW_DEAGLE )
    {
        
// Models
        
set_pev Playerpev_viewmodel2v_m79 )
        
set_pev Playerpev_weaponmodel2p_m79 )
        
        
// Find ak47
        
new ak47 find_ent_by_owner ( -1"weapon_deagle"Player )
        
        
// Get clip
        
new clip cs_get_weapon_ammo ak47 )
        
        
// Get bp ammo
        
new bpammo cs_get_user_bpammo PlayerCSW_DEAGLE )
        
        
// We have more than required
        
if ( clip MAXCLIP || bpammo MAXBPAMMO )
        {
            
// Return it back
            
cs_set_weapon_ammo ak47MAXCLIP )
            
cs_set_user_bpammo PlayerCSW_DEAGLEMAXBPAMMO )
            
            
// Call for HUD update
            
update_hud Player )
        }
    }
    return 
PLUGIN_CONTINUE
}

// New round started
public Event_NewRound ( )
{
    
// Game was restarted
    
if ( g_Restarted )
    {
        
// Update
        
arrayset g_hasLauncherfalse33 )
    }
    
    
// Update
    
g_Restarted false
    
    
// One round cvar
    
if ( get_pcvar_num cvar_oneround ) >= )
    {
        
// Loop
        
for ( new i  1g_MaxPlayersi++ )
        {
            
g_hasLauncher ] = false
            
            
// Remove ak47 from inventory
            
fm_strip_user_gun iCSW_AK47"weapon_deagle" )
        }
    }    
}

// Restart
public Event_GameRestart ( )
{
    
g_Restarted true
}

// Someone died
public Event_DeathMsg ( )
{
    
// Get victim
    
new victim read_data )
    
    
// Not connected
    
if ( !is_user_connected victim ) )
        return
        
    
// Update
    
bIsAlive victim ] = false
        
    
if ( g_hasLauncher victim ] )
    {
        
// Force to drop
        
engclient_cmd victim"drop" )
    }
}

// Cmd start
public fw_CmdStart PlayerUC_HandleSeed )
{
    
// Not alive / dont have m79 / weapon isnt ak47
    
if ( !bIsAlive Player ] || !g_hasLauncher Player ] || g_CurrentWeapon Player ] != CSW_DEAGLE )
        return 
FMRES_IGNORED
        
    
// Get buttons
    
static buttons buttons get_uc UC_HandleUC_Buttons )
    
    
// Primary attack button
    
if ( buttons IN_ATTACK )
    {
        
// Remove attack buttons from their button mask
        
buttons &= ~IN_ATTACK
        set_uc 
UC_HandleUC_Buttonsbuttons )
        
        
// No way...That's too  fast
        
if ( get_gametime ( ) - g_LastShotTime Player ] < REFIRE_RATE )
            return 
FMRES_IGNORED
        
        
// Weapon entity
        
static ak47 ak47 find_ent_by_owner NULLENTg_AkEntityPlayer )
        
        
// Clip
        
static Clip Clip get_pdata_int ak47OFFSET_CLIPLINUX_DIFF )
        
        
// Out of ammo ?
        
if ( Clip <= ) return FMRES_IGNORED
        
        
// Reloading ?
        
static Reload Reload get_pdata_int ak47OFFSET_RELOADLINUX_DIFF )
        
        
// Don't fire while reloading
        
if ( Reload ) return FMRES_IGNORED
        
        
// Bp ammo
        
static BpAmmo BpAmmo cs_get_user_bpammo PlayerCSW_DEAGLE )
        
        
// Fire!!
        
FireGrenade Player )
                
        
// Decrease ammo count
        
cs_set_weapon_ammo ak47Clip-)
                        
        
// Remember last shot time
        
g_LastShotTime Player ] = get_gametime ( )
                
        
// We are out of ammo
        
if ( Clip <= && BpAmmo <= )
        {
            
// Empty sound
            
ExecuteHamB Ham_Weapon_PlayEmptySoundak47 )
            return 
FMRES_IGNORED
        
}
    }
    return 
FMRES_HANDLED
}

// Update client data post
public fw_UpdateClientData_Post PlayerSendWeaponsCD_Handle )
{
    
// Not alive / dont have m79 / weapon isnt ak47
    
if ( !bIsAlive Player ] || !g_hasLauncher Player ] || g_CurrentWeapon Player ] != CSW_DEAGLE )
        return 
FMRES_IGNORED
        
    
// Block default sounds/animations
    
set_cd CD_HandleCD_flNextAttackhalflife_time ( ) + 0.001 )
    return 
FMRES_HANDLED
}

// Set world model(meTaLiCroSS)
public fw_SetModel Entity, const Model [ ] )
{
    
// Entity is not valid
    
if ( !is_valid_ent Entity ) )
        return 
FMRES_IGNORED
        
    
// Not ak47
    
if ( !equal Model"models/w_deagle.mdl" ) ) 
        return 
FMRES_IGNORED;
        
    
// Get classname
    
static szClassName 33 ]
    
entity_get_string EntityEV_SZ_classnameszClassNamecharsmax szClassName ) )
        
    
// Not a Weapon box
    
if ( !equal szClassName"weaponbox" ) )
        return 
FMRES_IGNORED
    
    
// Some vars
    
static iOwneriStoredAkID
    
    
// Get owner
    
iOwner entity_get_edict EntityEV_ENT_owner )
    
    
// Get drop weapon index
    
iStoredAkID find_ent_by_owner NULLENT"weapon_deagle"Entity )
    
    
// Entity classname is weaponbox, and ak47 was founded
    
if( g_hasLauncher iOwner ] && is_valid_ent iStoredAkID ) )
    {
        
// Setting weapon options
        
entity_set_int iStoredAkIDEV_INT_WEAPONKEYM79_WEAPONKEY )
        
        
// Save bp ammo
        
set_pev iStoredAkIDpev_weaponammocs_get_user_bpammo iOwnerCSW_DEAGLE ) )
        
        
// Reset user vars
        
g_hasLauncher iOwner ] = false
        
        
// Replace world model
        
entity_set_model Entityw_m79 )
        
        return 
FMRES_SUPERCEDE
    
}
    
    return 
FMRES_IGNORED
}

// Launcher deploy
public fw_LauncherDeploy_Post Launcher )
{
    
// Owner
    
new Player get_pdata_cbase LauncherOFFSET_PLAYERLINUX_DIFF_WPN )
    
//new Player = entity_get_edict(Launcher, EV_ENT_owner);
    
    // Owns Launcher
    
if ( g_hasLauncher Player ] )
    {
        
// Deploy animation
        
UTIL_PlayWeaponAnimation Playerm79_draw )
    }
    return 
HAM_IGNORED
}

// Give launcher to a player
public fw_LauncherAddToPlayer LauncherPlayer )
{
    
// Make sure that this is M79
    
if( is_valid_ent Launcher ) && is_user_connected Player ) && entity_get_int Launcher,  EV_INT_WEAPONKEY ) == M79_WEAPONKEY )
    {
        
// Update
        
g_hasLauncher Player ] = true
        
        
// BP ammo
        
cs_set_user_bpammo PlayerCSW_DEAGLEpev Launcherpev_weaponammo ) )
        
        
// Reset weapon options
        
entity_set_int LauncherEV_INT_WEAPONKEY0)
        
        return 
HAM_HANDLED
    
}
    
    return 
HAM_IGNORED
}
    
// Launcher post frame
public fw_LauncherPostFrame Launcher )
{
    
// Owner
    //new Player = get_pdata_cbase ( Launcher, OFFSET_PLAYER, LINUX_DIFF_WPN )
    
new Player entity_get_edict(LauncherEV_ENT_owner);
    
    
// Owns Launcher
    
if ( is_user_connected Player ) && g_hasLauncher Player ] )
    {
        
// Reload offset
        
new fInReload get_pdata_int LauncherOFFSET_RELOADLINUX_DIFF )
        
        
// Next attack time
        
new Float:flNextAttack get_pdata_float PlayerOFFSET_NEXTATTACKLINUX_DIFF_WPN )
        
        
// Clip
        
new iClip iClip get_pdata_int LauncherOFFSET_CLIPLINUX_DIFF )
        
        
// Ammo type
        
new iAmmoType OFFSET_PLAYERSLOT get_pdata_intLauncherOFFSET_PRIMAMMOTYPELINUX_DIFF )
        
        
// BP ammo
        
new iBpAmmo iBpAmmo get_pdata_intPlayeriAmmoTypeLINUX_DIFF_WPN )    
        
        
// Reloading
        
if( fInReload && flNextAttack <= 0.0 )
        {
            
// Calculate the difference
            
new min(MAXCLIP iClipiBpAmmo)
            
            
// Set new clip
            
set_pdata_int LauncherOFFSET_CLIPiClip jLINUX_DIFF )
            
            
// Decrease 'x' bullets from backpack(depending on new clip)
            
set_pdata_int PlayeriAmmoTypeiBpAmmo-jLINUX_DIFF_WPN )
            
            
// Not reloding anymore
            
set_pdata_int LauncherOFFSET_RELOAD0LINUX_DIFF )
            
fInReload 0
        
}
        
        
// Get buttons
        
static iButton iButton pevPlayerpev_button)
        
        
// Attack/Attack2 buttons and next prim/sec attack time hasnt' come yet
        
if(    (iButton IN_ATTACK2 && get_pdata_floatLauncherOFFSET_NEXTSECATTACKLINUX_DIFF ) <= 0.0)
        ||    (
iButton IN_ATTACK && get_pdata_floatLauncherOFFSET_NEXTPRIMATTACKLINUX_DIFF ) <= 0.0)    )
        {
            return
        }
        
        
// Reload button / not reloading
        
if( iButton IN_RELOAD && !fInReload )
        {
            
// Old clip is more/equal than/to new
            
if( iClip >= MAXCLIP )
            {
                
// Remove reload button
                
set_pev Playerpev_buttoniButton & ~IN_RELOAD )
                
                
//Don't play reload animation
                
UTIL_PlayWeaponAnimationPlayer, -)
            }
            else    
            {
                
// No need to reload if we are out of ammo
                
if ( !iBpAmmo ) return 
                
                
// Next attack time
                
set_pdata_floatPlayerOFFSET_NEXTATTACKRELOAD_TIME+0.5LINUX_DIFF_WPN )
            
                
// Reload animation
                
UTIL_PlayWeaponAnimation Playerm79_shoot1 )
                        
                
// Reload offset
                
set_pdata_int LauncherOFFSET_RELOAD1LINUX_DIFF )
    
                
// Idle time
                
set_pdata_float LauncherOFFSET_WEAPONIDLERELOAD_TIME 1.0LINUX_DIFF )
            }
        }
    }
}    

// Spawn
public fw_PlayerSpawn_Post Player )
{
    
// Dead
    
if ( !is_user_alive Player ) )
        return
        
    
// Update
    
bIsAlive Player ] = true
}

// Fire grenade
public FireGrenade Player )
{
    
// Velocity
    
static Float:fVelocity ]
    
    
// Create ent
    
new grenade create_entity g_DefaultEntity )
    
    
// Not grenade
    
if (!grenade ) return PLUGIN_HANDLED
    
    
// Classname
    
entity_set_string grenadeEV_SZ_classnameg_GrenadeEntity )
    
    
// Model
    
entity_set_model grenadegrenade_model )
    
    
// Origin
    
static Float:origin ], Float:angle ]
    
engfunc EngFunc_GetAttachmentPlayer2originangle )
    
entity_set_origin grenadeorigin )
    
    
// Size
    
engfunc EngFunc_SetSizegrenadeFloat:{ 0.00.00.0 }, Float:{ 0.00.00.0 } )
    
    
// Interaction
    
entity_set_int grenadeEV_INT_solidSOLID_SLIDEBOX )
    
    
// Movetype
    
entity_set_int grenadeEV_INT_movetypeMOVETYPE_TOSS )
    
    
// Owner
    
entity_set_edict grenadeEV_ENT_ownerPlayer )
    
    
// Velocity
    
VelocityByAimPlayer2000fVelocity )
    
    
// Velocity
    
entity_set_vector grenadeEV_VEC_velocityfVelocity )
    
    
// Angles
    
static Float:flAngle ]
    
engfunc EngFunc_VecToAnglesfVelocityflAngle )
    
entity_set_vector grenadeEV_VEC_anglesflAngle )
    
    
// Animation
    
UTIL_PlayWeaponAnimation Playerm79_shoot1 )
    
    
// Recoil
    
set_pev Playerpev_punchangleFloat:{12.06.0,0.0} )
    
    
// Launch sound
    
emit_sound grenadeCHAN_WEAPONfire_sound[random_num(0sizeof fire_sound-1)], VOL_NORMATTN_NORM0PITCH_NORM )
    
    
// Trail
    
message_begin MSG_BROADCASTSVC_TEMPENTITY )
    
write_byte(TE_BEAMFOLLOW// Temporary entity ID
    
write_short(grenade// Entity
    
write_shortm_iTrail // Sprite index
    
write_byte(10// Life
    
write_byte(3// Line width
    
write_byte(TRAIL_RED// Red
    
write_byte(TRAIL_GREEN// Green
    
write_byte(TRAIL_BLUE// Blue
    
write_byte(255// Alpha
    
message_end() 
    
    return 
PLUGIN_CONTINUE
}
    
// Grenade hit something
public touch_m79nade NadeOther )
{
    
// Invalid entity ?
    
if ( !pev_valid Nade ) )
        return
        
    
// Get it's origin
    
static Float:origin ]
    
pev Nadepev_originorigin )
    
    
// Explosion
    
engfunc EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYorigin)
    
write_byte TE_EXPLOSION )
    
engfunc EngFunc_WriteCoordorigin ] ) // Position X
    
engfunc EngFunc_WriteCoordorigin ] ) // Position Y
    
engfunc EngFunc_WriteCoordorigin ] ) // Position Z
    
write_short m_iExplo // Sprite index
    
write_byte 30 // Scale
    
write_byte 15 // Frame rate
    
write_byte // Flags
    
message_end ( )
    
    
// Owner
    
static owner  owner pev Nadepev_owner )    
    
    
// Make a loop
    
for ( new 1g_MaxPlayersi++ )
    {
        
// Not alive
        
if ( !bIsAlive ] )
            continue
            
        
// Godmode
        
if ( get_user_godmode ) == )
            continue
            
        
// Human/Survivor
        
if ( !zp_get_user_zombie ) || zp_get_user_survivor ) )
            continue
            
        
// Get victims origin
        
static Float:origin2 ]
        
pev ipev_originorigin2 )
        
        
// Get distance between those origins
        
static Float:distance_f distance_f get_distance_f originorigin2 )
        
        
// Convert distnace to non-float
        
static distance distance floatround distance_f )
        
        
// Radius
        
static radius radius get_pcvar_num cvar_radius )
        
        
// We are in damage radius
        
if ( distance <= radius )
        {
            
// Fake damage
            
fakedamage i"grenade"0.0DMG_BLAST )
            
            
// Max damage
            
static maxdmg maxdmg get_pcvar_num cvar_maxdmg )
            
            
// Normal dmg
            
new Damage
            Damage 
maxdmg floatround floatmul float maxdmg ), floatdiv float distance ), float radius ) ) ) )
            
            
// Calculate health
            
new health get_user_health )
            
            
// We have at least 1 hp
            
if ( health Damage >= )
            {
                
// New heakth
                
set_user_health ihealth Damage )
                
                
// Make knockback
                
make_knockback ioriginget_pcvar_float cvar_knockback ) * Damage )
            }
            else
            {
                
// We must die
                
death_message owneri"grenade")
                
                
// I hope they'll not find the bodies....
                
origin2 ] -= 45.0
            
}
        }
    }
    
    
// Breakable
    
static ClassName 32 ]
    
pev Otherpev_classnameClassNamecharsmax ClassName ) )
    if ( 
equal ClassName"func_breakable" ) )
    {
        
// Entity health
        
static Float:health
        health 
entity_get_float OtherEV_FL_health )
        
        if ( 
health <= get_pcvar_num cvar_maxdmg ) )
        {
            
// Break it
            
force_use ownerOther )
        }
    }
    
    
// Remove grenade
    
engfunc EngFunc_RemoveEntityNade )
}

// Death message
public death_message KillerVictim, const Weapon [ ], ScoreBoard )
{
    
// Block death msg
    
set_msg_block(g_msgDeathMsgBLOCK_SET)
    
ExecuteHamB(Ham_KilledVictimKiller2)
    
set_msg_block(g_msgDeathMsgBLOCK_NOT)
    
    
// Death
    
make_deathmsg KillerVictim0Weapon )
    
    
// Ammo packs
    
zp_set_user_ammo_packs Killerzp_get_user_ammo_packs Killer ) + )
    
    
// Update score board
    
if ( ScoreBoard )
    {
        
message_begin(MSG_BROADCASTg_msgScoreInfo)
        
write_byteKiller // id
        
write_short(pev(Killerpev_frags)) // frags
        
write_short(cs_get_user_deaths(Killer)) // deaths
        
write_short(0// class?
        
write_short(get_user_team(Killer)) // team
        
message_end()
        
        
message_begin(MSG_BROADCASTg_msgScoreInfo)
        
write_byte(Victim// id
        
write_short(pev(Victimpev_frags)) // frags
        
write_short(cs_get_user_deaths(Victim)) // deaths
        
write_short(0// class?
        
write_short(get_user_team(Victim)) // team
        
message_end()
    }
}
    
// Make knockback
public make_knockback VictimFloat:origin ], Float:maxspeed )
{
    
// Get and set velocity
    
new Float:fVelocity[3];
    
kickback VictimoriginmaxspeedfVelocity)
    
entity_set_vectorVictimEV_VEC_velocityfVelocity);

    return (
1);
}

// Extra calulation for knockback
stock kickbackentFloat:fOrigin[3], Float:fSpeedFloat:fVelocity[3])
{
    
// Find origin
    
new Float:fEntOrigin[3];
    
entity_get_vectorentEV_VEC_originfEntOrigin );

    
// Do some calculations
    
new Float:fDistance[3];
    
fDistance[0] = fEntOrigin[0] - fOrigin[0];
    
fDistance[1] = fEntOrigin[1] - fOrigin[1];
    
fDistance[2] = fEntOrigin[2] - fOrigin[2];
    new 
Float:fTime = (vector_distancefEntOrigin,fOrigin ) / fSpeed);
    
fVelocity[0] = fDistance[0] / fTime;
    
fVelocity[1] = fDistance[1] / fTime;
    
fVelocity[2] = fDistance[2] / fTime;

    return (
fVelocity[0] && fVelocity[1] && fVelocity[2]);
}

// Play weapon animation stock
stock UTIL_PlayWeaponAnimation ( const Player, const Sequence )
{
    
set_pev Playerpev_weaponanimSequence )
    
    
message_begin MSG_ONE_UNRELIABLESVC_WEAPONANIM, .player Player )
    
write_byte Sequence )
    
write_byte pev Playerpev_body ) )
    
message_end ( )
}

// Drop all primary guns
stock drop_primary_weapons Player )    
{
    
// Get user weapons
    
static weapons 32 ], numiweaponid
    num 
// reset passed weapons count (bugfix)
    
get_user_weapons Playerweaponsnum )
    
    
// Loop through them and drop primaries
    
for ( 0numi++ )
    {
        
// Prevent re-indexing the array
        
weaponid weapons ]
        
        
// We definetely are holding primary gun
        
if  ( ( (1<<weaponid) & SECONDARY_WEAPONS_BITSUM ) )        
        {
            
// Get weapon entity
            
static wname[32]
            
get_weaponname(weaponidwnamecharsmax(wname))
                
            
// Player drops the weapon and looses his bpammo
            
engclient_cmdPlayer"drop"wname)
        }
    }
}

// Update HUD
stock update_hud Player )
{
    
// Weapon ent
    
new Ent find_ent_by_owner ( -1,"weapon_deagle"Player )
    
    
// Clip
    
new clip  cs_get_weapon_ammo Ent )
    
    
// BP Ammo
    
new bpammo cs_get_user_bpammo PlayerCSW_DEAGLE )
    
    if ( 
clip != -)
    {
        
// Update HUD
        
message_begin MSG_ONEg_msgCurWeapon_Player )
        
write_byte )
        
write_byte CSW_DEAGLE )
        
write_byte clip )
        
message_end ( )
    }
    
    if ( 
bpammo != -)
    {
        
// Update HUD
        
message_begin MSG_ONEg_msgAmmoX_Player )
        
write_byte )
        
write_byte bpammo )
        
message_end ( )
    }
}


/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/ 
Attached Files
File Type: sma Get Plugin or Get Source (zp_extra_m79.sma - 725 views - 27.0 KB)
arnux is offline
JoKeR LauGh
Veteran Member
Join Date: May 2011
Location: Malaysia
Old 08-31-2011 , 06:11   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #135

I compiled it . works fine . o.O
__________________
Quote:
Originally Posted by addons_zz View Post
Also, just to not read `the article`, read all you find. Read and read, for ever and ever. Never stop reading.
Why? Because there is not one single universal truth which holds the meaning for everything.
JoKeR LauGh is offline
tei1995
Senior Member
Join Date: Feb 2011
Location: VietNam
Old 09-02-2011 , 01:02   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #136

Its run time error, i think you need add more "if statement" to deploy function and return ...
__________________

Hatsune Miku~
tei1995 is offline
RainZ
Junior Member
Join Date: Sep 2011
Old 09-03-2011 , 09:03   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #137

Return HAM_IGNORED ?
RainZ is offline
arnux
BANNED
Join Date: Sep 2010
Old 09-03-2011 , 10:22   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #138

Sorry for late reply, but maybe anyone know solution for this error?

Last edited by arnux; 09-03-2011 at 10:31.
arnux is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 09-03-2011 , 10:36   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #139

Quote:
Originally Posted by RainZ View Post
Return HAM_IGNORED ?
That wont solve the problem, its probably caused by an invalid player index.
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
shubhamgulati12
Senior Member
Join Date: Oct 2010
Location: Inida The Holy Place!!
Old 01-07-2012 , 14:24   Re: [ZP] Extra Item: Grenade Launcher
Reply With Quote #140

i have found a big bug in this plugin
According to the cvar - zp_m79_oneround 1 -- If 1 weapon will stay only 1 round
it should stay for 1 round if we keep 1
though i have kept it as 1 still if sum1 who bought it previous round wants to take it again takes ak - 47 as gun any by bug the grenade launcher comes!!!!!
and 1 more thing
after 1 round when gun vanishes if the user tries to buy the gun it comes that you already have m79
please help me it is creating big mess in server ...
__________________

Join Free File hosting - http://db.tt/VvebKSSW
[Free 2 GB cloud storage]
shubhamgulati12 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 21:08.


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