Raised This Month: $19 Target: $400
 4% 

return variable


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Culverton smith
Junior Member
Join Date: Apr 2021
Old 05-01-2021 , 16:30   return variable
Reply With Quote #1

Hello. How can I add a native to this code to return the variable g_had_thunderbolt[id] to me? I have already tried to add a native that does this but it does not work. Code
PHP Code:
 #include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <fun>

#define PLUGIN "CSO Thunderbolt"
#define VERSION "2.0"
#define AUTHOR "Dias"

#define CSW_THUNDERBOLT CSW_AWP
#define weapon_thunderbolt "weapon_awp"
#define old_event "events/awp.sc"
#define old_w_model "models/w_awp.mdl"
#define WEAPON_SECRETCODE 4234234

#define DEFAULT_AMMO 20
#define RELOAD_TIME 2.67
#define DAMAGE 800

#define ZOOM_DELAY 0.5
#define ZOOM_DELAY2 0.1

new const v_model[] = "models/v_sfsniper2.mdl"
new const p_model[] = "models/p_sfsniper.mdl"
new const w_model[] = "models/w_sfsniper.mdl"
new const weapon_sound[5][] = 
{
    
"weapons/sfsniper-1.wav",
    
"weapons/sfsniper_insight1.wav",
    
"weapons/sfsniper_zoom.wav",
    
"weapons/sfsniper_idle.wav",
    
"weapons/sfsniper_draw.wav"
}


new const 
WeaponResource[4][] = 
{
    
"sprites/weapon_sfsniper.txt",
    
"sprites/640hud2_2.spr",
    
"sprites/640hud10_2.spr",
    
"sprites/640hud81_2.spr"
}

enum
{
    
TB_ANIM_IDLE 0,
    
TB_ANIM_SHOOT,
    
TB_ANIM_DRAW
}

new 
g_had_thunderbolt[33], g_thunderbolt_ammo[33], g_Shoot_Count[33], Float:StartOrigin2[3], Float:EndOrigin2[3],
Float:g_thunderbolt_zoomdelay[33], Float:g_thunderbolt_zoomdelay2[33], Float:g_thunderbolt_zoomdelay3[33]
new 
g_old_weapon[33], g_smokepuff_idm_iBlood[2], g_event_thunderboltg_scope_hud
new g_Beam_SprIdFloat:g_can_laser[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_forward(FM_CmdStart"fw_CmdStart")
    
register_forward(FM_SetModel"fw_SetModel")
    
register_forward(FM_UpdateClientData"fw_UpdateClientData_Post"1)    
    
register_forward(FM_PlaybackEvent"fw_PlaybackEvent")        
    
    
RegisterHam(Ham_Item_AddToPlayerweapon_thunderbolt"fw_AddToPlayer_Post"1)
    
RegisterHam(Ham_TraceAttack"worldspawn""fw_TraceAttack2")
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack")
    
RegisterHam(Ham_TraceAttack"player""fw_TraceAttack_Post"1)
    
RegisterHam(Ham_Spawn"player""ReviveCmd")
    
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
    
    
g_scope_hud CreateHudSyncObj(1962)
    
    
//register_clcmd("admin_get_thunderbolt", "get_thunderbolt", ADMIN_RCON)
    //register_clcmd("weapon_sfsniper", "hook_weapon")
}

public 
plugin_natives()

    
register_library("thunderbolt")
    
register_native("SetThunder""get_thunderbolt"true);
    
register_native("HasThund""nativecmd"1);
}

public 
bool:nativecmd(iPluginiParams)
{
    new 
what;
    if(
g_had_thunderbolt[id] == 1)
    {
        
what true;
        
//return 1;
    
}
    else
    {
        
what false;
        
//return 2;
    
}
    return 
what;
    
//return g_had_thunderbolt[id];
}

public 
plugin_precache()
{
    
precache_model(v_model)
    
precache_model(p_model)
    
precache_model(w_model)
    
    for(new 
0sizeof(weapon_sound); i++) 
        
precache_sound(weapon_sound[i])
        
    
precache_generic(WeaponResource[0])
    for(new 
1sizeof(WeaponResource); i++)
        
precache_model(WeaponResource[i])
    
    
g_smokepuff_id engfunc(EngFunc_PrecacheModel"sprites/wall_puff1.spr")
    
m_iBlood[0] = precache_model("sprites/blood.spr")
    
m_iBlood[1] = precache_model("sprites/bloodspray.spr")    
    
g_Beam_SprId precache_model("sprites/laserbeam.spr")
    
    
register_forward(FM_PrecacheEvent"fw_PrecacheEvent_Post"1)    
}

public 
ReviveCmd(id)
{
    if(
g_had_thunderbolt[id])
    {
        
g_had_thunderbolt[id] = 0
        ham_strip_weapon
(id"weapon_awp")
    }
}

new 
g_register
public client_putinserver(id)
{
    if(!
g_register && is_user_bot(id))
    {
        
g_register 0
        set_task
(0.1"do_register"id__"b")
    }
}

public 
do_register(id)
{
    
RegisterHamFromEntity(Ham_TraceAttackid"fw_TraceAttack")
    
RegisterHamFromEntity(Ham_TraceAttackid"fw_TraceAttack_Post"1)
}

public 
fw_PrecacheEvent_Post(type, const name[])
{
    if(
equal(old_eventname))
        
g_event_thunderbolt get_orig_retval()
}

public 
hook_weapon(id)
{
    
engclient_cmd(idweapon_thunderbolt)
    return
}

public 
get_thunderbolt(id)
{
    if(!
is_user_alive(id))
        return
        
    
g_had_thunderbolt[id] = 1
    g_thunderbolt_ammo
[id] = DEFAULT_AMMO
    
    give_item
(idweapon_thunderbolt)
    
    static 
weapon_entweapon_ent fm_find_ent_by_owner(-1weapon_thunderboltid)
    if(
pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent1)
}

public 
fw_UpdateClientData_Post(idsendweaponscd_handle)
{
    if(!
is_user_alive(id) || !is_user_connected(id))
        return 
FMRES_IGNORED    
    
if(get_user_weapon(id) == CSW_THUNDERBOLT && g_had_thunderbolt[id])
        
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_user_connected(invoker))
        return 
FMRES_IGNORED        
    
if(get_user_weapon(invoker) == CSW_THUNDERBOLT && g_had_thunderbolt[invoker] && eventid == g_event_thunderbolt)
    {
        
engfunc(EngFunc_PlaybackEventflags FEV_HOSTONLYinvokereventiddelayoriginanglesfparam1fparam2iParam1iParam2bParam1bParam2)    

        
set_weapon_anim(invokerTB_ANIM_SHOOT)
        
emit_sound(invokerCHAN_WEAPONweapon_sound[0], 1.0ATTN_NORM0PITCH_NORM)    

        return 
FMRES_SUPERCEDE
    
}
    
    return 
FMRES_HANDLED
}

public 
Event_CurWeapon(id)
{
    if(!
is_user_alive(id))
        return
        
    if(
get_user_weapon(id) == CSW_THUNDERBOLT && g_had_thunderbolt[id])
    {
        
set_pev(idpev_viewmodel2cs_get_user_zoom(id) == v_model "")
        
set_pev(idpev_weaponmodel2p_model)
        
        if(
g_old_weapon[id] != CSW_THUNDERBOLTset_weapon_anim(idTB_ANIM_DRAW)
        
update_ammo(id)
    } else if(
get_user_weapon(id) != CSW_THUNDERBOLT && g_old_weapon[id] == CSW_THUNDERBOLT) {
        
cs_set_user_zoom(id11)
    }
    
    
g_old_weapon[id] = get_user_weapon(id)
}

public 
fw_CmdStart(iduc_handleseed)
{
    if(!
is_user_alive(id) || !is_user_connected(id))
        return 
FMRES_IGNORED
    
if(get_user_weapon(id) != CSW_THUNDERBOLT || !g_had_thunderbolt[id])
        return 
FMRES_IGNORED
    
    
static CurButton
    CurButton 
get_uc(uc_handleUC_Buttons)
    
    if(
CurButton IN_ATTACK)
    {
        
CurButton &= ~IN_ATTACK
        set_uc
(uc_handleUC_ButtonsCurButton)
        
        
thunderbolt_shoothandle(id)
    }
    if(
CurButton IN_ATTACK2
    {
        
CurButton &= ~IN_ATTACK2
        set_uc
(uc_handleUC_ButtonsCurButton)
        
        if(
get_gametime() - ZOOM_DELAY g_thunderbolt_zoomdelay[id])
        {
            if(
get_pdata_float(id835) <= 0.0)
            {
                if(
cs_get_user_zoom(id) == 1)
                {
                    
cs_set_user_zoom(idCS_SET_FIRST_ZOOM1)
                } else {
                    
cs_set_user_zoom(id11)
                }
                    
                
emit_sound(idCHAN_ITEMweapon_sound[2], 1.0ATTN_NORM0PITCH_NORM)
            }
            
g_thunderbolt_zoomdelay[id] = get_gametime()
        }
    }
    
    if(
get_gametime() - ZOOM_DELAY2 g_thunderbolt_zoomdelay2[id])
    {
        if(
cs_get_user_zoom(id) == CS_SET_FIRST_ZOOM)
        {
            static 
BodyTarget
            get_user_aiming
(idTargetBody99999999)
            
            if(!
is_user_alive(Target))
            {
                
set_hudmessage(02000, -1.0, -1.000.10.1)
            } else {
                
set_hudmessage(25500, -1.0, -1.000.10.1)
                
                if(
get_gametime() - ZOOM_DELAY g_thunderbolt_zoomdelay3[id])
                {
                    
emit_sound(idCHAN_ITEMweapon_sound[1], 1.0ATTN_NORM0PITCH_NORM)
                    
g_thunderbolt_zoomdelay3[id] = get_gametime()
                }    
            }
            
            
ShowSyncHudMsg(idg_scope_hud"|^n-- + --^n|")
        } else {
            
set_hudmessage(02000, -1.0, -1.000.10.1)
            
ShowSyncHudMsg(idg_scope_hud"")
        }
            
        
g_thunderbolt_zoomdelay2[id] = get_gametime()
    }
    
    return 
FMRES_HANDLED
}

public 
thunderbolt_shoothandle(id)
{
    if(
get_pdata_float(id835) <= 0.0 && g_thunderbolt_ammo[id] > 0)
    {
        
g_thunderbolt_ammo[id]--
        
g_Shoot_Count[id] = 0
        update_ammo
(id)
        
        
Stock_Get_Postion(id50.010.05.0StartOrigin2)
        
        
set_task(0.1"Create_Laser"id)
        
        static 
weapon_entweapon_ent fm_find_ent_by_owner(-1weapon_thunderboltid)
        if(
pev_valid(weapon_ent)) ExecuteHamB(Ham_Weapon_PrimaryAttackweapon_ent)
        
set_player_nextattack(idCSW_THUNDERBOLTRELOAD_TIME)
        
        
// Reset Weapon
        
cs_set_user_zoom(id11)

        
set_hudmessage(02000, -1.0, -1.000.10.1)
        
ShowSyncHudMsg(idg_scope_hud"")
    }
}

public 
Create_Laser(id)
{
    
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_WriteCoordEndOrigin2[0])
    
engfunc(EngFunc_WriteCoordEndOrigin2[1])
    
engfunc(EngFunc_WriteCoordEndOrigin2[2])
    
write_short(g_Beam_SprId)
    
write_byte(0)
    
write_byte(0)
    
write_byte(30)
    
write_byte(25)
    
write_byte(0)
    
write_byte(0)
    
write_byte(0)
    
write_byte(255)
    
write_byte(255)
    
write_byte(0)
    
message_end()    
}

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_THUNDERBOLT)
        
        if(!
pev_valid(weapon))
            return 
FMRES_IGNORED
        
        
if(g_had_thunderbolt[id])
        {
            
set_pev(weaponpev_impulseWEAPON_SECRETCODE)
            
set_pev(weaponpev_iuser4g_thunderbolt_ammo[id])
            
engfunc(EngFunc_SetModelentityw_model)
            
            
g_had_thunderbolt[id] = 0
            g_thunderbolt_ammo
[id] = 0
            
            
return FMRES_SUPERCEDE
        
}
    }

    return 
FMRES_IGNORED;
}

public 
fw_AddToPlayer_Post(entid)
{
    if(
pev(entpev_impulse) == WEAPON_SECRETCODE)
    {
        
g_had_thunderbolt[id] = 1
        g_thunderbolt_ammo
[id] = pev(entpev_iuser4)
        
        
set_pev(entpev_impulse0)
    }            
    
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("WeaponList"), _id)
    
write_string((g_had_thunderbolt[id] == "weapon_sfsniper" "weapon_awp"))
    
write_byte(1)
    
write_byte(30)
    
write_byte(-1)
    
write_byte(-1)
    
write_byte(0)
    
write_byte(2)
    
write_byte(CSW_THUNDERBOLT)
    
write_byte(0)
    
message_end()
}

public 
fw_TraceAttack(entattackerFloat:DamageFloat:fDir[3], ptriDamageType)
{
    if(!
is_user_alive(attacker))
        return 
HAM_IGNORED    
    
if(get_user_weapon(attacker) != CSW_THUNDERBOLT || !g_had_thunderbolt[attacker])
        return 
HAM_IGNORED
        
    
static Float:flEnd[3]
    
get_tr2(ptrTR_vecEndPosflEnd)    

    if(
is_user_alive(ent)) create_blood(flEnd)
    
SetHamParamFloat(3float(DAMAGE))    
    
    return 
HAM_HANDLED
}

public 
fw_TraceAttack_Post(entattackerFloat:DamageFloat:fDir[3], ptriDamageType)
{
    if(!
is_user_alive(attacker))
        return 
HAM_IGNORED    
    
if(get_user_weapon(attacker) != CSW_THUNDERBOLT || !g_had_thunderbolt[attacker])
        return 
HAM_IGNORED

    
static Float:flEnd[3]
    
get_tr2(ptrTR_vecEndPosflEnd)
    
    
EndOrigin2 flEnd
    
    
return HAM_HANDLED
}

public 
fw_TraceAttack2(entattackerFloat:DamageFloat:fDir[3], ptriDamageType)
{
    if(!
is_user_alive(attacker))
        return 
HAM_IGNORED    
    
if(get_user_weapon(attacker) != CSW_THUNDERBOLT || !g_had_thunderbolt[attacker])
        return 
HAM_IGNORED
        
    
if(get_gametime() - 0.1 g_can_laser[attacker])
    {
        static 
Float:flEnd[3]
            
        
get_tr2(ptrTR_vecEndPosflEnd)    
        
EndOrigin2 flEnd
        
        make_bullet
(attackerflEnd)
        
fake_smoke(attackerptr)

        
g_can_laser[attacker] = get_gametime()
    }

    return 
HAM_HANDLED
}

public 
update_ammo(id)
{
    if(!
is_user_alive(id))
        return
    
    static 
weapon_entweapon_ent fm_find_ent_by_owner(-1weapon_thunderboltid)
    if(
pev_valid(weapon_ent)) cs_set_weapon_ammo(weapon_ent1)    
    
    
cs_set_user_bpammo(idCSW_THUNDERBOLT0)
    
    
engfunc(EngFunc_MessageBeginMSG_ONE_UNRELIABLEget_user_msgid("CurWeapon"), {000}, id)
    
write_byte(1)
    
write_byte(CSW_THUNDERBOLT)
    
write_byte(-1)
    
message_end()
    
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("AmmoX"), _id)
    
write_byte(1)
    
write_byte(g_thunderbolt_ammo[id])
    
message_end()
}

stock set_weapon_anim(idanim)
{
    if(!
is_user_alive(id))
        return
    
    
set_pev(idpev_weaponanimanim)
    
    
message_begin(MSG_ONE_UNRELIABLESVC_WEAPONANIM, {000}, id)
    
write_byte(anim)
    
write_byte(pev(idpev_body))
    
message_end()
}


stock set_player_light(id, const LightStyle[])
{
    if(!
is_user_alive(id))
        return
        
    
message_begin(MSG_ONE_UNRELIABLESVC_LIGHTSTYLE, .player id)
    
write_byte(0)
    
write_string(LightStyle)
    
message_end()
}

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

public 
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 Stock_Get_Postion(id,Float:forw,Float:rightFloat:up,Float:vStart[])
{
    new 
Float:vOrigin[3], Float:vAngle[3], Float:vForward[3], Float:vRight[3], Float:vUp[3]
    
    
pev(idpev_originvOrigin)
    
pev(idpev_view_ofs,vUp//for player
    
xs_vec_add(vOrigin,vUp,vOrigin)
    
pev(idpev_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 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 create_blood(const Float:origin[3])
{
    
// Show some blood :)
    
message_begin(MSG_BROADCASTSVC_TEMPENTITY
    
write_byte(TE_BLOODSPRITE)
    
engfunc(EngFunc_WriteCoordorigin[0])
    
engfunc(EngFunc_WriteCoordorigin[1])
    
engfunc(EngFunc_WriteCoordorigin[2])
    
write_short(m_iBlood[1])
    
write_short(m_iBlood[0])
    
write_byte(75)
    
write_byte(5)
    
message_end()
}

stock set_player_screenfade(pPlayersDuration 0sHoldTime 0sFlags 0000)
{
    if(!
is_user_connected(pPlayer))
        return
    
    
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("ScreenFade"), _pPlayer)
    
write_short(sDuration)
    
write_short(sHoldTime)
    
write_short(sFlags)
    
write_byte(r)
    
write_byte(g)
    
write_byte(b)
    
write_byte(a)
    
message_end()
}

stock set_player_nextattack(playerweapon_idFloat:NextTime)
{
    if(!
is_user_alive(player))
        return
    
    const 
m_flNextPrimaryAttack 46
    
const m_flNextSecondaryAttack 47
    
const m_flTimeWeaponIdle 48
    
const m_flNextAttack 83
    
    
static weapon
    weapon 
fm_get_user_weapon_entity(playerweapon_id)
    
    
set_pdata_float(playerm_flNextAttackNextTime5)
    if(
pev_valid(weapon))
    {
        
set_pdata_float(weaponm_flNextPrimaryAttack NextTime4)
        
set_pdata_float(weaponm_flNextSecondaryAttackNextTime4)
        
set_pdata_float(weaponm_flTimeWeaponIdleNextTime4)
    }
}

stock ham_strip_weapon(id,weapon[])
{
    if(!
equal(weapon,"weapon_",7)) return 0;
    
    new 
wId get_weaponid(weapon);
    if(!
wId) return 0;
    
    new 
wEnt;
    while((
wEnt engfunc(EngFunc_FindEntityByString,wEnt,"classname",weapon)) && pev(wEnt,pev_owner) != id) {}
    if(!
wEnt) return 0;
    
    
ExecuteHamB(Ham_Weapon_RetireWeapon,wEnt);
    
    if(!
ExecuteHamB(Ham_RemovePlayerItem,id,wEnt)) return 0;
    
ExecuteHamB(Ham_Item_Kill,wEnt);
    
    
set_pev(id,pev_weapons,pev(id,pev_weapons) & ~(1<<wId));
    return 
1;

Culverton smith is online now
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-01-2021 , 23:57   Re: return variable
Reply With Quote #2

You are registering a style 1 native but wrote code for a style 0 native. Style 1 natives are deprecated and should not be used. See the tutorial about dynamic natives here.

Ultimately, it looks like you may only need to remove the style 1 setting in register_native().



Offtopic: "set" and "get" have opposite meanings: register_native("SetThunder", "get_thunderbolt", true);
__________________
fysiks is offline
Culverton smith
Junior Member
Join Date: Apr 2021
Old 05-02-2021 , 03:56   Re: return variable
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
You are registering a style 1 native but wrote code for a style 0 native. Style 1 natives are deprecated and should not be used. See the tutorial about dynamic natives here.

Ultimately, it looks like you may only need to remove the style 1 setting in register_native().



Offtopic: "set" and "get" have opposite meanings: register_native("SetThunder", "get_thunderbolt", true);
Thanks but it didn't work.I found another solution and the problem was solved
Culverton smith is online now
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-02-2021 , 17:40   Re: return variable
Reply With Quote #4

Quote:
Originally Posted by Culverton smith View Post
Thanks but it didn't work.I found another solution and the problem was solved
What did you end up doing to fix it? You should explain what you did so that if other people have similar issues, then this thread will actually be helpful to the community.
__________________
fysiks is offline
Culverton smith
Junior Member
Join Date: Apr 2021
Old 05-03-2021 , 03:14   Re: return variable
Reply With Quote #5

I checked if the string is empty
Code:
if( string[ 0 ] == EOS )
It means that the player does not have that gun. Otherwise he/she has.
Culverton smith is online now
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-03-2021 , 22:31   Re: return variable
Reply With Quote #6

If it's a global/static variable then you need to be sure to set string[ 0 ] = EOS when he no longer has the gun, or at spawn or something.
__________________
Bugsy is offline
Culverton smith
Junior Member
Join Date: Apr 2021
Old 05-04-2021 , 03:14   Re: return variable
Reply With Quote #7

I already did. But thank you
Culverton smith is online now
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 15:42.


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