AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is this re-check necessary? (https://forums.alliedmods.net/showthread.php?t=82248)

LagParty 12-19-2008 18:32

Is this re-check necessary?
 
PHP Code:

if(!pev_valid(EntID[id]))//ent number for a player
        
EntID[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    if(!
pev_valid(EntID[id])) //recheck if entity was created
        
return
//after this i will work with the entity 

thanks.

Styles 12-19-2008 19:11

Re: Is this re-check necessary?
 
whats before if(!pev_valid(EntID[id]))//ent number for a player ? (First one)
And it depends what your doing afterwards, It never hurts to check if an entity is valid, because if it isn't and you mess with it, you probably will crash your server.

LagParty 12-20-2008 00:21

Re: Is this re-check necessary?
 
ok, I'll keep the double check because i do a lot of stuff after.

Another question: i created an entity gave it a player model and when i drop it to the floor half of the body goes through it. I'm using fakemeta and i've been trying for HOURS to solve this problem. Any help will be appreciated.

PHP Code:

public MakeFrozenModel(id) {
    if(!
pev_valid(FrozenEntID[id]))
        
FrozenEntID[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    if(!
pev_valid(FrozenEntID[id]))
        return
    static 
string[64], Float:Origin[3], Float:Angles[3], Float:Vel1[3], Float:Vel2[3], Model[16]
    
pev(id,pev_origin,Origin)
    
pev(id,pev_v_angle,Angles)
    
pev(id,pev_velocity,Vel1)
    
get_user_info(id,"model",Model,15)
    
    
//Store some info
    
set_pev(FrozenEntID[id],pev_classname,"freezemodel")
    
format(string,63,"models/player/%s/%s.mdl",Model,Model)
    
engfunc(EngFunc_SetModel,FrozenEntID[id],string)
    
    
    
set_pev(FrozenEntID[id],pev_size,{-16.0,-16.0,-36.0},{16.0,16.0,36.0})//mins,maxs
    
if(pev(id,pev_button)&IN_DUCKOrigin[2] += 18.0
    
else Origin[2] += 36.0
    
    set_pev
(FrozenEntID[id],pev_solid,SOLID_BBOX//some properties
    
set_pev(FrozenEntID[id],pev_movetype,MOVETYPE_TOSS)
    
    
set_pev(FrozenEntID[id],pev_sequence,pev(id,pev_sequence)) //give the correct anim type
    
    
engfunc(EngFunc_SetOrigin,FrozenEntID[id],Origin//Origin, view angle, velocity
    
set_pev(FrozenEntID[id],pev_v_angle,Angles)
    
velocity_by_aim(id,320,Vel2)
    
Vel1[0] += Vel2[0]
    
Vel1[1] += Vel2[1]
    
Vel1[2] += 32.0
    set_pev
(FrozenEntID[id],pev_velocity,Vel1)
    
    
set_pev(FrozenEntID[id],pev_framerate,1.0)
    
set_pev(FrozenEntID[id],pev_renderfx,kRenderFxGlowShell)
    
set_pev(FrozenEntID[id],pev_rendercolor,Float:{255.0,255.0,255.0}) //Add colour team later 
    
set_pev(FrozenEntID[id],pev_rendermode,kRenderNormal)  
    
set_pev(FrozenEntID[id],pev_renderamt,16.0)
    
    
//Give Weapon
    
if(!pev_valid(FrozenWeapID[id]))
        
FrozenWeapID[id] = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
    if(!
pev_valid(FrozenWeapID[id]))
        return
    
set_pev(FrozenWeapID[id],pev_classname,"freezeweapon")
    
set_pev(FrozenWeapID[id],pev_solid,SOLID_NOT)
    
set_pev(FrozenWeapID[id],pev_aiment,FrozenEntID[id])
    
set_pev(FrozenWeapID[id],pev_movetype,MOVETYPE_FOLLOW)
    
get_weaponname(get_user_weapon(id),Model,15)
    if(
equal(Model,"weapon_mp5navy"))
        
format(Model,15,"weapon_mp5")
    
format(string,63,"models/p_%s.mdl",Model[7])
    
engfunc(EngFunc_SetModel,FrozenWeapID[id],string)
    
    
Origin[2] += 100.0//Testing pruposes
    
engfunc(EngFunc_SetOrigin,id,Origin)
    
    
set_pev(FrozenEntID[id],pev_nextthink,get_gametime()+0.01//Later use this one


thanks.

danielkza 12-20-2008 00:29

Re: Is this re-check necessary?
 
You didn't set ent's pev_maxs/pev_mins.

LagParty 12-20-2008 00:46

Re: Is this re-check necessary?
 
PHP Code:

set_pev(FrozenEntID[id],pev_size,{-16.0,-16.0,-36.0},{16.0,16.0,36.0})//mins,maxs 

That doesn't count?

danielkza 12-20-2008 00:50

Re: Is this re-check necessary?
 
Quote:

Originally Posted by LagParty (Post 730186)
PHP Code:

set_pev(FrozenEntID[id],pev_size,{-16.0,-16.0,-36.0},{16.0,16.0,36.0})//mins,maxs 

That doesn't count?

I don't think this is possible at all. You're passing two arrays, set_pev only accepts one int/float/array. It's probably error'ing and not doing anything.

Exolent[jNr] 12-20-2008 01:43

Re: Is this re-check necessary?
 
Code:
new Float:mins[3], Float:maxs[3]; // set mins and maxs engfunc(EngFunc_SetSize, entity, mins, maxs);

LagParty 12-20-2008 03:18

Re: Is this re-check necessary?
 
Ok i got it. Setting pev_mins and pev_maxs helped with the entity not falling through the ground. Using EngFunc_SetSize helped with players passing through the entity (it was like SOLID_NOT).

Thanks to everyone for your help, i really appreciate it. Its frustrating to work a lot on your script and not getting any good results lol.


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

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