AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Fakemeta Entity Spawn (https://forums.alliedmods.net/showthread.php?t=54508)

Minimum 04-27-2007 22:53

Fakemeta Entity Spawn
 
Heres the problem, I cannot get this entity to appear when I execute this function. I know it spawns the item because it does not display the error message I have in here. Any suggestions on how to get this to work? I have already precached the model just for your info.

Code:
public spawn_item(itemid,amount,origin[3]) {     new targetname[64], Float:forigin[3]     formatex(targetname,63,"%i|%i",itemid,amount)     new Float:minsx[3] = { -2.5, -2.5, -2.5 }     new Float:maxsx[3] = { 2.5, 2.5, -2.5 }     new Float:angles[3] = { 0.0, 0.0, 0.0 }     forigin[0] = float(origin[0])     forigin[1] = float(origin[1])     forigin[2] = float(origin[2])     angles[1] = float(random_num(0,360))     new item = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))     if(!item) {         log_amx("ERROR: Item failed to spawn.")         return PLUGIN_HANDLED     }     set_pev(item,pev_targetname,targetname)     set_pev(item,pev_classname,"dropped_item")     set_pev(item,pev_mins,minsx)     set_pev(item,pev_maxs,maxsx)     set_pev(item,pev_angles,angles)     set_pev(item,pev_dmg,0.0)     set_pev(item,pev_dmg_take,0.0)     set_pev(item,pev_max_health,50000.0)     set_pev(item,pev_health,50000.0)     set_pev(item,pev_solid,SOLID_TRIGGER)     set_pev(item,pev_movetype,MOVETYPE_TOSS)     set_pev(item,pev_model,"models/roleplay/w_backpack.mdl")     set_pev(item,pev_origin,forigin)     return PLUGIN_HANDLED }

stupok 04-28-2007 00:27

Re: Fakemeta Entity Spawn
 
Give this a whirl:

Code:
public spawn_item(itemid, amount, Float:origin[3]) {     new targetname[64]     formatex(targetname,63,"%i|%i",itemid,amount)         new item = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))         if(!pev_valid(item))     {         log_amx("ERROR: Item failed to spawn.")         return PLUGIN_HANDLED     }         set_pev(item,pev_targetname,targetname)     set_pev(item,pev_classname,"dropped_item")     set_pev(item,pev_mins,{ -2.5, -2.5, -2.5 })     set_pev(item,pev_maxs,{ 2.5, 2.5, -2.5 })     set_pev(item,pev_angles,{ 0.0, random_float(0.0, 360.0), 0.0 })     set_pev(item,pev_dmg,0.0) //necessary?     set_pev(item,pev_dmg_take,0.0) //necessary?     set_pev(item,pev_max_health,50000.0) //necessary?     set_pev(item,pev_health,50000.0) //necessary?     set_pev(item,pev_solid,SOLID_TRIGGER)     set_pev(item,pev_movetype,MOVETYPE_TOSS)     set_pev(item,pev_model,"models/roleplay/w_backpack.mdl")     //set_pev(item,pev_origin,forigin)     engfunc(EngFunc_SetOrigin, item, origin)     return PLUGIN_HANDLED }

Zenith77 04-28-2007 00:35

Re: Fakemeta Entity Spawn
 
Can you say,

Code:
dllfunc(DLLFunc_Spawn, item);

stupok 04-28-2007 00:42

Re: Fakemeta Entity Spawn
 
Zenith I'm pretty sure that isn't necessary.

Minimum 04-28-2007 01:35

Re: Fakemeta Entity Spawn
 
Zenith's way did not work.

Stupok69's way made it return this:
Got a NaN origin on dropped_item

Minimum 04-28-2007 18:30

Re: Fakemeta Entity Spawn
 
Found the problem. It was the pev_model line. I changed it to the following and it worked:

engfunc(EngFunc_SetModel, item, "models/roleplay/w_backpack.mdl")

Zenith77 04-29-2007 21:17

Re: Fakemeta Entity Spawn
 
Quote:

Originally Posted by stupok69 (Post 470553)
Zenith I'm pretty sure that isn't necessary.

Actually it is, search the forums for why.

stupok 04-29-2007 21:39

Re: Fakemeta Entity Spawn
 
I'm not going to bother, because I didn't use that line when I was playing around with ents using fakemeta and everything worked just fine. It looks like Minimum didn't use that line either.

If you want to give a link or a brief explanation, that'd be nice.

Zenith77 04-29-2007 21:58

Re: Fakemeta Entity Spawn
 
I'll find one later. It all depends on what you're doing with the entity, like are you editing keyvalues or other stuff.


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

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