AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Odd Entity Problem (https://forums.alliedmods.net/showthread.php?t=100329)

Bad_Bud 08-13-2009 14:13

Odd Entity Problem
 
I'm displaying an unmoving model in 3d space at some coordinates I load from MySQL.

When I pass the coordinates thusly, it displays the model at the location:
PHP Code:

entity_set_origin(entity,Origin

When I do it this way, I see nothing at the location:
PHP Code:

set_pev(entity,pev_origin,Origin

In one compile, I even went as far as logging the origin, calling entity_set_origin(entity,Origin), and then reading it back by using pev(entity,pev_origin,Origin) and logging the value a second time. (I could see the model and everything)

In a second compile, I logged the origin, called set_pev(entity,pev_origin,Origin), and then read it back by using pev(entity,pev_origin,Origin) and logged the value a second time. (Though I could not see the model because I used set_pev)

All four of the logged origins were exactly the same, yet set_pev makes no model appear. Any suggestions?

ConnorMcLeod 08-13-2009 14:15

Re: Odd Entity Problem
 
set_pev acts as entity_set_vector( iEnt, EV_VEC_origin, vecOrigin )

engfunc( EngFunc_SetOrigin, iEnt, vecOrigin )

Bad_Bud 08-13-2009 14:16

Re: Odd Entity Problem
 
I used set_pev(entity,pev_origin,Origin) for some other entities I spawned. Why is it that in this case I need to use engfunc?

ConnorMcLeod 08-13-2009 14:17

Re: Odd Entity Problem
 
Because you used set_pev BEFORE you spawn those ents.
Then the game sends SetOrigin in the spawn function.

Bad_Bud 08-13-2009 14:44

Re: Odd Entity Problem
 
The engfunc worked perfectly, but it still bothers me that I don't understand it completely!

Here's the order everything went in on both.

One that already worked:
PHP Code:

new Item=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))

new 
Float:Location[3]
pev(id,pev_origin,Location)

new 
Float:Minbox[3]={-2.5,-2.5,-2.5}
new 
Float:Maxbox[3]={2.5,2.5,-2.5}
new 
Float:Angles[3]//={0.0,0.0,0.0}

Angles[1]=float(random_num(0,359)) 

set_pev(Item,pev_mins,Minbox)
set_pev(Item,pev_maxs,Maxbox)
set_pev(Item,pev_angles,Angles)            
set_pev(Item,pev_solid,SOLID_TRIGGER)
set_pev(Item,pev_movetype,MOVETYPE_TOSS)            
set_pev(Item,pev_classname,CLASS_ITEM)

new 
String[65]
format(String,64,"Stuff")
set_pev(Item,pev_targetname,String)

format(String,64,"Modelpath")
engfunc(EngFunc_SetModel,Item,String)
set_pev(Item,pev_origin,Location

What you just helped with:
PHP Code:

//I passed some coordinates through to the threaded query
new Float:Origin[3]
for(new 
i=0;i<3;i++)
        
Origin[i]=float(Data[i])

new 
Float:Angles[3]
for(new 
i=0;i<3;i++)
        
Angles[i]=float(Data[i+3])

entity=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
        
set_pev(entity,pev_angles,Angles)        
set_pev(entity,pev_solid,SOLID_NOT)
set_pev(entity,pev_movetype,MOVETYPE_NONE)        
set_pev(entity,CLASS_SALEITEM)

format(Model,64,"Modelpath",Model)
engfunc(EngFunc_SetModel,entity,Model)

engfunc(EngFunc_SetOrigin,entity,Origin

So I guess the second one was created differently in the engine because it was not solid and had no min/maxbox? Otherwise, I think everything else was done in the same order.

ConnorMcLeod 08-13-2009 14:45

Re: Odd Entity Problem
 
Also, use EngFunc_SetSize.

Bad_Bud 08-13-2009 14:46

Re: Odd Entity Problem
 
What for? The bounding box on the first one?

ConnorMcLeod 08-14-2009 00:27

Re: Odd Entity Problem
 
Instead of :

set_pev(Item,pev_mins,Minbox)
set_pev(Item,pev_maxs,Maxbox)

Then, absmin and absmax will also be set.


All times are GMT -4. The time now is 15:08.

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