AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Entity Problems, once again... (https://forums.alliedmods.net/showthread.php?t=55065)

Silencer123 05-12-2007 16:42

Entity Problems, once again...
 
Is it possible that the first time you test something it never works?
Well, the time has come again.
Code:
new origin[3] pev(i,pev_origin,origin) new uzi=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"weapon_uziakimbo")) set_pev(uzi,pev_spawnflags,1024) set_pev(uzi,pev_origin,origin) set_pev(uzi,pev_model,"models/w_uzi.mdl")
This does nothing - there does not at least appear an error message in the console.
This should do nothing more than spawn an uziakimbo with spawnflags set to 1024 at the Players origin.
But actually it does nothing - why?

stupok 05-12-2007 20:44

Re: Entity Problems, once again...
 
Well you can't use pev() for everything.

You should use this for origin and model:

Code:

engfunc(EngFunc_SetModel, entid, "chicken")

engfunc(EngFunc_SetOrigin, entid, origin)


XxAvalanchexX 05-12-2007 21:46

Re: Entity Problems, once again...
 
You might also have to call DispatchSpawn.

Zenith77 05-12-2007 22:59

Re: Entity Problems, once again...
 
Quote:

Originally Posted by XxAvalanchexX (Post 476038)
You might also have to call DispatchSpawn.

This is correct, I had somebody PM this question. You MUST spawn an entity before setting their model and some other stuff. It is a good rule of thumb to always spawn you're entity before messing with it's pev_* section.

However with fakemeta use:
Code:
dllfunc(DLLFunc_Spawn, ent);

regalis 05-12-2007 23:46

Re: Entity Problems, once again...
 
Quote:

Originally Posted by Zenith77 (Post 476057)
This is correct, I had somebody PM this question. You MUST spawn an entity before setting their model and some other stuff. It is a good rule of thumb to always spawn you're entity before messing with it's pev_* section.

However with fakemeta use:
Code:
dllfunc(DLLFunc_Spawn, ent);

I use this in my new Plugin:
Code:

g_SNentity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"));
engfunc(EngFunc_SetOrigin, g_SNentity, g_Origin);
engfunc(EngFunc_SetModel, g_SNentity, g_models[0]);

My code works flawless....
Should i use this dllfunc too?
Code:

dllfunc(DLLFunc_Spawn, g_SNentity);
Would that improve my code?
weird! :)

greetz regalis

Drak 05-13-2007 01:27

Re: Entity Problems, once again...
 
@regalis
Code:
dllfunc(DLLFunc_Spawn, g_SNentity);
This (i think) notifies the engine of the changes to an entity. So far, i never needed to use it on any entity's besides "info_target" which is manly used for creating new entity's. So, i assume it's used all the time just for the safety. So it wouldn't hurt to add it.

@Silencer123

If i'm right, you need to use the function. As Avalanche said, because you're modifying an already 'made' entity.
(I assume this is for SvenCoop)

regalis 05-13-2007 01:37

Re: Entity Problems, once again...
 
Quote:

Originally Posted by SixTwin (Post 476078)
@regalis
Code:
dllfunc(DLLFunc_Spawn, g_SNentity);

This (i think) notifies the engine of the changes to an entity. So far, i never needed to use it on any entity's besides "info_target" which is manly used for creating new entity's. So, i assume it's used all the time just for the safety. So it wouldn't hurt to add it.

Then i will add it in the next update if there is one..0o
But as far as i know myself, there are plenty...i only wait till VEN inspects my Plugin :oops:
He always find some flaws..0o

Thanks for the explanation!
I go now sleeping*lol*

greetz regalis

Silencer123 05-13-2007 06:17

Re: Entity Problems, once again...
 
Okay, does that dllfunc come right behind the
EngFunc_CreateNamedEntity line one or at the end of all changes made?

EDIT: Just reading your words more carefully and finding out I have to do that before I set something.

VEN 05-13-2007 06:39

Re: Entity Problems, once again...
 
It's necessary to spawn an entity in two cases. When you want to apply all previously fired to that entity keyvalue data and when you want it to take all of the native properties of its classname. So for example if you'd going to spawn func_buyzone entity you do not have to care about configuration of its solidity and visibility.

Silencer123 05-13-2007 06:49

Re: Entity Problems, once again...
 
Okay... Now where I am looking for an alternative for pev I arrived at this point:
Code:
engfunc(EngFunc_SetKeyValue,engfunc(EngFunc_GetInfoKeyBuffer,uzi),"spawnflags","1024")
It says EngFunc_GetInfoKeyBuffer returns "char*" - So is it only one char = one array = one integer?
Or do I have to make a new uberfat string to store long word clusters? *confused*


All times are GMT -4. The time now is 06:46.

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