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

API Scripting Help Sniper Laser Gun Problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hopkins852
Member
Join Date: Mar 2011
Location: India
Old 08-17-2011 , 02:05   Sniper Laser Gun Problem
Reply With Quote #1

I don't know if this the right thread for this. ( sorry moderator).

When i use this gun as extra item the ammo packs doesn't gets decreased. I mean like it costs 40 ammo packs , but when anyone buys it the ammo doesn't gets reduced it stays at 40, making it like FREE. I know i should ask the original author about the help but he is not giving any replies. Here so many coders please can anyone help on this please please please

PHP Code:
#include <amxmodx>
#include <zombieplague>
#include <fun>
#include <cstrike>
#include <engine>
#include <hamsandwich>
#include <fakemeta>

/* [ZP] Extra Item : Sniper Laser Gun [SLG] ! By xLeoNNN. (san antonio,chile)
   this is my second plugin, the Sniper Laser Gun [SLG] is a weapon awp with efects,laser,
   Credits : 
   
   meTaLiCroSS  :  for code of damage of "gauss"
   Mr.Death     :  how to create the effects and use the "Temp Entity"
   */
   
new g_ibuy
new bullets[33]
new 
hotflarexlaserbthunder
new bool:g_lasergun[33]
new 
g_iMaxPlayers
const q_pPlayer 41
new Shakes
const Second = ( 1<<10 )
new 
cvar_particles_deadcvar_bullet_efectcvar_thundercvar_oneround
new g_currentweapon[33]

new 
V_LASERGUN[] = "models/zombie_plague/v_sniper_laser_gun.mdl" 
new P_LASERGUN[]        = "models/zombie_plague/p_sniper_laser_gun.mdl"
new W_LASERGUN[]    = "models/zombie_plague/w_sniper_laser_gun.mdl"
new const LaserSound[] = "weapons/electro4.wav"

public plugin_init()
{
    
register_plugin("[ZP] Extra Item: Sniper Laser Gun""1.0""x[L]eoNNN"
    
g_ibuy zp_register_extra_item("Sniper Laser Gun"40ZP_TEAM_HUMAN)
    
Shakes get_user_msgid"ScreenShake" )
    
register_event("CurWeapon""make_tracer""be""1=1""3>0")
    
register_event("CurWeapon""Event_CurWeapon""be","1=1")
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_awp""fw_AWP_PrimaryAttack_Post"1)
    
RegisterHam(Ham_Spawn"player""fw_PlayerSpawn_Post"1)
    
register_forward(FM_SetModel"fw_SetModel")
    
cvar_particles_dead register_cvar("zp_slg_particles""1")
    
cvar_bullet_efect register_cvar("zp_slg_bullet""1")
    
cvar_thunder register_cvar("zp_slg_thunder""1")
    
cvar_oneround register_cvar("zp_slg_oneround""1")
    
}

public 
plugin_precache()
{
    
hotflarex precache_model("sprites/flare6.spr")
    
laserb precache_model("sprites/laserbeam.spr")
    
thunder precache_model("sprites/zbeam1.spr")
    
precache_model(V_LASERGUN)
    
precache_model(P_LASERGUN)
    
precache_model(W_LASERGUN)
    
precache_sound(LaserSound)
}

public 
zp_extra_item_selected(iditemid
{
    
    if (
itemid ==g_ibuy)
    {
        
g_lasergun[id] = true
        give_item 
(id"weapon_awp")
        
cs_set_user_bpammo(idCSW_AWP20)
        
client_print(idprint_center"[ZP] Sniper Laser Gun ON! Killed All Zombies!")
    }
    
    if(
g_lasergun[id] && user_has_weapon(idCSW_AWP))
    {
        
client_print(idprint_chat"/g[ZP]/y You Already Have Sniper Laser Gun!")
        
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) + 40)
        return;
    }


public 
zp_user_infected_post(infectedinfector)
{
    if (
g_lasergun[infected])
    {
        
g_lasergun[infected] = false
    
}
}

public 
event_round_start()
{
    for (new 
1<= g_iMaxPlayersi++)
    {
        if (!
is_user_connected(i))
            continue
        
        if (
g_lasergun[i])
        {
            
g_lasergun[i] = false
        
}
    }
}

public 
client_putinserver(id)
{
    
g_lasergun[id] = false
}

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

public 
make_tracer(id)
{
    if(
get_pcvar_num(cvar_bullet_efect))
    {
        if(
g_lasergun[id] && g_currentweapon[id])
        {
            new 
clip,ammo
            
new wpnid get_user_weapon(id,clip,ammo)
            new 
pteam[16]
            
            
get_user_team(idpteam15)
            
            if ((
bullets[id] > clip) && (wpnid == CSW_AWP)) 
            {
                new 
laser1[3], laser2[3]
                
get_user_origin(idlaser11)
                
get_user_origin(idlaser24)
                
                
message_beginMSG_BROADCAST,SVC_TEMPENTITY)
                
write_byte (1)    
                
write_short(id 0x1000
                
write_coord (laser2[0]) 
                
write_coord (laser2[1])
                
write_coord (laser2[2])
                
write_shortlaserb )
                
write_byte(1
                
write_byte(5
                
write_byte(1
                
write_byte(80
                
write_byte(20
                
write_byte(0)    
                
write_byte(52)       
                
write_byte(255)      
                
write_byte(255
                
write_byte(150)
                
message_end()
                
                
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
                
write_byte(TE_DLIGHT
                
write_coord(laser1[0]) 
                
write_coord(laser1[1]) 
                
write_coord(laser1[2]) 
                
write_byte(13
                
write_byte(254)
                
write_byte(0)
                
write_byte(0
                
write_byte(100)
                
write_byte(10)
                
message_end()
                
                
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
                
write_byte(TE_SPRITETRAIL)
                
write_coord(laser1[0]) 
                
write_coord(laser1[1]) 
                
write_coord(laser1[2]) 
                
write_coord(laser1[0]) 
                
write_coord(laser1[1]) 
                
write_coord(laser1[2]) 
                
write_short(hotflarex)
                
write_byte(5)
                
write_byte(1
                
write_byte(3
                
write_byte(34)
                
write_byte(43)
                
message_end()
                
emit_sound(idCHAN_AUTOLaserSoundVOL_NORMATTN_NORM 0PITCH_NORM)
                
            }
            
bullets[id] = clip
        
}
    }
}

public 
Event_CurWeapon(id
{      
    
g_currentweapon[id] = read_data(2)
    
    if(!
g_lasergun[id] || g_currentweapon[id] != CSW_AWP)
        return 
PLUGIN_CONTINUE
    
    entity_set_string
(idEV_SZ_viewmodelV_LASERGUN)
    
entity_set_string(idEV_SZ_weaponmodelP_LASERGUN)
    
    return 
PLUGIN_CONTINUE 
}

public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity))
        return 
FMRES_IGNORED
    
    
    
if(!equali(model"models/w_awp.mdl")) 
        return 
FMRES_IGNORED;
    
    new 
ads entity_get_edict(entityEV_ENT_owner)
    new 
className[33]
    
entity_get_string(entityEV_SZ_classnameclassName32)
    
    if(
equal(className"weaponbox") || equal(className"armoury_entity") || equal(className"grenade"))
    {
        if(
g_lasergun[ads])
        {
            
entity_set_model(entityW_LASERGUN)
            return 
FMRES_SUPERCEDE
        
}
    }
    
    return 
FMRES_IGNORED


public 
fw_TakeDamage(victiminflictorattackerFloat:damagedamage_bits)
{
    if(!
is_user_connected(attacker) || !is_user_connected(victim) || zp_get_user_nemesis(victim) || attacker == victim || !attacker)
        return 
HAM_IGNORED
    
    
if (g_lasergun[attacker] && g_currentweapon[attacker] == CSW_AWP)
    {    
        static 
Float:originF[3]
        
pev(victimpev_originoriginF)
        
        new 
plrWeapIdplrClipplrAmmo
        plrWeapId 
get_user_weapon(attackerplrClipplrAmmo)
        if (
plrWeapId == CSW_AWP)
            
SetHamParamFloat(4damage += get_user_health(victim))
        
        
client_print(attackerprint_center"Enemy Electrocuted!")
        if(
get_pcvar_num(cvar_particles_dead))
            
dead_efect(originF)
    }
    
    if(
zp_get_user_nemesis(victim))
    {
        
client_print(attackerprint_center"Nemesis is Inmune")
    }
    return 
PLUGIN_HANDLED
}

dead_efect(const Float:originF[3])
{    
engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)            
write_byte(TE_PARTICLEBURST
engfunc(EngFunc_WriteCoordoriginF[0])
engfunc(EngFunc_WriteCoordoriginF[1]) 
engfunc(EngFunc_WriteCoordoriginF[2]+10
write_short(250
write_byte(70
write_byte(55
message_end()

engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)            
write_byte(TE_PARTICLEBURST
engfunc(EngFunc_WriteCoordoriginF[0])
engfunc(EngFunc_WriteCoordoriginF[1]) 
engfunc(EngFunc_WriteCoordoriginF[2]+10)
write_short(250
write_byte(70
write_byte(55
message_end()

engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)            
write_byte(TE_PARTICLEBURST)
engfunc(EngFunc_WriteCoordoriginF[0]) 
engfunc(EngFunc_WriteCoordoriginF[1]) 
engfunc(EngFunc_WriteCoordoriginF[2]+10)
write_short(250)
write_byte(83
write_byte(55)
message_end()

engfunc(EngFunc_MessageBeginMSG_PVSSVC_TEMPENTITYoriginF0)
write_byte(TE_IMPLOSION)
engfunc(EngFunc_WriteCoordoriginF[0]) 
engfunc(EngFunc_WriteCoordoriginF[1]) 
engfunc(EngFunc_WriteCoordoriginF[2]+10
write_byte(random_num(100300))
write_byte(20
write_byte(3
message_end()
}

public 
fw_AWP_PrimaryAttack_Post(awp)
{
if(
get_pcvar_num(cvar_thunder))
{
    static 
id
    id 
get_pdata_cbase(awpq_pPlayer4)
    
    if(
is_user_connected(id) && g_lasergun[id])
    {    
        new 
iEndOrigin[3]
        
get_user_origin(idiEndOrigin3)
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITYiEndOrigin
        
write_byte(TE_EXPLOSION)    
        
write_coord(iEndOrigin[0]) 
        
write_coord(iEndOrigin[1]) 
        
write_coord(iEndOrigin[2] +10
        
write_short(thunder)    
        
write_byte(90)        
        
write_byte(60)        
        
write_byte(TE_EXPLFLAG_NONE)    
        
message_end() 
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITYiEndOrigin
        
write_byte(TE_EXPLOSION)    
        
write_coord(iEndOrigin[0]) 
        
write_coord(iEndOrigin[1]) 
        
write_coord(iEndOrigin[2]+20
        
write_short(thunder)    
        
write_byte(60)    
        
write_byte(20)        
        
write_byte(TE_EXPLFLAG_NONE)    
        
message_end() 
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITYiEndOrigin
        
write_byte(TE_EXPLOSION)    
        
write_coord(iEndOrigin[0]) 
        
write_coord(iEndOrigin[1]) 
        
write_coord(iEndOrigin[2] +30
        
write_short(thunder)    
        
write_byte(60)        
        
write_byte(20)            
        
write_byte(TE_EXPLFLAG_NONE)    
        
message_end() 
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITYiEndOrigin
        
write_byte(TE_BEAMCYLINDER)
        
write_coord(iEndOrigin[0])
        
write_coord(iEndOrigin[1])
        
write_coord(iEndOrigin[2])
        
write_coord(iEndOrigin[0])
        
write_coord(iEndOrigin[1])
        
write_coord(iEndOrigin[2]+200)
        
write_short(hotflarex)
        
write_byte(0)
        
write_byte(1)
        
write_byte(6)
        
write_byte(8)
        
write_byte(1)
        
write_byte(255)
        
write_byte(255)
        
write_byte(192)
        
write_byte(128)
        
write_byte(5)
        
message_end()
        
        
message_beginMSG_ONE_UNRELIABLEShakes_id )
        
write_shortSecond*)
        
write_shortSecond*)
        
write_shortSecond*)
        
message_end( ) 
    }
}
}

public 
fw_PlayerSpawn_Post(id)
{
if(
get_pcvar_num(cvar_oneround))
{
    if(
g_lasergun[id])
    {
        
g_lasergun[id] = false
        ham_strip_weapon
(id"weapon_awp")
    }
}
}

stock ham_strip_weapon(idweapon[])
{
if(!
equal(weapon,"weapon_",7)) 
    return 
0
    
    
new idd get_weaponid(weapon)
    
    if(!
idd) 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) == idd
        
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<<idd))
    
    return 
1


plgin link http://forums.alliedmods.net/showthread.php?t=138512
hopkins852 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 16:23.


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