Raised This Month: $130 Target: $400
 32% 

Railcannon not compiling :(


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
KhaledAwesome
Member
Join Date: Jul 2013
Old 06-13-2018 , 23:54   Railcannon not compiling :(
Reply With Quote #1

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

#define PLUGIN "[CSO] Rail Cannon (2014)"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define DAMAGE 61 // 161 for Zombie

#define CLIP 24
#define BPAMMO 40

#define SPEED 1.25
#define RELOAD_TIME 2.5

#define CHARGE_AMMO 15
#define TIME_ACTIVATE 10
#define TIME_USAGE 7

#define MODEL_V "models/v_railcannon.mdl"
#define MODEL_P "models/p_railcannon.mdl"
#define MODEL_W "models/w_railcannon.mdl"

new const WeaponSounds[10][] = 
{
    
"weapons/railcanon-1.wav",
    
"weapons/railcanon-2.wav",
    
"weapons/railcanon_chage1.wav",
    
"weapons/railcanon_chage1_start.wav",
    
"weapons/railcanon_chage2.wav",
    
"weapons/railcanon_chage3.wav",
    
"weapons/railcanon_chage3_loop.wav",
    
"weapons/railcanon_clipin.wav",
    
"weapons/railcanon_clipout.wav",
    
"weapons/railcanon_draw.wav"
}

new const 
WeaponResources[3][] = 
{
    
"sprites/weapon_railcannon.txt",
    
"sprites/640hud13_2.spr",
    
"sprites/640hud112_2.spr"
}

enum
{
    
ANIM_IDLE 0,
    
ANIM_IDLE_CHARGE1,
    
ANIM_IDLE_CHARGE2,
    
ANIM_IDLE_CHARGE3,
    
ANIM_SHOOT1,
    
ANIM_SHOOT2,
    
ANIM_RELOAD,
    
ANIM_DRAW
}

enum
{
    
STATE_NORMAL 0,
    
STATE_CHARGE1,
    
STATE_CHARGE2,
    
STATE_CHARGE3,
    
STATE_CHARGE3_LOOP
}

#define CSW_RAILCANNON CSW_XM1014
#define weapon_railcannon "weapon_xm1014"

#define WEAPON_SECRETCODE 2792014
#define OLD_W_MODEL "models/w_xm1014.mdl"
#define OLD_EVENT "events/xm1014.sc"
#define ANIM_EXT "shotgun"

// MACROS
#define Get_BitVar(%1,%2) (%1 & (1 << (%2 & 31)))
#define Set_BitVar(%1,%2) %1 |= (1 << (%2 & 31))
#define UnSet_BitVar(%1,%2) %1 &= ~(1 << (%2 & 31))

// Main Vars
new g_Had_RCg_OldWeapon[33], g_WeaponState[33]
new 
g_HamBotg_MsgWeaponListg_MsgCurWeapong_MsgAmmoXg_Event_RCg_SmokePuff_Idm_spriteTexture

// Safety
new g_IsConnectedg_IsAliveg_PlayerWeapon[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
Register_SafetyFunc()
    
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
    
    
register_forward(FM_SetModel"fw_SetModel")
    
register_forward(FM_CmdStart"fw_CmdStart")
    
register_forward(FM_UpdateClientData"fw_UpdateClientData_Post"1)    
    
register_forward(FM_PlaybackEvent"fw_PlaybackEvent")    
    
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack")
    
RegisterHam(Ham_TraceAttack"worldspawn""fw_TraceAttack")        
    
    
RegisterHam(Ham_Item_Deployweapon_railcannon"fw_Item_Deploy_Post"1)    
    
RegisterHam(Ham_Item_AddToPlayerweapon_railcannon"fw_Item_AddToPlayer_Post"1)
    
RegisterHam(Ham_Weapon_WeaponIdleweapon_railcannon"fw_Weapon_WeaponIdle_Post"1)
    
RegisterHam(Ham_Item_PostFrameweapon_railcannon"fw_Item_PostFrame")
    
RegisterHam(Ham_Weapon_Reloadweapon_railcannon"fw_Weapon_Reload_Post"1)
    
    
// Cache
    
g_MsgWeaponList get_user_msgid("WeaponList")
    
g_MsgCurWeapon get_user_msgid("CurWeapon")
    
g_MsgAmmoX get_user_msgid("AmmoX")
    
    
// CMD
    
register_clcmd("weapon_railcannon""Hook_Weapon")
    
register_clcmd("say /get""Get_RailCannon")
}

public 
plugin_precache()
{
    
precache_model(MODEL_V)
    
precache_model(MODEL_P)
    
precache_model(MODEL_W)
    
    for(new 
0sizeof(WeaponSounds); i++)
        
precache_sound(WeaponSounds[i])
    for(new 
0sizeof(WeaponResources); i++)
    {
        if(!
iprecache_generic(WeaponResources[i])
        else 
precache_model(WeaponResources[i])
    }
    
    
register_forward(FM_PrecacheEvent"fw_PrecacheEvent_Post"1)    
    
    
m_spriteTexture precache_model("sprites/laserbeam.spr")
    
g_SmokePuff_Id engfunc(EngFunc_PrecacheModel"sprites/wall_puff1.spr")    
}

public 
fw_PrecacheEvent_Post(type, const name[])
{
    if(
equal(OLD_EVENTname))
        
g_Event_RC get_orig_retval()
}

public 
client_putinserver(id)
{
    
Safety_Connected(id)
    
    if(!
g_HamBot && is_user_bot(id))
    {
        
g_HamBot 1
        set_task
(0.1"Do_Register_HamBot"id)
    }
}

public 
Do_Register_HamBot(id
{
    
Register_SafetyFuncBot(id)
    
RegisterHamFromEntity(Ham_TraceAttackid"fw_TraceAttack")
}

public 
client_disconnect(id)
{
    
Safety_Disconnected(id)
}

public 
Get_RailCannon(id)
{
    
Remove_RailCannon(id)
    
    
Set_BitVar(g_Had_RCid)
    
g_WeaponState[id] = STATE_NORMAL
    
    give_item
(idweapon_railcannon)
    
cs_set_user_bpammo(idCSW_RAILCANNONBPAMMO)
    
    static 
EntEnt fm_get_user_weapon_entity(idCSW_RAILCANNON)
    if(
pev_valid(Ent)) cs_set_weapon_ammo(EntCLIP)
    
    
engfunc(EngFunc_MessageBeginMSG_ONE_UNRELIABLEg_MsgCurWeapon, {000}, id)
    
write_byte(1)
    
write_byte(CSW_RAILCANNON)
    
write_byte(CLIP)
    
message_end()
}

public 
Remove_RailCannon(id)
{
    
UnSet_BitVar(g_Had_RCid)
}

public 
Hook_Weapon(id)
{
    
engclient_cmd(idweapon_railcannon)
    return 
PLUGIN_HANDLED
}

public 
Event_CurWeapon(id)
{
    if(!
is_alive(id))
        return
    
    static 
CSWIDCSWID read_data(2)

    if((
CSWID == CSW_RAILCANNON && g_OldWeapon[id] == CSW_RAILCANNON) && Get_BitVar(g_Had_RCid)) 
    {
        static 
EntEnt fm_get_user_weapon_entity(idCSW_RAILCANNON)
        if(
pev_valid(Ent)) 
        {
            
set_pdata_float(Ent46get_pdata_float(Ent464) * SPEED4)
            
set_pdata_float(Ent47get_pdata_float(Ent464) * SPEED4)
        }
    }
    
    
g_OldWeapon[id] = CSWID
}


public 
fw_SetModel(entitymodel[])
{
    if(!
pev_valid(entity))
        return 
FMRES_IGNORED
    
    
static Classname[64]
    
pev(entitypev_classnameClassnamesizeof(Classname))
    
    if(!
equal(Classname"weaponbox"))
        return 
FMRES_IGNORED
    
    
static id
    id 
pev(entitypev_owner)
    
    if(
equal(modelOLD_W_MODEL))
    {
        static 
weapon
        weapon 
fm_get_user_weapon_entity(entityCSW_RAILCANNON)
        
        if(!
pev_valid(weapon))
            return 
FMRES_IGNORED
        
        
if(Get_BitVar(g_Had_RCid))
        {
            
set_pev(weaponpev_impulseWEAPON_SECRETCODE)
            
engfunc(EngFunc_SetModelentityMODEL_W)
            
            
Remove_RailCannon(id)
            
            return 
FMRES_SUPERCEDE
        
}
    }

    return 
FMRES_IGNORED;
}

public 
fw_CmdStart(iduc_handleseed)
{
    if(!
is_alive(id))
        return
    if(
get_player_weapon(id) != CSW_RAILCANNON || !Get_BitVar(g_Had_RCid))
        return
        
    static 
NewButtonNewButton get_uc(uc_handleUC_Buttons)
    static 
OldButtonOldButton pev(idpev_oldbuttons)
    
    static 
EntEnt fm_get_user_weapon_entity(idCSW_RAILCANNON)
    static 
Float:flNextAttackflNextAttack get_pdata_float(id835)
    static 
AmmoAmmo cs_get_weapon_ammo(Ent)
    if(!
pev_valid(Ent)) return
    
    if(
NewButton IN_ATTACK2)
    {
        if(
flNextAttack 0.0) return
        switch(
g_WeaponState[id])
        {
            case 
STATE_NORMAL
            {
                if(
Ammo <= 0) return
                
                
set_pdata_float(id830.55)
                
g_WeaponState[id] = STATE_CHARGE1
            
}
            case 
STATE_CHARGE1:
            {
                if(
Ammo 0)
                {
                    
Set_WeaponAnim(idANIM_IDLE_CHARGE1)
                    
g_WeaponState[id] = STATE_CHARGE2

                    cs_set_weapon_ammo
(EntAmmo 1)
                    
PlaySound(idWeaponSounds[2])
                }
                
                
set_pdata_float(id830.55)
                
PlaySound(idWeaponSounds[3])
            }
            case 
STATE_CHARGE2:
            {
                if(
Ammo 0)
                {
                    
Set_WeaponAnim(idANIM_IDLE_CHARGE2)
                    
g_WeaponState[id] = STATE_CHARGE3
                    
                    cs_set_weapon_ammo
(EntAmmo 1)
                    
PlaySound(idWeaponSounds[4])
                }
                
                
set_pdata_float(id830.55)
            }
            case 
STATE_CHARGE3:
            {
                if(
Ammo 0)
                {
                    
Set_WeaponAnim(idANIM_IDLE_CHARGE3)
                    
g_WeaponState[id] = STATE_CHARGE3_LOOP
                    
                    cs_set_weapon_ammo
(EntAmmo 1)
                    
PlaySound(idWeaponSounds[5])
                }
                
                
set_pdata_float(id830.55)
                
PlaySound(idWeaponSounds[3])
            }
            case 
STATE_CHARGE3_LOOP:
            {
                
Set_WeaponAnim(idANIM_IDLE_CHARGE3)
                
g_WeaponState[id] = STATE_CHARGE3_LOOP
                
                set_pdata_float
(id831.05)
                
PlaySound(idWeaponSounds[3])
            }
        }
    } else {
        if(
OldButton IN_ATTACK2)
        {
            if(
g_WeaponState[id] >= STATE_CHARGE2)
            {
                
cs_set_weapon_ammo(EntAmmo 1)
                
ExecuteHamB(Ham_Weapon_PrimaryAttackEnt)
            }
            
            
g_WeaponState[id] = STATE_NORMAL
        
}
    }
    
    if(
NewButton IN_RELOAD) {
        
NewButton &= ~IN_RELOAD
        set_uc
(uc_handleUC_ButtonsNewButton)
        
        if(
flNextAttack 0.0 || g_WeaponState[id] != STATE_NORMAL) return
        
        static 
fInReloadfInReload get_pdata_int(Ent544)
        if(
fInReload || cs_get_weapon_ammo(Ent) >= CLIP)
        {
            switch(
g_WeaponState[id])
            {
                case 
STATE_NORMALSet_WeaponAnim(idANIM_IDLE)
                case 
STATE_CHARGE1Set_WeaponAnim(idANIM_IDLE_CHARGE1)
                case 
STATE_CHARGE2Set_WeaponAnim(idANIM_IDLE_CHARGE2)
                case 
STATE_CHARGE3Set_WeaponAnim(idANIM_IDLE_CHARGE3)
            }
            return
        }
        
        
fw_Weapon_Reload_Post(Ent)
    }
}

public 
fw_UpdateClientData_Post(idsendweaponscd_handle)
{
    if(!
is_alive(id))
        return 
FMRES_IGNORED    
    
if(get_player_weapon(id) == CSW_RAILCANNON && Get_BitVar(g_Had_RCid))
        
set_cd(cd_handleCD_flNextAttackget_gametime() + 0.001
    
    return 
FMRES_HANDLED
}

public 
fw_PlaybackEvent(flagsinvokereventidFloat:delayFloat:origin[3], Float:angles[3], Float:fparam1Float:fparam2iParam1iParam2bParam1bParam2)
{
    if (!
is_connected(invoker))
        return 
FMRES_IGNORED        
    
if(get_player_weapon(invoker) == CSW_RAILCANNON && Get_BitVar(g_Had_RCinvoker) && eventid == g_Event_RC)
    {
        
engfunc(EngFunc_PlaybackEventflags FEV_HOSTONLYinvokereventiddelayoriginanglesfparam1fparam2iParam1iParam2bParam1bParam2)    

        
Set_WeaponAnim(invokerANIM_SHOOT1)
        
emit_sound(invokerCHAN_WEAPONWeaponSounds[0], 1.0ATTN_NORM0PITCH_LOW)    

        return 
FMRES_SUPERCEDE
    
}
    
    return 
FMRES_HANDLED
}

public 
fw_TraceAttack(EntAttackerFloat:DamageFloat:Dir[3], ptrDamageType)
{
    if(!
is_connected(Attacker))
        return 
HAM_IGNORED    
    
if(get_player_weapon(Attacker) != CSW_RAILCANNON || !Get_BitVar(g_Had_RCAttacker))
        return 
HAM_IGNORED
        
    
static Float:TargetOrigin[3], Float:MyOrigin[3], Float:Result[3]
        
    switch(
g_WeaponState[Attacker])
    {
        case 
STATE_NORMAL..STATE_CHARGE1// Shoot Normal
        
{
            static 
Float:flEnd[3], Float:vecPlane[3]
    
            
get_tr2(ptrTR_vecEndPosflEnd)
            
get_tr2(ptrTR_vecPlaneNormalvecPlane)        
            
            if(!
is_connected(Ent))
            {
                
make_bullet(AttackerflEnd)
                
fake_smoke(Attackerptr)
            }
            
            
SetHamParamFloat(3float(DAMAGE) / 6.0)
        }
        case 
STATE_CHARGE2// Shoot Charge 1
        
{
            
get_position(Attacker30.08.0, -5.0MyOrigin)
            
            
get_position(Attacker4096.0random_float(-100.0100.0), random_float(-100.0100.0), TargetOrigin)
            
Get_EndOrigin(MyOriginTargetOriginResultAttacker)
            
            
set_tr2(ptrTR_vecEndPosResult)
            
            if(!
is_connected(Ent))
            {
                
make_bullet(AttackerResult)
                
fake_smoke(Attackerptr)
            }
        
            
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
            
write_byte(TE_BEAMPOINTS)
            
write_coord_f(MyOrigin[0]) 
            
write_coord_f(MyOrigin[1]) 
            
write_coord_f(MyOrigin[2]) 
            
write_coord_f(Result[0]) 
            
write_coord_f(Result[1]) 
            
write_coord_f(Result[2]) 
            
write_short(m_spriteTexture)
            
write_byte(0// framerate
            
write_byte(0// framerate
            
write_byte(15// life
            
write_byte(7)  // width
            
write_byte(0)   // noise
            
write_byte(255)   // r, g, b
            
write_byte(75)   // r, g, b
            
write_byte(0)   // r, g, b
            
write_byte(255)    // brightness
            
write_byte(0)        // speed 
            
message_end()
            
            
SetHamParamFloat(3float(DAMAGE) / 4.0)
        }
        case 
STATE_CHARGE3// Shoot Charge 2
        
{
            
get_position(Attacker30.08.0, -5.0MyOrigin)
            
            
get_position(Attacker4096.0random_float(-50.050.0), random_float(-50.050.0), TargetOrigin)
            
Get_EndOrigin(MyOriginTargetOriginResultAttacker)
            
            
set_tr2(ptrTR_vecEndPosResult)
            
            if(!
is_connected(Ent))
            {
                
make_bullet(AttackerTargetOrigin)
                
fake_smoke(Attackerptr)
            }
            
            
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
            
write_byte(TE_BEAMPOINTS)
            
write_coord_f(MyOrigin[0]) 
            
write_coord_f(MyOrigin[1]) 
            
write_coord_f(MyOrigin[2]) 
            
write_coord_f(Result[0]) 
            
write_coord_f(Result[1]) 
            
write_coord_f(Result[2]) 
            
write_short(m_spriteTexture)
            
write_byte(0// framerate
            
write_byte(0// framerate
            
write_byte(15// life
            
write_byte(7)  // width
            
write_byte(0)   // noise
            
write_byte(255)   // r, g, b
            
write_byte(75)   // r, g, b
            
write_byte(0)   // r, g, b
            
write_byte(255)    // brightness
            
write_byte(0)        // speed 
            
message_end()
            
            
SetHamParamFloat(3float(DAMAGE) / 3.0)
        }
        case 
STATE_CHARGE3_LOOP// Shoot Charge 3
        
{
            
get_position(Attacker30.08.0, -5.0MyOrigin)
            
            
get_position(Attacker4096.0random_float(-10.010.0), random_float(-10.010.0), TargetOrigin)
            
Get_EndOrigin(MyOriginTargetOriginResultAttacker)
            
            
set_tr2(ptrTR_vecEndPosResult)
            
            if(!
is_connected(Ent))
            {
                
make_bullet(AttackerTargetOrigin)
                
fake_smoke(Attackerptr)
            }
            
            
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
            
write_byte(TE_BEAMPOINTS)
            
write_coord_f(MyOrigin[0]) 
            
write_coord_f(MyOrigin[1]) 
            
write_coord_f(MyOrigin[2]) 
            
write_coord_f(Result[0]) 
            
write_coord_f(Result[1]) 
            
write_coord_f(Result[2]) 
            
write_short(m_spriteTexture)
            
write_byte(0// framerate
            
write_byte(0// framerate
            
write_byte(15// life
            
write_byte(7)  // width
            
write_byte(0)   // noise
            
write_byte(255)   // r, g, b
            
write_byte(75)   // r, g, b
            
write_byte(0)   // r, g, b
            
write_byte(255)    // brightness
            
write_byte(0)        // speed 
            
message_end()
            
            
SetHamParamFloat(3float(DAMAGE) / 1.5)
        }
    }

    return 
HAM_HANDLED    
}

public 
fw_Item_Deploy_Post(Ent)
{
    if(
pev_valid(Ent) != 2)
        return
    static 
IdId get_pdata_cbase(Ent414)
    if(
get_pdata_cbase(Id373) != Ent)
        return
    if(!
Get_BitVar(g_Had_RCId))
        return

    
set_pev(Idpev_viewmodel2MODEL_V)
    
set_pev(Idpev_weaponmodel2MODEL_P)
    
    
Set_WeaponAnim(IdANIM_DRAW)
    
    
// Reverse
    
static Ammo
    
switch(g_WeaponState[Id])
    {
        case 
STATE_NORMALAmmo 0
        
case STATE_CHARGE1Ammo 0
        
case STATE_CHARGE2Ammo 1
        
case STATE_CHARGE3Ammo 2
        
case STATE_CHARGE3_LOOPAmmo 3
    
}
    
    
g_WeaponState[Id] = STATE_NORMAL
    cs_set_weapon_ammo
(Entcs_get_weapon_ammo(Ent) + Ammo)
    
    
set_pdata_string(Id, (492) * 4ANIM_EXT, -20)
}

public 
fw_Item_AddToPlayer_Post(entid)
{
    if(
pev(entpev_impulse) == WEAPON_SECRETCODE)
    {
        
Set_BitVar(g_Had_RCid)
        
set_pev(entpev_impulse0)
    }            
    
    
message_begin(MSG_ONE_UNRELIABLEg_MsgWeaponList_id)
    
write_string(Get_BitVar(g_Had_RCid) ? "weapon_railcannon" weapon_railcannon)
    
write_byte(5)
    
write_byte(32)
    
write_byte(-1)
    
write_byte(-1)
    
write_byte(0)
    
write_byte(12)
    
write_byte(CSW_RAILCANNON)
    
write_byte(0)
    
message_end()
}

public 
fw_Weapon_WeaponIdle_Post(iEnt)
{
    if(
pev_valid(iEnt) != 2)
        return 
    static 
idid get_pdata_cbase(iEnt414)
    if(
get_pdata_cbase(id373) != iEnt)
        return
    if(!
Get_BitVar(g_Had_RCid))
        return
    
    static 
SpecialReloadSpecialReload get_pdata_int(iEnt554)
    if(!
SpecialReload && get_pdata_float(iEnt484) <= 0.25)
    {
        switch(
g_WeaponState[id])
        {
            case 
STATE_NORMALSet_WeaponAnim(idANIM_IDLE)
            case 
STATE_CHARGE1Set_WeaponAnim(idANIM_IDLE_CHARGE1)
            case 
STATE_CHARGE2Set_WeaponAnim(idANIM_IDLE_CHARGE2)
            case 
STATE_CHARGE3Set_WeaponAnim(idANIM_IDLE_CHARGE3)
        }
        
        
set_pdata_float(iEnt4820.04)
    }    
}

public 
fw_Item_PostFrame(iEnt)
{
    if(
pev_valid(iEnt) != 2)
        return 
    static 
idid get_pdata_cbase(iEnt414)
    if(
get_pdata_cbase(id373) != iEnt)
        return
    if(!
Get_BitVar(g_Had_RCid))
        return

    static 
iBpAmmo iBpAmmo get_pdata_int(id3815)
    static 
iClip iClip get_pdata_int(iEnt514)
    static 
iMaxClip iMaxClip CLIP

    
if(get_pdata_int(iEnt544) && get_pdata_float(id835) <= 0.0)
    {
        static 
jmin(iMaxClip iClipiBpAmmo)
        
set_pdata_int(iEnt51iClip j4)
        
set_pdata_int(id381iBpAmmo-j5)
        
        
set_pdata_int(iEnt5404)
        if(
iBpAmmo CLIPcs_set_weapon_ammo(iEntmin(iBpAmmoCLIP))
        else 
cs_set_weapon_ammo(iEntiClip iBpAmmo)
    
        
// Update the fucking ammo hud
        
message_begin(MSG_ONE_UNRELIABLEg_MsgCurWeapon_id)
        
write_byte(1)
        
write_byte(CSW_RAILCANNON)
        
write_byte(CLIP)
        
message_end()
        
        
message_begin(MSG_ONE_UNRELIABLEg_MsgAmmoX_id)
        
write_byte(3)
        
write_byte(cs_get_user_bpammo(idCSW_RAILCANNON))
        
message_end()
    
        return
    }
}

public 
fw_Weapon_Reload_Post(iEnt)
{
    if(
pev_valid(iEnt) != 2)
        return 
    static 
idid get_pdata_cbase(iEnt414)
    if(
get_pdata_cbase(id373) != iEnt)
        return
    if(!
Get_BitVar(g_Had_RCid))
        return

    static 
CurBpAmmoCurBpAmmo cs_get_user_bpammo(idCSW_RAILCANNON)
    if(
CurBpAmmo  <= 0)
        return

    
set_pdata_int(iEnt5504)
    
set_pdata_float(id83RELOAD_TIME5)
    
set_pdata_float(iEnt48RELOAD_TIME 0.54)
    
set_pdata_float(iEnt46RELOAD_TIME 0.254)
    
set_pdata_float(iEnt47RELOAD_TIME 0.254)
    
set_pdata_int(iEnt5414)
    
    
Set_WeaponAnim(idANIM_RELOAD)
}

public 
Get_EndOrigin(Float:Start[3], Float:End[3], Float:Result[3], IgnoreEnt)
{
    static 
TraceID
    engfunc
(EngFunc_TraceLineStartEndDONT_IGNORE_MONSTERSIgnoreEntTraceID)
    
    
get_tr2(TraceIDTR_vecEndPosResult)
}

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

stock Set_Weapon_Idle(idWeaponId ,Float:TimeIdle)
{
    static 
entwpnentwpn fm_get_user_weapon_entity(idWeaponId)
    if(!
pev_valid(entwpn)) 
        return
        
    
set_pdata_float(entwpn46TimeIdle4)
    
set_pdata_float(entwpn47TimeIdle4)
    
set_pdata_float(entwpn48TimeIdle 0.54)
}

stock Set_Player_NextAttack(idFloat:NextTimeset_pdata_float(id83NextTime5)
stock make_bullet(idFloat:Origin[3])
{
    
// Find target
    
new decal random_num(4145)
    const 
loop_time 2
    
    
static BodyTarget
    get_user_aiming
(idTargetBody999999)
    
    if(
is_user_connected(Target))
        return
    
    for(new 
0loop_timei++)
    {
        
// Put decal on "world" (a wall)
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_WORLDDECAL)
        
engfunc(EngFunc_WriteCoordOrigin[0])
        
engfunc(EngFunc_WriteCoordOrigin[1])
        
engfunc(EngFunc_WriteCoordOrigin[2])
        
write_byte(decal)
        
message_end()
        
        
// Show sparcles
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_GUNSHOTDECAL)
        
engfunc(EngFunc_WriteCoordOrigin[0])
        
engfunc(EngFunc_WriteCoordOrigin[1])
        
engfunc(EngFunc_WriteCoordOrigin[2])
        
write_short(id)
        
write_byte(decal)
        
message_end()
    }
}

stock fake_smoke(idtrace_result)
{
    static 
Float:vecSrc[3], Float:vecEnd[3], TE_FLAG
    
    get_weapon_attachment
(idvecSrc)
    
global_get(glb_v_forwardvecEnd)
    
    
xs_vec_mul_scalar(vecEnd8192.0vecEnd)
    
xs_vec_add(vecSrcvecEndvecEnd)

    
get_tr2(trace_resultTR_vecEndPosvecSrc)
    
get_tr2(trace_resultTR_vecPlaneNormalvecEnd)
    
    
xs_vec_mul_scalar(vecEnd2.5vecEnd)
    
xs_vec_add(vecSrcvecEndvecEnd)
    
    
TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
    TE_FLAG 
|= TE_EXPLFLAG_NOSOUND
    TE_FLAG 
|= TE_EXPLFLAG_NOPARTICLES
    
    engfunc
(EngFunc_MessageBeginMSG_PASSVC_TEMPENTITYvecEnd0)
    
write_byte(TE_EXPLOSION)
    
engfunc(EngFunc_WriteCoordvecEnd[0])
    
engfunc(EngFunc_WriteCoordvecEnd[1])
    
engfunc(EngFunc_WriteCoordvecEnd[2] - 10.0)
    
write_short(g_SmokePuff_Id)
    
write_byte(2)
    
write_byte(50)
    
write_byte(TE_FLAG)
    
message_end()
}

stock get_weapon_attachment(idFloat:output[3], Float:fDis 40.0)

    new 
Float:vfEnd[3], viEnd[3
    
get_user_origin(idviEnd3)  
    
IVecFVec(viEndvfEnd
    
    new 
Float:fOrigin[3], Float:fAngle[3]
    
    
pev(idpev_originfOrigin
    
pev(idpev_view_ofsfAngle)
    
    
xs_vec_add(fOriginfAnglefOrigin
    
    new 
Float:fAttack[3]
    
    
xs_vec_sub(vfEndfOriginfAttack)
    
xs_vec_sub(vfEndfOriginfAttack
    
    new 
Float:fRate
    
    fRate 
fDis vector_length(fAttack)
    
xs_vec_mul_scalar(fAttackfRatefAttack)
    
    
xs_vec_add(fOriginfAttackoutput)
}

stock get_position(entFloat:forwFloat:rightFloat:upFloat:vStart[])
{
    static 
Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    
    
pev(entpev_originvOrigin)
    
pev(entpev_view_ofs,vUp//for player
    
xs_vec_add(vOrigin,vUp,vOrigin)
    
pev(entpev_v_anglevAngle// if normal entity ,use pev_angles
    
    
angle_vector(vAngle,ANGLEVECTOR_FORWARD,vForward//or use EngFunc_AngleVectors
    
angle_vector(vAngle,ANGLEVECTOR_RIGHT,vRight)
    
angle_vector(vAngle,ANGLEVECTOR_UP,vUp)
    
    
vStart[0] = vOrigin[0] + vForward[0] * forw vRight[0] * right vUp[0] * up
    vStart
[1] = vOrigin[1] + vForward[1] * forw vRight[1] * right vUp[1] * up
    vStart
[2] = vOrigin[2] + vForward[2] * forw vRight[2] * right vUp[2] * up
}

stock PlaySound(id, const sound[])
{
    if(
equal(sound[strlen(sound)-4], ".mp3")) client_cmd(id"mp3 play ^"sound/%s^""sound)
    else 
client_cmd(id"spk ^"%s^""sound)
}

/* ===============================
------------- SAFETY -------------
=================================*/
public Register_SafetyFunc()
{
    
register_event("CurWeapon""Safety_CurWeapon""be""1=1")
    
    
RegisterHam(Ham_Spawn"player""fw_Safety_Spawn_Post"1)
    
RegisterHam(Ham_Killed"player""fw_Safety_Killed_Post"1)
}

public 
Register_SafetyFuncBot(id)
{
    
RegisterHamFromEntity(Ham_Spawnid"fw_Safety_Spawn_Post"1)
    
RegisterHamFromEntity(Ham_Killedid"fw_Safety_Killed_Post"1)
}

public 
Safety_Connected(id)
{
    
Set_BitVar(g_IsConnectedid)
    
UnSet_BitVar(g_IsAliveid)
    
    
g_PlayerWeapon[id] = 0
}

public 
Safety_Disconnected(id)
{
    
UnSet_BitVar(g_IsConnectedid)
    
UnSet_BitVar(g_IsAliveid)
    
    
g_PlayerWeapon[id] = 0
}

public 
Safety_CurWeapon(id)
{
    if(!
is_alive(id))
        return
        
    static 
CSWCSW read_data(2)
    if(
g_PlayerWeapon[id] != CSWg_PlayerWeapon[id] = CSW
}

public 
fw_Safety_Spawn_Post(id)
{
    if(!
is_user_alive(id))
        return
        
    
Set_BitVar(g_IsAliveid)
}

public 
fw_Safety_Killed_Post(id)
{
    
UnSet_BitVar(g_IsAliveid)
}

public 
is_alive(id)
{
    if(!(
<= id <= 32))
        return 
0
    
if(!Get_BitVar(g_IsConnectedid))
        return 
0
    
if(!Get_BitVar(g_IsAliveid)) 
        return 
0
        
    
return 1
}

public 
is_connected(id)
{
    if(!(
<= id <= 32))
        return 
0
    
if(!Get_BitVar(g_IsConnectedid))
        return 
0
    
    
return 1
}

public 
get_player_weapon(id)
{
    if(!
is_alive(id))
        return 
0
    
    
return g_PlayerWeapon[id]
}

/* ===============================
--------- End of SAFETY ----------
=================================*/ 
Image of error :
Attached Thumbnails
Click image for larger version

Name:	errorerror.png
Views:	24
Size:	52.1 KB
ID:	170114  
KhaledAwesome is offline
Visinescu
Senior Member
Join Date: Dec 2015
Location: Tokyo
Old 06-14-2018 , 10:49   Re: Railcannon not compiling :(
Reply With Quote #2

Here you go mate.
Attached Files
File Type: sma Get Plugin or Get Source (CSO_RailCannon_2014_fix.sma - 10 views - 27.3 KB)
Visinescu is offline
KhaledAwesome
Member
Join Date: Jul 2013
Old 06-14-2018 , 12:31   Re: Railcannon not compiling :(
Reply With Quote #3

Quote:
Originally Posted by Visinescu View Post
Here you go mate.
THX MAN YOUR A LEGEND!

I was wondering if you can tell me why the Charge 1 + 2 make M3-1 shootgun sound instead of the actual plugin sound?
Basically when you right click the gun for 2 seconds, it charges from 1 to 2 to 3 and if u release it shoots.
now when u release at charge 1 or 2 it makes m3-1 shootgun sound, but when you reach charge 3 it makes the plugin sound as it should do.

In this (Other railcannon sma)

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

#define ENG_NULLENT        -1
#define EV_INT_WEAPONKEY    EV_INT_impulse
#define RAILCANNON_WEAPONKEY 756144798
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define SMOKE_CLASS "smokess"

const USE_STOPPED 0
const OFFSET_ACTIVE_ITEM 373
const OFFSET_WEAPONOWNER 41
const OFFSET_LINUX 5
const OFFSET_LINUX_WEAPONS 4

#if cellbits == 32
const OFFSET_CLIPAMMO 51
#else
const OFFSET_CLIPAMMO 65
#endif

#define WEAP_LINUX_XTRA_OFF        4
#define m_fKnown                    44
#define m_flNextPrimaryAttack         46
#define m_flNextSecondaryAttack         47
#define m_flTimeWeaponIdle            48
#define m_iClip                    51
#define m_fInReload                54
#define m_fInSpecialReload             55
#define PLAYER_LINUX_XTRA_OFF    5
#define m_flNextAttack                83

#define RAILCANNON_DRAW            7

#define TASK_SOUND 2573+10
#define TASK_SETRUM2 2573+20

new gmsgWeaponListsTrail

#define write_coord_f(%1)    engfunc(EngFunc_WriteCoord,%1)

new const Fire_Sounds[] = "weapons/railcanon-1.wav"
new const MuzzleFlash[] = "sprites/muzzleflash19.spr"

//////////// Change Here For Customize //////////////////////////

const Float:cvar_recoil_railcannon 0.65
const cvar_clip_railcannon 24
const cvar_railcannon_ammo 90

const Float:damage_mode1 5.0
const Float:damage_mode2 8.0
const Float:damage_mode3 15.0

/////////////////////////////////////////////////////////////////

new RAILCANNON_V_MODEL[64] = "models/v_railcannon.mdl"
new RAILCANNON_P_MODEL[64] = "models/p_railcannon.mdl"
new RAILCANNON_W_MODEL[64] = "models/w_railcannon.mdl"

new const GUNSHOT_DECALS[] = { 4142434445 }

new 
g_has_railcannon[33], g_Ham_Bot

new g_MaxPlayersg_orig_event_railcannong_IsInPrimaryAttackg_MuzzleFlash_SprId
new Float:cl_pushangle[33][3], m_iBlood[2], zz[33], udah[33]
new 
g_clip_ammo[33], oldweap[33], g_reload[33], railcannon_mode[33], Float:StartOrigin2[3], g_SpecialAmmo[33]
const 
PRIMARY_WEAPONS_BIT_SUM 
(
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)
new const 
WEAPONENTNAMES[][] = { """weapon_p228""""weapon_scout""weapon_hegrenade""weapon_xm1014""weapon_c4""weapon_mac10",
            
"weapon_aug""weapon_smokegrenade""weapon_elite""weapon_fiveseven""weapon_ump45""weapon_sg550",
            
"weapon_mp5navy""weapon_famas""weapon_usp""weapon_glock18""weapon_awp""weapon_mp5navy""weapon_m249",
            
"weapon_m3""weapon_m4a1""weapon_tmp""weapon_g3sg1""weapon_flashbang""weapon_deagle""weapon_sg552",
            
"weapon_ak47""weapon_knife""weapon_p90" }

public 
plugin_init()
{
    
register_plugin("Rail Cannon""1.0""m4m3ts")
    
register_cvar("rail_version""m4m3ts"FCVAR_SERVER|FCVAR_SPONLY)
    
register_event("CurWeapon","CurrentWeapon","be","1=1")
    
register_think(SMOKE_CLASS"fw_Fire_smoke")
    
RegisterHam(Ham_Item_AddToPlayer"weapon_m3""fw_RAILCANNON_AddToPlayer")
    
RegisterHam(Ham_Use"func_tank""fw_UseStationary_Post"1)
    
RegisterHam(Ham_Use"func_tankmortar""fw_UseStationary_Post"1)
    
RegisterHam(Ham_Use"func_tankrocket""fw_UseStationary_Post"1)
    
RegisterHam(Ham_Use"func_tanklaser""fw_UseStationary_Post"1)
    
    for (new 
1sizeof WEAPONENTNAMESi++)
        if (
WEAPONENTNAMES[i][0]) RegisterHam(Ham_Item_DeployWEAPONENTNAMES[i], "fw_Item_Deploy_Post"1)
    
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_m3""fw_RAIL_PrimaryAttack")
    
RegisterHam(Ham_Weapon_PrimaryAttack"weapon_m3""fw_RAIL_PrimaryAttack_Post"1)
    
RegisterHam(Ham_Weapon_Reload"weapon_m3""RAILCANNON_Reload")
    
RegisterHam(Ham_Weapon_Reload"weapon_m3""RAILCANNON_Reload_Post"1)
    
RegisterHam(Ham_Weapon_WeaponIdle"weapon_m3""fw_railcannonidleanim"1)
    
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
    
    
register_forward(FM_CmdStart"fw_CmdStart")
    
register_forward(FM_SetModel"fw_SetModel")
    
register_forward(FM_UpdateClientData"fw_UpdateClientData_Post"1)
    
register_forward(FM_PlaybackEvent"fwPlaybackEvent")
    
register_forward(FM_TraceLine,"fw_traceline",1)
    
    
gmsgWeaponList get_user_msgid("WeaponList")
    
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack")
    
RegisterHam(Ham_TraceAttack"worldspawn""fw_TraceAttack"1)
    
RegisterHam(Ham_TraceAttack"func_breakable""fw_TraceAttack"1)
    
RegisterHam(Ham_TraceAttack"func_wall""fw_TraceAttack"1)
    
RegisterHam(Ham_TraceAttack"func_door""fw_TraceAttack"1)
    
RegisterHam(Ham_TraceAttack"func_door_rotating""fw_TraceAttack"1)
    
RegisterHam(Ham_TraceAttack"func_plat""fw_TraceAttack"1)
    
RegisterHam(Ham_TraceAttack"func_rotating""fw_TraceAttack"1)
    
    
register_clcmd("get_railcannon""give_railcannon"ADMIN_KICK)
    
g_MaxPlayers get_maxplayers()
}

public 
plugin_precache()
{
    
precache_model(RAILCANNON_V_MODEL)
    
precache_model(RAILCANNON_P_MODEL)
    
precache_model(RAILCANNON_W_MODEL)
    
precache_sound(Fire_Sounds)    
        
    
sTrail precache_model("sprites/laserbeam.spr")
    
    
precache_sound("weapons/railcanon_clipin.wav")
    
precache_sound("weapons/railcanon_chage1_start.wav")
    
precache_sound("weapons/railcanon_chage3_loop.wav")
    
precache_sound("weapons/railcanon_draw.wav")
    
precache_sound("weapons/railcanon_clipout.wav")
    
precache_sound("weapons/railcanon-2.wav")
    
    
g_MuzzleFlash_SprId engfunc(EngFunc_PrecacheModelMuzzleFlash)
    
precache_generic("sprites/weapon_railcannon.txt")
    
    
precache_generic("sprites/640hud112.spr")
    
precache_generic("sprites/640hud13.spr")
        
    
register_clcmd("weapon_railcannon""weapon_hook")    
                    
    
m_iBlood[0] = precache_model("sprites/blood.spr")
    
m_iBlood[1] = precache_model("sprites/bloodspray.spr")
    
precache_model("sprites/wall_puff1.spr")

    
register_forward(FM_PrecacheEvent"fwPrecacheEvent_Post"1)
}

public 
weapon_hook(id)
{
    
engclient_cmd(id"weapon_m3")
    return 
PLUGIN_HANDLED
}

public 
client_putinserver(id)
{
    if(!
g_Ham_Bot && is_user_bot(id))
    {
        
g_Ham_Bot 1
        set_task
(0.1"Do_RegisterHam_Bot"id)
    }
}

public 
Do_RegisterHam_Bot(id)
{
    
RegisterHamFromEntity(Ham_TraceAttackid"fw_TraceAttack"1)
    
RegisterHamFromEntity(Ham_TraceAttackid"fw_TraceAttack")
}

public 
fw_PlayerKilled(id)
{
    
g_has_railcannon[id] = false
}

public 
fw_TraceAttack(iEntiAttackerFloat:flDamageFloat:fDir[3], ptriDamageType)
{
    if(!
is_user_alive(iAttacker))
        return

    new 
g_currentweapon get_user_weapon(iAttacker)

    if(
g_currentweapon != CSW_M3 || !g_has_railcannon[iAttacker])
        return
    
    if(
railcannon_mode[iAttacker] == 3SetHamParamFloat(3damage_mode3)
    if(
railcannon_mode[iAttacker] == 2SetHamParamFloat(3damage_mode2)
    if(
railcannon_mode[iAttacker] == 1SetHamParamFloat(3damage_mode1)
    
    static 
Float:flEnd[3], Float:test[3], Float:myOrigin[3]
    
    
pev(iAttackerpev_originmyOrigin)
    
get_tr2(ptrTR_vecEndPosflEnd)
        
    if(!
is_user_alive(iEnt))
    {
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_DECAL)
        
write_coord_f(flEnd[0])
        
write_coord_f(flEnd[1])
        
write_coord_f(flEnd[2])
        
write_byte(GUNSHOT_DECALS[random_num (0sizeof GUNSHOT_DECALS -1)])
        
write_short(iEnt)
        
message_end()

        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_WORLDDECAL)
        
write_coord_f(flEnd[0])
        
write_coord_f(flEnd[1])
        
write_coord_f(flEnd[2])
        
write_byte(GUNSHOT_DECALS[random_num (0sizeof GUNSHOT_DECALS -1)])
        
message_end()
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_GUNSHOTDECAL)
        
write_coord_f(flEnd[0])
        
write_coord_f(flEnd[1])
        
write_coord_f(flEnd[2])
        
write_short(iAttacker)
        
write_byte(GUNSHOT_DECALS[random_num (0sizeof GUNSHOT_DECALS -1)])
        
message_end()
        
        
fm_get_aim_origin(iAttackertest)
        if(
railcannon_mode[iAttacker] == 3fake_smokes(iAttackertest)
    }
    
    if(
railcannon_mode[iAttacker] == 2)
    {
        
get_position(iAttacker20.00.010.0StartOrigin2)
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_BEAMPOINTS)
        
engfunc(EngFunc_WriteCoordStartOrigin2[0])
        
engfunc(EngFunc_WriteCoordStartOrigin2[1])
        
engfunc(EngFunc_WriteCoordStartOrigin2[2] - 10.0)
        
engfunc(EngFunc_WriteCoordflEnd[0])
        
engfunc(EngFunc_WriteCoordflEnd[1])
        
engfunc(EngFunc_WriteCoordflEnd[2])
        
write_short(sTrail)
        
write_byte(0// start frame
        
write_byte(0// framerate
        
write_byte(5// life
        
write_byte(5// line width
        
write_byte(0// amplitude
        
write_byte(220)
        
write_byte(88)
        
write_byte(0// blue
        
write_byte(255// brightness
        
write_byte(0// speed
        
message_end()
    }
    
    if(
railcannon_mode[iAttacker] == 3)
    {
        
get_position(iAttacker20.05.05.0StartOrigin2)
        
        
message_begin(MSG_BROADCASTSVC_TEMPENTITY)
        
write_byte(TE_BEAMPOINTS)
        
engfunc(EngFunc_WriteCoordStartOrigin2[0])
        
engfunc(EngFunc_WriteCoordStartOrigin2[1])
        
engfunc(EngFunc_WriteCoordStartOrigin2[2] - 10.0)
        
engfunc(EngFunc_WriteCoordflEnd[0])
        
engfunc(EngFunc_WriteCoordflEnd[1])
        
engfunc(EngFunc_WriteCoordflEnd[2])
        
write_short(sTrail)
        
write_byte(0// start frame
        
write_byte(0// framerate
        
write_byte(8// life
        
write_byte(8// line width
        
write_byte(0// amplitude
        
write_byte(220)
        
write_byte(88)
        
write_byte(0// blue
        
write_byte(50// brightness
        
write_byte(0// speed
        
message_end()    
    }
    
}

public 
fake_smokes(idFloat:Origin[3])
{
    new 
ent_testent_test engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"env_sprite"))
    
    
engfunc(EngFunc_SetModelent_test"sprites/wall_puff1.spr")
    
entity_set_string(ent_testEV_SZ_classnameSMOKE_CLASS)
    
set_pev(ent_testpev_nextthinkget_gametime() + 0.04)
    
set_pev(ent_testpev_movetypeMOVETYPE_NONE)
    
set_pev(ent_testpev_rendermodekRenderTransAdd)
    
set_pev(ent_testpev_renderamt20.0)
    
set_pev(ent_testpev_scale1.0)
    
set_pev(ent_testpev_originOrigin)
    
set_pev(ent_testpev_frame0.0)
    
set_pev(ent_testpev_iuser2get_user_team(id))

    
set_pev(ent_testpev_solidSOLID_NOT)
    
dllfunc(DLLFunc_Spawnent_test)
}

public 
fw_Fire_smoke(iEnt)
{
    if(!
pev_valid(iEnt)) 
        return
    
    new 
Float:fFrame
    pev
(iEntpev_framefFrame)

    
// effect exp
    
fFrame += 1.0

    set_pev
(iEntpev_framefFrame)
    
set_pev(iEntpev_scale1.0)
    
set_pev(iEntpev_nextthinkget_gametime() + 0.02)
    
    if(
fFrame 30.0engfunc(EngFunc_RemoveEntityiEnt)
}

public 
fw_traceline(Float:v1[3],Float:v2[3],noMonsters,id,ptr)
{
    if(!
is_user_alive(id))
        return 
HAM_IGNORED    
    
if(get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
        return 
HAM_IGNORED
    
if(railcannon_mode[id] != 3)
        return 
HAM_IGNORED
    
    
// get crosshair aim
    
static Float:aim[3];
    
get_aim(id,v1,aim);
    
    
// do another trace to this spot
    
new trace create_tr2();
    
engfunc(EngFunc_TraceLine,v1,aim,noMonsters,id,trace);
    
    
// copy ints
    
set_tr2(ptr,TR_AllSolid,get_tr2(trace,TR_AllSolid));
    
set_tr2(ptr,TR_StartSolid,get_tr2(trace,TR_StartSolid));
    
set_tr2(ptr,TR_InOpen,get_tr2(trace,TR_InOpen));
    
set_tr2(ptr,TR_InWater,get_tr2(trace,TR_InWater));
    
set_tr2(ptr,TR_pHit,get_tr2(trace,TR_pHit));
    
set_tr2(ptr,TR_iHitgroup,get_tr2(trace,TR_iHitgroup));

    
// copy floats
    
get_tr2(trace,TR_flFraction,aim[0]);
    
set_tr2(ptr,TR_flFraction,aim[0]);
    
get_tr2(trace,TR_flPlaneDist,aim[0]);
    
set_tr2(ptr,TR_flPlaneDist,aim[0]);
    
    
// copy vecs
    
get_tr2(trace,TR_vecEndPos,aim);
    
set_tr2(ptr,TR_vecEndPos,aim);
    
get_tr2(trace,TR_vecPlaneNormal,aim);
    
set_tr2(ptr,TR_vecPlaneNormal,aim);

    
// get rid of new trace
    
free_tr2(trace);

    return 
FMRES_IGNORED;
}

get_aim(id,Float:source[3],Float:ret[3])
{
    static 
Float:vAngle[3], Float:pAngle[3], Float:dir[3], Float:temp[3];

    
// get aiming direction from forward global based on view angle and punch angle
    
pev(id,pev_v_angle,vAngle);
    
pev(id,pev_punchangle,pAngle);
    
xs_vec_add(vAngle,pAngle,temp);
    
engfunc(EngFunc_MakeVectors,temp);
    
global_get(glb_v_forward,dir);
    
    
/* vecEnd = vecSrc + vecDir * flDistance; */
    
xs_vec_mul_scalar(dir,8192.0,temp);
    
xs_vec_add(source,temp,ret);
}

public 
fwPrecacheEvent_Post(type, const name[])
{
    if (
equal("events/m3.sc"name))
    {
        
g_orig_event_railcannon get_orig_retval()
        return 
FMRES_HANDLED
    
}
    return 
FMRES_IGNORED
}

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

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

public 
fw_SetModel(entitymodel[])
{
    if(!
is_valid_ent(entity))
        return 
FMRES_IGNORED
    
    
static szClassName[33]
    
entity_get_string(entityEV_SZ_classnameszClassNamecharsmax(szClassName))
        
    if(!
equal(szClassName"weaponbox"))
        return 
FMRES_IGNORED
    
    
static iOwner
    
    iOwner 
entity_get_edict(entityEV_ENT_owner)
    
    if(
equal(model"models/w_m3.mdl"))
    {
        static 
iStoredAugID
        
        iStoredAugID 
find_ent_by_owner(ENG_NULLENT"weapon_m3"entity)
    
        if(!
is_valid_ent(iStoredAugID))
            return 
FMRES_IGNORED
    
        
if(g_has_railcannon[iOwner])
        {
            
entity_set_int(iStoredAugIDEV_INT_WEAPONKEYRAILCANNON_WEAPONKEY)
            
            
g_has_railcannon[iOwner] = false
            
            entity_set_model
(entityRAILCANNON_W_MODEL)
            
            return 
FMRES_SUPERCEDE
        
}
    }
    return 
FMRES_IGNORED
}

public 
give_railcannon(id)
{
    
drop_weapons(id1)
    new 
iWep2 give_item(id,"weapon_m3")
    if( 
iWep2 )
    {
        
cs_set_weapon_ammo(iWep2cvar_clip_railcannon)
        
cs_set_user_bpammo (idCSW_M3cvar_railcannon_ammo)
        
UTIL_PlayWeaponAnimation(idRAILCANNON_DRAW)
        
set_weapons_timeidle(idCSW_M31.0)
        
set_player_nextattackx(id1.0)
        
g_clip_ammo[id] = cs_get_weapon_ammo(iWep2)
    }
    
g_has_railcannon[id] = true
    g_SpecialAmmo
[id] = 0
    udah
[id] = 0
    zz
[id] = 0
    railcannon_mode
[id] = 1
    update_specialammo
(idg_SpecialAmmo[id], g_SpecialAmmo[id] > 0)
    
message_begin(MSG_ONEgmsgWeaponList, {0,0,0}, id)
    
write_string("weapon_railcannon")
    
write_byte(5)
    
write_byte(32)
    
write_byte(-1)
    
write_byte(-1)
    
write_byte(0)
    
write_byte(5)
    
write_byte(21)
    
write_byte(0)
    
message_end()
}

public 
fw_RAILCANNON_AddToPlayer(railcannonid)
{
    if(!
is_valid_ent(railcannon) || !is_user_connected(id))
        return 
HAM_IGNORED
    
    
if(entity_get_int(railcannonEV_INT_WEAPONKEY) == RAILCANNON_WEAPONKEY)
    {
        
g_has_railcannon[id] = true
        
        message_begin
(MSG_ONEgmsgWeaponList, {0,0,0}, id)
        
write_string("weapon_railcannon")
        
write_byte(5)
        
write_byte(32)
        
write_byte(-1)
        
write_byte(-1)
        
write_byte(0)
        
write_byte(5)
        
write_byte(21)
        
write_byte(0)
        
message_end()
        
        
entity_set_int(railcannonEV_INT_WEAPONKEY0)
        
update_specialammo(idg_SpecialAmmo[id], 0)
        
g_SpecialAmmo[id] = 0

        
return HAM_HANDLED
    
}
    return 
HAM_IGNORED
}

public 
fw_UseStationary_Post(entitycalleractivatoruse_type)
{
    if (
use_type == USE_STOPPED && is_user_connected(caller))
        
replace_weapon_models(callerget_user_weapon(caller))
}

public 
fw_Item_Deploy_Post(weapon_ent)
{
    static 
owner
    owner 
fm_cs_get_weapon_ent_owner(weapon_ent)
    
    static 
weaponid
    weaponid 
cs_get_weapon_id(weapon_ent)
    
    
update_specialammo(ownerg_SpecialAmmo[owner], 0)
    
g_SpecialAmmo[owner] = 0
    
    replace_weapon_models
(ownerweaponid)
}

public 
CurrentWeapon(id)
{
    if( 
read_data(2) != CSW_M3 ) {
        if( 
g_reload[id] ) {
            
g_reload[id] = 0
            remove_task
id 1331 )
        }
    }
    
replace_weapon_models(idread_data(2))
}

replace_weapon_models(idweaponid)
{
    switch (
weaponid)
    {
        case 
CSW_M3:
        {
            if(
g_has_railcannon[id])
            {
                
set_pev(idpev_viewmodel2RAILCANNON_V_MODEL)
                
set_pev(idpev_weaponmodel2RAILCANNON_P_MODEL)
                if(
oldweap[id] != CSW_M3
                {
                    
set_weapons_timeidle(idCSW_M31.0)
                    
set_player_nextattackx(id1.0)
                    
UTIL_PlayWeaponAnimation(idRAILCANNON_DRAW)
                    
udah[id] = 0
                    zz
[id] = 0
                    railcannon_mode
[id] = 1
                    remove_task
(id+TASK_SOUND)
                    
remove_task(id)

                    
message_begin(MSG_ONEgmsgWeaponList, {0,0,0}, id)
                    
write_string("weapon_railcannon")
                    
write_byte(5)
                    
write_byte(32)
                    
write_byte(-1)
                    
write_byte(-1)
                    
write_byte(0)
                    
write_byte(5)
                    
write_byte(CSW_M3)
                    
message_end()
                }
            }
        }
    }
    
oldweap[id] = weaponid
}

public 
fw_UpdateClientData_Post(PlayerSendWeaponsCD_Handle)
{
    if(!
is_user_alive(Player) || get_user_weapon(Player) != CSW_M3 || !g_has_railcannon[Player])
        return 
FMRES_IGNORED
    
    set_cd
(CD_HandleCD_flNextAttackhalflife_time () + 0.001)
    return 
FMRES_HANDLED
}

public 
fw_RAIL_PrimaryAttack(Weapon)
{
    new 
Player get_pdata_cbase(Weapon414)
    
    if (!
g_has_railcannon[Player])
        return
    
    
g_IsInPrimaryAttack 1
    pev
(Player,pev_punchangle,cl_pushangle[Player])
    
    
g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
    if(
g_clip_ammo[Player]) Make_Muzzleflash(Player)
}

public 
fw_RAIL_PrimaryAttack_Post(Weapon)
{
    
g_IsInPrimaryAttack 0
    
new Player get_pdata_cbase(Weapon414)
    
    new 
szClipszAmmo
    get_user_weapon
(PlayerszClipszAmmo)
    
    if(!
is_user_alive(Player))
        return

    if(
g_has_railcannon[Player])
    {
        if (!
g_clip_ammo[Player] && railcannon_mode[Player] == 1)
            return
        
        
g_reload[Player] = 0
        remove_task
Player 1331 )
        new 
Float:push[3]
        
pev(Player,pev_punchangle,push)
        
xs_vec_sub(push,cl_pushangle[Player],push)
        
xs_vec_mul_scalar(push,cvar_recoil_railcannon,push)
        
xs_vec_add(push,cl_pushangle[Player],push)
        
set_pev(Player,pev_punchangle,push)
        
        
UTIL_PlayWeaponAnimation(Player,random_num(4,5))
        
set_weapons_timeidle(PlayerCSW_M30.3)
        
set_player_nextattackx(Player0.3)
        
g_clip_ammo[Player] --
        
        if(
railcannon_mode[Player] == 3emit_sound(PlayerCHAN_WEAPON"weapons/railcanon-2.wav"VOL_NORMATTN_NORM0PITCH_NORM)
        else 
emit_sound(PlayerCHAN_WEAPONFire_SoundsVOL_NORMATTN_NORM0PITCH_NORM)
        
        
railcannon_mode[Player] = 1
    
}
}

public 
Make_Muzzleflash(id)
{
    static 
Float:Origin[3], TE_FLAG
    get_position
(id32.06.0, -15.0Origin)
    
    
TE_FLAG |= TE_EXPLFLAG_NODLIGHTS
    TE_FLAG 
|= TE_EXPLFLAG_NOSOUND
    TE_FLAG 
|= TE_EXPLFLAG_NOPARTICLES
    
    engfunc
(EngFunc_MessageBeginMSG_ONE_UNRELIABLESVC_TEMPENTITYOriginid)
    
write_byte(TE_EXPLOSION)
    
engfunc(EngFunc_WriteCoordOrigin[0])
    
engfunc(EngFunc_WriteCoordOrigin[1])
    
engfunc(EngFunc_WriteCoordOrigin[2])
    
write_short(g_MuzzleFlash_SprId)
    
write_byte(2)
    
write_byte(30)
    
write_byte(TE_FLAG)
    
message_end()
}

public 
fw_CmdStart(iduc_handleseed
{
    new 
ammoclipweapon get_user_weapon(idclipammo)
    if (!
g_has_railcannon[id] || weapon != CSW_M3 || !is_user_alive(id))
        return
    
    static 
entent fm_get_user_weapon_entity(idCSW_M3)
        
    if(!
pev_valid(ent))
        return
        
    static 
CurButton
    CurButton 
get_uc(uc_handleUC_Buttons)
    
    if(
CurButton IN_ATTACK)
    {
        new 
wpn fm_get_user_weapon_entity(idget_user_weapon(id))
        
        new 
Id pevwpnpev_owner ), clipbpammo
        get_user_weapon
Idclipbpammo )
        if( 
g_has_railcannonId ] ) {
        if( 
clip >= ) {
            if( 
g_reload[Id] ) {
                
remove_taskId 1331 )
                
g_reload[Id] = 0
            
}
        }
        else if( 
clip == )
        {
            if(
get_pdata_float(Id834) <= 0.3)
            {
                if( 
g_reload[Id] ) {
                
remove_taskId 1331 )
                
g_reload[Id] = 0
            
}
            }
        }
    }
    }
    
    else if(
CurButton IN_ATTACK2)
    {
        if(!
zz[id] && get_pdata_float(id834) <= 0.0 && g_clip_ammo[id] >= 1)
        {
            
set_weapons_timeidle(idCSW_M3200.0)
            
set_player_nextattackx(id200.0)
            
UTIL_PlayWeaponAnimation(id1)
            
emit_sound(idCHAN_WEAPON"weapons/railcanon_chage1_start.wav"1.0ATTN_NORM0PITCH_NORM)
            
set_task(0.6"charge_idle2"id)
            
zz[id] = 1
            udah
[id] = 0
            railcannon_mode
[id] = 2
            
            update_specialammo
(idg_SpecialAmmo[id], 0)
            
g_SpecialAmmo[id] ++
            
update_specialammo(idg_SpecialAmmo[id], 1)
            
            new 
weapon find_ent_by_owner( -1"weapon_m3"id )
            
cs_set_weapon_ammoweapong_clip_ammo[id] - 1)
            
g_clip_ammo[id] --
        }
    }
    
    else if(!(
pev(idpev_oldbuttons) & IN_ATTACK) && zz[id])
    {
        
zz[id] = 0
        
if(udah[id])
        {
            if(
g_clip_ammo[id] >= 1)
            {
                
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
                
set_weapons_timeidle(idCSW_M31.1)
                
set_player_nextattackx(id1.1)
                
udah[id] = 0
                remove_task
(id+TASK_SOUND)
                
                
update_specialammo(idg_SpecialAmmo[id], 0)
                
g_SpecialAmmo[id] = 0
                
                
new weapon find_ent_by_owner( -1"weapon_m3"id )
                
cs_set_weapon_ammoweapong_clip_ammo[id] + 1)
                
g_clip_ammo[id] ++
            }
            else
            {
                new 
weapon find_ent_by_owner( -1"weapon_m3"id )
                
cs_set_weapon_ammoweapong_clip_ammo[id] + 1)
                
g_clip_ammo[id] ++
                
                
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
                
set_weapons_timeidle(idCSW_M31.1)
                
set_player_nextattackx(id1.1)
                
udah[id] = 0
                remove_task
(id+TASK_SOUND)
                
                
update_specialammo(idg_SpecialAmmo[id], 0)
                
g_SpecialAmmo[id] = 0
            
}
        }
    }
}

public 
charge_idle2(id)
{
    if(
get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
        return
    if(
zz[id])
    {
        if(
g_clip_ammo[id] >= 1)
        {
            
UTIL_PlayWeaponAnimation(id2)
            
set_weapons_timeidle(idCSW_M3200.0)
            
set_player_nextattackx(id200.0)
            
set_task(0.6"charge_idle3"id)
            
            
update_specialammo(idg_SpecialAmmo[id], 0)
            
g_SpecialAmmo[id] ++
            
update_specialammo(idg_SpecialAmmo[id], 1)
            
            new 
weapon find_ent_by_owner( -1"weapon_m3"id )
            
cs_set_weapon_ammoweapong_clip_ammo[id] - 1)
            
g_clip_ammo[id] --
        }
        else
        {
            static 
entent fm_get_user_weapon_entity(idCSW_M3)
        
            if(!
pev_valid(ent))
                return
            
            new 
weapon find_ent_by_owner( -1"weapon_m3"id )
            
cs_set_weapon_ammoweapong_clip_ammo[id] + 1)
            
g_clip_ammo[id] ++
            
            
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
            
set_weapons_timeidle(idCSW_M31.1)
            
set_player_nextattackx(id1.1)
            
            
update_specialammo(idg_SpecialAmmo[id], 0)
            
g_SpecialAmmo[id] = 0
        
}
    }
    else
    {
        static 
entent fm_get_user_weapon_entity(idCSW_M3)
        
        if(!
pev_valid(ent))
            return
        
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
        
set_weapons_timeidle(idCSW_M31.1)
        
set_player_nextattackx(id1.1)
        
        
update_specialammo(idg_SpecialAmmo[id], 0)
        
g_SpecialAmmo[id] = 0
        
        
new weapon find_ent_by_owner( -1"weapon_m3"id )
        
cs_set_weapon_ammoweapong_clip_ammo[id] + 1)
        
g_clip_ammo[id] ++
    }
}

public 
charge_idle3(id)
{
    if(
get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
        return
    if(
zz[id])
    {
        if(
g_clip_ammo[id] >= 1)
        {
            
UTIL_PlayWeaponAnimation(id3)
            
emit_sound(idCHAN_WEAPON"weapons/railcanon_chage3_loop.wav"1.0ATTN_NORM0PITCH_NORM)
            
set_task(0.794"play_sound"id+TASK_SOUND,_,_,"b")
            
udah[id] = 1
            railcannon_mode
[id] = 3
            set_weapons_timeidle
(idCSW_M3200.0)
            
set_player_nextattackx(id200.0)
            
            
update_specialammo(idg_SpecialAmmo[id], 0)
            
g_SpecialAmmo[id] ++
            
update_specialammo(idg_SpecialAmmo[id], 1)
            
            new 
weapon find_ent_by_owner( -1"weapon_m3"id )
            
cs_set_weapon_ammoweapong_clip_ammo[id] - 1)
            
g_clip_ammo[id] --
        }
        else
        {
            static 
entent fm_get_user_weapon_entity(idCSW_M3)
        
            if(!
pev_valid(ent))
                return
            new 
weapon find_ent_by_owner( -1"weapon_m3"id )
            
cs_set_weapon_ammoweapong_clip_ammo[id] + 1)
            
g_clip_ammo[id] ++
            
            
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
            
set_weapons_timeidle(idCSW_M31.1)
            
set_player_nextattackx(id1.1)
            
            
update_specialammo(idg_SpecialAmmo[id], 0)
            
g_SpecialAmmo[id] = 0
        
}
    }
    else
    {
        static 
entent fm_get_user_weapon_entity(idCSW_M3)
        
        if(!
pev_valid(ent))
            return
        
ExecuteHamB(Ham_Weapon_PrimaryAttackent)
        
set_weapons_timeidle(idCSW_M31.1)
        
set_player_nextattackx(id1.1)
        
        
update_specialammo(idg_SpecialAmmo[id], 0)
        
g_SpecialAmmo[id] = 0
        
        
new weapon find_ent_by_owner( -1"weapon_m3"id )
        
cs_set_weapon_ammoweapong_clip_ammo[id] + 1)
        
g_clip_ammo[id] ++
    }
}

public 
play_sound(id)
{
    
id -= TASK_SOUND
    
    
if(!is_user_alive(id) || get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
        return
    
    
emit_sound(idCHAN_WEAPON"weapons/railcanon_chage3_loop.wav"1.0ATTN_NORM0PITCH_NORM)
}

public 
fw_railcannonidleanim(Weapon)
{
    new 
id get_pdata_cbase(Weapon414)

    if(!
is_user_alive(id) || !g_has_railcannon[id] || get_user_weapon(id) != CSW_M3)
        return 
HAM_IGNORED;
    
    if(
railcannon_mode[id] == && get_pdata_float(Weapon484) <= 0.25)
    {
        
UTIL_PlayWeaponAnimation(id0)
        
set_pdata_float(Weapon4820.04)
        return 
HAM_SUPERCEDE;
    }
    
    if(
railcannon_mode[id] == && get_pdata_float(Weapon484) <= 0.01)
    {
        
UTIL_PlayWeaponAnimation(id3)
        
set_pdata_float(Weapon481.74)
        return 
HAM_SUPERCEDE;
    }

    return 
HAM_IGNORED;
}

public 
update_specialammo(idAmmoOn)
{
    static 
AmmoSprites[33]
    
format(AmmoSpritessizeof(AmmoSprites), "number_%d"Ammo)
      
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("StatusIcon"), {0,0,0}, id)
    
write_byte(On)
    
write_string(AmmoSprites)
    
write_byte(42// red
    
write_byte(255// green
    
write_byte(42// blue
    
message_end()
}

public 
fwPlaybackEvent(flagsinvokereventidFloat:delayFloat:origin[3], Float:angles[3], Float:fparam1Float:fparam2iParam1iParam2bParam1bParam2)
{
    if ((
eventid != g_orig_event_railcannon) || !g_IsInPrimaryAttack)
        return 
FMRES_IGNORED
        
    
if (!(<= invoker <= g_MaxPlayers))
        return 
FMRES_IGNORED

    playback_event
(flags FEV_HOSTONLYinvokereventiddelayoriginanglesfparam1fparam2iParam1iParam2bParam1bParam2)
    return 
FMRES_SUPERCEDE
}

public 
RAILCANNON_Reloadwpn ) {
    if(
railcannon_mode[pevwpnpev_owner )] == 3)
          return 
HAM_SUPERCEDE
          
    
if( g_has_railcannonpevwpnpev_owner ) ] ) {
        
RAILCANNON_Reload_Postwpn )
        return 
HAM_SUPERCEDE
    
}
    return 
HAM_IGNORED
}

public 
RAILCANNON_Reload_Post(weapon) {
    new 
id pevweaponpev_owner )
    if(
railcannon_mode[id] == || g_reload[id])
          return 
HAM_SUPERCEDE
    
new clipbpammo
    get_user_weapon
(idclipbpammo )
    if( 
g_has_railcannonid ] && clip cvar_clip_railcannon && bpammo ) {
        if(!
task_existsid+1331 )) set_task0.1"reload"id+1331 )
        }
    return 
HAM_IGNORED
}

public 
reloadid ) {
    
id -= 1331
    set_weapons_timeidle
(idCSW_M33.0)
    
set_player_nextattackx(id3.0)
    
UTIL_PlayWeaponAnimation(id6)
    
g_reload[id] = 1
    set_task
(3.0"isi"id)
}

public 
isi(id)
{
    if(
get_user_weapon(id) != CSW_M3 || !g_has_railcannon[id])
        return
    
    if(!
g_reload[id])
        return
    
    new 
clipplurupengurangbpammoweapon find_ent_by_owner( -1"weapon_m3"id )
    
get_user_weapon(idclipbpammo )
    
pengurang cvar_clip_railcannon clip
    pluru 
bpammo pengurang
    cs_set_user_bpammo
idCSW_M3pluru )
    
    if(
bpammo <= pengurangcs_set_weapon_ammoweaponclip bpammo)
    else 
cs_set_weapon_ammoweaponcvar_clip_railcannon)
    
    
g_clip_ammo[id] = cvar_clip_railcannon
}

stock fm_cs_get_current_weapon_ent(id)
{
    return 
get_pdata_cbase(idOFFSET_ACTIVE_ITEMOFFSET_LINUX)
}

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

stock fm_cs_get_weapon_ent_owner(ent)
{
    return 
get_pdata_cbase(entOFFSET_WEAPONOWNEROFFSET_LINUX_WEAPONS)
}

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()
}

stock set_player_nextattackx(idFloat:nexttime)
{
    if(!
is_user_alive(id))
        return
        
    
set_pdata_float(idm_flNextAttacknexttime5)
}

stock get_weapon_attachment(idFloat:output[3], Float:fDis 40.0)

    new 
Float:vfEnd[3], viEnd[3
    
get_user_origin(idviEnd3)  
    
IVecFVec(viEndvfEnd
    
    new 
Float:fOrigin[3], Float:fAngle[3]
    
    
pev(idpev_originfOrigin
    
pev(idpev_view_ofsfAngle)
    
    
xs_vec_add(fOriginfAnglefOrigin
    
    new 
Float:fAttack[3]
    
    
xs_vec_sub(vfEndfOriginfAttack)
    
xs_vec_sub(vfEndfOriginfAttack
    
    new 
Float:fRate
    
    fRate 
fDis vector_length(fAttack)
    
xs_vec_mul_scalar(fAttackfRatefAttack)
    
    
xs_vec_add(fOriginfAttackoutput)
}

stock set_weapons_timeidle(idWeaponId ,Float:TimeIdle)
{
    if(!
is_user_alive(id))
        return
        
    static 
entwpnentwpn fm_get_user_weapon_entity(idWeaponId)
    if(!
pev_valid(entwpn)) 
        return
        
    
set_pdata_float(entwpn46TimeIdleWEAP_LINUX_XTRA_OFF)
    
set_pdata_float(entwpn47TimeIdleWEAP_LINUX_XTRA_OFF)
    
set_pdata_float(entwpn48TimeIdle 1.0WEAP_LINUX_XTRA_OFF)
}

stock get_speed_vector(const Float:origin1[3],const Float:origin2[3],Float:speedFloat:new_velocity[3])
{
    
new_velocity[0] = origin2[0] - origin1[0]
    
new_velocity[1] = origin2[1] - origin1[1]
    
new_velocity[2] = origin2[2] - origin1[2]
    new 
Float:num floatsqroot(speed*speed / (new_velocity[0]*new_velocity[0] + new_velocity[1]*new_velocity[1] + new_velocity[2]*new_velocity[2]))
    
new_velocity[0] *= num
    new_velocity
[1] *= num
    new_velocity
[2] *= num
    
    
return 1;
}

stock get_position(id,Float:forwFloat:rightFloat:upFloat:vStart[])
{
    static 
Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    
    
pev(idpev_originvOrigin)
    
pev(idpev_view_ofsvUp//for player
    
xs_vec_add(vOriginvUpvOrigin)
    
pev(idpev_v_anglevAngle// if normal entity ,use pev_angles
    
    
angle_vector(vAngle,ANGLEVECTOR_FORWARDvForward//or use EngFunc_AngleVectors
    
angle_vector(vAngle,ANGLEVECTOR_RIGHTvRight)
    
angle_vector(vAngle,ANGLEVECTOR_UPvUp)
    
    
vStart[0] = vOrigin[0] + vForward[0] * forw vRight[0] * right vUp[0] * up
    vStart
[1] = vOrigin[1] + vForward[1] * forw vRight[1] * right vUp[1] * up
    vStart
[2] = vOrigin[2] + vForward[2] * forw vRight[2] * right vUp[2] * up
}


stock drop_weapons(iddropwhat)
{
    static 
weapons[32], numiweaponid
    num 
0
    get_user_weapons
(idweaponsnum)
     
    for (
0numi++)
    {
        
weaponid weapons[i]
          
        if (
dropwhat == && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
        {
            static 
wname[32]
            
get_weaponname(weaponidwnamesizeof wname 1)
            
engclient_cmd(id"drop"wname)
        }
    }


Last edited by KhaledAwesome; 06-14-2018 at 12:32.
KhaledAwesome is offline
Visinescu
Senior Member
Join Date: Dec 2015
Location: Tokyo
Old 06-15-2018 , 17:32   Re: Railcannon not compiling :(
Reply With Quote #4

Just thinker with the plugin until you find the sweet spot.
Visinescu is offline
Mr.J
Member
Join Date: Sep 2017
Location: 35hp_4
Old 06-18-2018 , 06:39   Re: Railcannon not compiling :(
Reply With Quote #5

Try this
Attached Files
File Type: sma Get Plugin or Get Source (CSO_RailCannon_2014.sma - 3 views - 22.5 KB)
Mr.J is offline
KhaledAwesome
Member
Join Date: Jul 2013
Old 06-18-2018 , 06:47   Re: Railcannon not compiling :(
Reply With Quote #6

Quote:
Originally Posted by Mr.J View Post
Try this
look attachment
Attached Thumbnails
Click image for larger version

Name:	trythisXD.png
Views:	6
Size:	50.2 KB
ID:	170157  

Last edited by KhaledAwesome; 06-18-2018 at 06:48.
KhaledAwesome is offline
sekac
Senior Member
Join Date: Nov 2016
Old 06-18-2018 , 07:19   Re: Railcannon not compiling :(
Reply With Quote #7

Just add this after all #includes
#define write_coord_f(%1) engfunc(EngFunc_WriteCoord, %1)
sekac is offline
KhaledAwesome
Member
Join Date: Jul 2013
Old 06-18-2018 , 07:37   Re: Railcannon not compiling :(
Reply With Quote #8

Quote:
Originally Posted by sekac View Post
Just add this after all #includes
#define write_coord_f(%1) engfunc(EngFunc_WriteCoord, %1)
That did it!

Last edited by KhaledAwesome; 06-18-2018 at 07:45.
KhaledAwesome is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:10.


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