AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can fake player entities be given weapons? (https://forums.alliedmods.net/showthread.php?t=3033)

Mugwump 06-24-2004 13:38

Can fake player entities be given weapons?
 
I tried to give_item() a weapon to the fake player entity I created and it ended up causing odd results: the entity fell through the floor slowly and never did have the weapon, or at least it wasn't wielded.

Anyone know of sma source I could look at to accomplish this (assuming its possible) or if not does anyone have any suggestions?

Also, if give_item() doesn't cause an entity to wield the weapon, what would be the followup command to do that?

Thanks for any assistance!

Mugwump

BAILOPAN 06-24-2004 13:53

give_item is a weird command that actually is kind of hackish.

It creates an entity, then forces it to touch the target. If it still exists after touching, it's deleted. So the only reason you "see" an entity is that it's a temporary marker.

If your entity is not a player that registers touching like that, nothing will happen. After all, only valid players can use weapons.

Ryan 06-24-2004 18:32

If i'm not mistaken, you can get/set what weapon a player model (even if it's fake) is holding using.

Code:
// Get weapon model held new szWeaponModel[64]; Entvars_Get_String( iEnt, EV_SZ_weaponmodel, szWeaponModel, 63 ); // Set weapon model held Entvars_Set_String( iEnt, EV_SZ_weaponmodel, "someweaponname" );

I believe it goes by p_weaponname.mdl but i'm not sure. I am almost postive that you can achieve this, if not with EV_SZ_weaponmodel, then one of the other string entity variables.

Mugwump 06-24-2004 21:19

Hmm, so there is no way for a fake player entity to wield a weapon? If so that doesn't explain how bots can wield weapons unless they are actually interfaced to be _real_ players as far as the server understands ... In any event this is disappointing . :(

Mugwump

BAILOPAN 06-24-2004 22:07

1] Bots ARE real players...

2] Ryan just gave you code to strap weapon models on, does it work?

Mugwump 06-24-2004 22:25

Sorry, when I posted earlier I hadnt seen your post Ryan, will be checking into it and will post.

Thanks
Mugwump

Mugwump 06-24-2004 22:52

I was not able to get the weaponmodel string to work. I tried the following to copy my weaponmodel to the entity:

Code:

  new szWeaponModel[64];
  Entvars_Get_String( id, EV_SZ_weaponmodel, szWeaponModel, 63 );
  Entvars_Set_String( dEnt, EV_SZ_weaponmodel, szWeaponModel );

The model spawns with no weapon, in his idle sequence. I also added an additional _Get_String call to verify that the model actually had the right weapon name set, it did.

I then tried:

Code:

  entity_set_string(dEnt, EV_SZ_weaponmodel,"models/p_knife.mdl")
and I added that model name to the plugin_precache() list of precached models, no change. I realize the above is simply an alias for the older format but wanted to rule that out just in case.

If that setting has any effect I don't see it. :(

Mugwump

Neo-Vortex 06-25-2004 03:45

hmmm
 
speaking of which, that gave me an idea, is it possible to give hostages a gun? (like they just hold it to look pretty, they dont shoot nor drop it when dead :P)

if it is possible, would it be done the same way as mentioned above (if it works) or some other way, and if it is possible by the way mentioned above, how do you get the id or whatever of the hostages (Im guessing theres one for each)

Ryan 06-25-2004 03:48

i dont think so. I think the player models are coded with properties to accept the weapon attachments, whereas the hostage models are probably not.

Neo-Vortex 06-25-2004 03:56

hmmm
 
hmmm, ill check if they can hold a gun or not...


All times are GMT -4. The time now is 14:53.

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