AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   TS Grenade Spawn (https://forums.alliedmods.net/showthread.php?t=58367)

Minimum 07-24-2007 18:47

TS Grenade Spawn
 
Trying to figure out how to spawn a grenade to help me better understand the HL Engine and Fakemeta. This code is saying it is failing to spawn the entity from the beginning. Any thoughts?

Code:
public create_grenade(id) {     if(gab_playerid(id) == 1) {         new Float:origin[3]         pev(id,pev_origin,origin)         origin[2] = origin[2] + 50.0         new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "grenade"))         if(pev_valid(ent)) hud_display(id,"Grenade Spawned.",HUD_STATUS)         else hud_display(id,"Grenade Failed.",HUD_STATUS)         engfunc(EngFunc_SetModel, ent, "models/briefcase.mdl")         engfunc(EngFunc_SetOrigin, ent, origin)         set_task(2.0,"grenade_think",ent)     }     return PLUGIN_HANDLED } public grenade_think(id) {     DF_Think(id)     DF_Use(id,id)     return PLUGIN_HANDLED }

Printent from SHP Tools of a live grenade created by the game.

Code:

Printing out entity #271 variable information...
(variable name = value (meaning))
pev_classname = 67731712 ("grenade")
pev_globalname = 0 ("")
pev_origin = Vector (-407.9, 38.5, 111.0)
pev_oldorigin = Vector (0.0, 0.0, 0.0)
pev_velocity = Vector (-102.1, -18.6, -49.1) - Length 114.910 - Length2D 103.873

pev_basevelocity = Vector (0.0, 0.0, 0.0) - Length 0.000 - Length2D 0.000
pev_clbasevelocity = Vector (0.0, 0.0, 0.0) - Length 0.000 - Length2D 0.000
pev_movedir = Vector (0.0, 0.0, 0.0)
pev_angles = Vector (205.2, 0.0, 0.0)
pev_avelocity = Vector (29.9, 0.0, 0.0) - Length 29.999 - Length2D 29.999
pev_punchangle = Vector (0.0, 0.0, 0.0)
pev_v_angle = Vector (0.0, 0.0, 0.0)
pev_endpos = Vector (0.0, 0.0, 0.0)
pev_startpos = Vector (0.0, 0.0, 0.0)
pev_impacttime = 0.000
pev_starttime = 0.000
pev_fixangle = 0 (nothing)
pev_idealpitch = 0.000
pev_pitch_speed = 0.000
pev_ideal_yaw = 0.000
pev_yaw_speed = 0.000
pev_modelindex = 234
pev_model = 67697400 ("models/w_m61.mdl")
pev_viewmodel = 0 ("")
pev_weaponmodel = 0 ("")
pev_absmin = Vector (-408.9, 37.5, 110.0)
pev_absmax = Vector (-406.9, 39.5, 112.0)
pev_mins = Vector (0.0, 0.0, 0.0)
pev_maxs = Vector (0.0, 0.0, 0.0)
pev_size = Vector (0.0, 0.0, 0.0)
pev_ltime = 0.000 (current time is 1157.270)
pev_nextthink = 1157.319 (current time is 1157.270)
pev_movetype = 10 (MOVETYPE_BOUNCE)
pev_solid = 2 (SOLID_BBOX)
pev_skin = 0 ("")
pev_body = 0 ("")
pev_effects = 0 ()
pev_gravity = 0.016 (fraction /1 of normal)
pev_friction = 0.800
pev_light_level = 0
pev_sequence = 0 ("")
pev_gaitsequence = 1 ("")
pev_frame = 0.000 (position /255 of total in sequence)
pev_animtime = 0.000 (current time is 1157.270)
pev_framerate = 0.000 (times normal speed)
pev_controller = {131655936, 131655936, 131655936, 131655936}
pev_blending = {131655936, 131655936}
pev_scale = 0.000
pev_rendermode = 0 (kRenderNormal)
pev_renderamt = 0.000
pev_rendercolor = Vector (0.0, 0.0, 0.0) (RGB)
pev_renderfx = 0 (kRenderFxNone)
pev_health = 0.000
pev_frags = 0.000
pev_weapons = 0 (00000000000000000000000000000000)
pev_takedamage = 0.0 (DAMAGE_NO)
pev_deadflag = 0 (DEAD_NO)
pev_view_ofs = Vector (0.0, 0.0, 0.0)
pev_button = 0 ()
pev_impulse = 0
pev_chain = NULL
pev_dmg_inflictor = NULL
pev_enemy = NULL
pev_aiment = NULL
pev_owner = Entity #1 ("player")
pev_groundentity = Entity #0 ("worldspawn")
pev_spawnflags = 0 (00000000000000000000000000000000)
pev_flags = 0 ()
pev_colormap = 0 (0x0)
pev_team = 0
pev_max_health = 0.000
pev_teleport_time = 0.000
pev_armortype = 0.000
pev_armorvalue = 0.000
pev_waterlevel = 0 (not in water)
pev_watertype = -1
pev_target = 0 ("")
pev_targetname = 0 ("")
pev_netname = 0 ("")
pev_message = 0 ("")
pev_dmg_take = 0.000
pev_dmg_save = 0.000
pev_dmg = 0.000
pev_dmgtime = 0.000 (current time is 1157.270)
pev_noise = 0 ("")
pev_noise1 = 0 ("")
pev_noise2 = 0 ("")
pev_noise3 = 0 ("")
pev_speed = 0.000
pev_air_finished = 0.000
pev_pain_finished = 0.000
pev_radsuit_finished = 0.000
pev_pContainingEntity = Entity #271 ("grenade")
pev_playerclass = 0
pev_maxspeed = 0.000
pev_fov = 0.000
pev_weaponanim = 0
pev_pushmsec = 0
pev_bInDuck = 0 (FALSE)
pev_flTimeStepSound = 0 (current time is 1157.270)
pev_flSwimTime = 0 (current time is 1157.270)
pev_flDuckTime = 0 (current time is 1157.270)
pev_iStepLeft = 0
pev_flFallVelocity = 0.000
pev_gamestate = 0
pev_oldbuttons = 0 ()
pev_groupinfo = 0
pev_iuser1 = 0
pev_iuser2 = 0
pev_iuser3 = 0
pev_iuser4 = 2
pev_fuser1 = 0.149
pev_fuser2 = 0.000
pev_fuser3 = 0.000
pev_fuser4 = 0.000
pev_vuser1 = Vector (0.0, 0.0, 0.0)
pev_vuser2 = Vector (0.0, 0.0, 0.0)
pev_vuser3 = Vector (0.0, 0.0, 0.0)
pev_vuser4 = Vector (0.0, 0.0, 0.0)
pev_euser1 = NULL
pev_euser2 = NULL
pev_euser3 = NULL
pev_euser4 = NULL
End of dump.

Edit: When I jump and reach where the ent should of spawned I get a fatal server error which reads "Hit a worldspawn with no model (models/briefcase.mdl)".

It also makes these ents:
Code:

281  (): min (0, 0, 0); siz (0, 0, 0);
282 bodyque (): min (0, 0, 0); siz (0, 0, 0);
283 bodyque (): min (0, 0, 0); siz (0, 0, 0);
284 bodyque (): min (0, 0, 0); siz (0, 0, 0);
285 bodyque (): min (0, 0, 0); siz (0, 0, 0);


stupok 07-24-2007 22:38

Re: TS Grenade Spawn
 
You already PM'ed me about spawning weapons in TS 3.0. I sent you the following code. I just tested the code and I can spawn grenades without a problem.

Code:
stock ts_spawnweapon(weaponid,duration,extraclip,spawnflags,Float:Origin[3]) {     new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "ts_groundweapon"))         new value[16];         formatex(value,15,"%i",weaponid);     set_keyvalue(ent,"tsweaponid",value);         formatex(value,15,"%i",duration);     set_keyvalue(ent,"wduration",value);         formatex(value,15,"%i",extraclip);     set_keyvalue(ent,"wextraclip",value);         formatex(value,15,"%i",spawnflags);     set_keyvalue(ent,"spawnflags",value);         engfunc(EngFunc_SetOrigin, ent, Origin);         dllfunc(DLLFunc_Spawn, ent);         return PLUGIN_HANDLED; } /*   Set Keyvalue - Coded by Basic-Master */   stock set_keyvalue(ent, key[], value[]) {     new classname[32]     pev(ent, pev_classname, classname, 31)     set_kvd(0, KV_ClassName, classname)     set_kvd(0, KV_KeyName, key)     set_kvd(0, KV_Value, value)     set_kvd(0, KV_fHandled, 0)         dllfunc(DLLFunc_KeyValue, ent, 0) }

Minimum 07-24-2007 23:28

Re: TS Grenade Spawn
 
No, this is trying to spawn an actual live grenade that will go off with no further player interaction.

stupok 07-25-2007 00:37

Re: TS Grenade Spawn
 
After toying around with this, I don't think it can be done. For starters, I couldn't make a valid entity with this:

Code:
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "grenade"))

The ent is always invalid. This leads me to believe that it's impossible to create a "grenade" entity. I don't have any experience dealing with this kind of entity.

Unless I'm unaware of something, it seems like you'll have to make a "fake" grenade and then a "fake" explosion to achieve your desired result.

Minimum 07-25-2007 02:38

Re: TS Grenade Spawn
 
Quote:

Originally Posted by stupok69 (Post 507939)
After toying around with this, I don't think it can be done. For starters, I couldn't make a valid entity with this:

Code:
new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "grenade"))

The ent is always invalid. This leads me to believe that it's impossible to create a "grenade" entity. I don't have any experience dealing with this kind of entity.

Unless I'm unaware of something, it seems like you'll have to make a "fake" grenade and then a "fake" explosion to achieve your desired result.

Thats how it seems. But I wonder how TS achieves at this... There must be a way. Unless of course, its impossible to achieve with AMXX and Fakemeta.


All times are GMT -4. The time now is 21:35.

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