Raised This Month: $ Target: $400
 0% 

Spawn an Entity at an Origin (Float) via Fakemeta?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-16-2006 , 14:35   Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #1

How to:


1. Spawn an Entity at an Origin (Float) via Fakemeta?

2. Remove an Entity via Fakemeta?
__________________
EAT YOUR VEGGIES
Silencer123 is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 10-16-2006 , 16:12   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #2

Code:
// 1: create_entity(const classname[], Float:origin[3] = {0.0, 0.0, 0.0}) {     new ent     ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))     if(ent) {         set_pev(ent, pev_origin, origin)            dllfunc(DLLFunc_Spawn, ent)     }     return ent } // 2: remove_entity(ent) {     if(pev_valid(ent))         engfunc(EngFunc_RemoveEntity, ent) }
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-16-2006 , 16:58   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #3

Use EngFunc_SetOrigin, not pev_origin.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Old 10-16-2006, 20:01
k007
This message has been deleted by k007.
commonbullet
Veteran Member
Join Date: Oct 2005
Old 10-16-2006 , 20:06   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #4

Quote:
Originally Posted by XxAvalanchexX View Post
Use EngFunc_SetOrigin, not pev_origin.
what's the difference?
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
Old 10-16-2006, 20:13
k007
This message has been deleted by k007.
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-16-2006 , 21:18   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #5

Quote:
Originally Posted by commonbullet View Post
what's the difference?
The comment for entity_set_origin (engine module's equivalent to EngFunc_SetOrigin) is:
Code:
/* Proper origin setting, keeps updated with Half-Life engine. */
One is proper, one is not. That's the difference. ;)
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS

Last edited by XxAvalanchexX; 10-16-2006 at 22:13.
XxAvalanchexX is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 10-16-2006 , 21:51   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #6

I only asked because I've been using pev_origin to change an entity origin and I've never faced a bug; but I'm sure that this function must be safer (and proper).
Thanks.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
P34nut
AMX Mod X Beta Tester
Join Date: Feb 2006
Location: Netherlands
Old 10-17-2006 , 03:39   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #7

if you use set_pev to set an origin of a player your server will crash...
__________________
All you need to change the world is one good lie and a river of blood
P34nut is offline
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-17-2006 , 05:56   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #8

@ commonbullet: I was going to use fakemeta only
= Unknown symbol "remove_entity"
&= Unknown symbol "create_entity"
...
__________________
EAT YOUR VEGGIES
Silencer123 is offline
commonbullet
Veteran Member
Join Date: Oct 2005
Old 10-17-2006 , 10:30   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #9

I've been very stupid to use the same names as engine functions; but they’re 100% fakemeta and they don’t work exactly like the engine functions (i.e. create_entity in engine doesn’t 'spawn' the entity, you would have DispatchSpawn after creating; I was trying to give you examples.)

And that’s the proper way to set origin.
Code:
create_entity_at(const classname[], Float:origin[3] = {0.0, 0.0, 0.0}) {     new ent     ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, classname))     if(ent) {         engfunc(EngFunc_SetOrigin, ent, origin)         dllfunc(DLLFunc_Spawn, ent)     }     return ent }

Last edited by commonbullet; 10-17-2006 at 10:34.
commonbullet is offline
Send a message via ICQ to commonbullet Send a message via MSN to commonbullet
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-17-2006 , 14:36   Re: Spawn an Entity at an Origin (Float) via Fakemeta?
Reply With Quote #10

Ok, I have made this Plugin to replace an Entity with another, but actually nothing happens:
Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define VERSION "1.0" new content_what[64][100] new content_with[64][100] public plugin_init() {     register_plugin("Entity Replacer",VERSION,"Silencer")     {         new path[128]         get_configsdir(path,127)         add(path,127,"/ent_replace.txt")         switch(file_exists(path))         {             case 1:             {                 new howlong                 new result[128]                 for(new i=0;i<100;i++)                 {                     read_file(path,i,result,127,howlong)                     parse(result,content_what,63,content_with,63)                 }             }             case 0:             {                 set_fail_state("NO FILE")             }         }     }     register_forward(FM_Spawn,"ER_Spawn") } public ER_Spawn(entid) {     new classname[64]     pev(entid,pev_classname,classname,63)     new curpos     while(curpos<100&&!equali(content_what[curpos],classname))     {         curpos++     }     if(curpos<100)     {         engfunc(EngFunc_RemoveEntity,entid)         if(!equali(content_with[curpos],"NOTHING"))         {             new Float:origin[3]             pev(entid,pev_origin,origin)             new alt_ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,content_with[curpos]))             engfunc(EngFunc_SetOrigin,alt_ent,origin)             dllfunc(DLLFunc_Spawn,alt_ent)             return alt_ent         }     }     return PLUGIN_HANDLED }
"addons\amxmodx\configs\ent_replace.txt":
Code:
weapon_shotgun nothing
ammo_buckshot nothing
weapon_357 weapon_gauss
ammo_357 ammo_gaussclip
What's wrong?
__________________
EAT YOUR VEGGIES
Silencer123 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 04:53.


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