AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Spawning a prop_physics and making it follow a player. (https://forums.alliedmods.net/showthread.php?t=77682)

Spazman0 09-18-2008 21:16

Spawning a prop_physics and making it follow a player.
 
I am currently in the process of making a command that spawns a custom model prop_physics above a players head and stays with them when they move. I have written all the foundations for the plugin, and now I just need to spawn the prop.

I am assuming I will need to use CreateEntityByName("prop_physics")(or prop_physics_multiplayer) but that's about as far as I have gotten.

So basically what I need is:

A way to spawn a prop_physics (or prop_physics_multiplayer) with a custom model
A way to make this prop follow the player.

Any help would be wonderful, thank you Allied Modders community.

Also, look for this command in the next release of FuncommandsX.

Spazman0.

Greyscale 09-18-2008 23:14

Re: Spawning a prop_physics and parenting it to a player.
 
There should be a signature for CBaseSomething(Entity?)::SetParent somewhere.. I've seen it before.

You might have to do a bit of research.

Kigen 09-19-2008 00:32

Re: Spawning a prop_physics and parenting it to a player.
 
That prop doesn't support being parented.

http://developer.valvesoftware.com/wiki/Prop_physics

Spazman0 09-19-2008 01:21

Re: Spawning a prop_physics and parenting it to a player.
 
Ok, so reading that article Kigen sent, I might be better off going with prop_physics_multiplayer. Still doesn't solve the issue of how to spawn it and make it follow the player. Any help?

Kigen 09-19-2008 02:27

Re: Spawning a prop_physics and making it follow a player.
 
Read the text I put above my link. I'm saying you CANNOT parent prop_physics.

Look at other props to see if one matches what your trying to do.

http://developer.valvesoftware.com/w...Types_Overview

Spazman0 09-19-2008 04:07

Re: Spawning a prop_physics and making it follow a player.
 
I read the whole article, and couldn't see anywhere that it can't be parented. Unless you are saying this from your own experience, in which case I apologize.

For the moment I am doing away with the parenting and just trying to spawn it. However, when I run the command my server pops up with a message saying: 292/ - prop_physics: UTIL_SetModel: not precached: models/Hat/model.mdl

This is the code I use to spawn the prop and give it the hat model:
PHP Code:

new Float:fPosition[3]
    
GetClientEyePosition(targetfPosition)
    new 
String:sModel[64]
    
sModel "models/Hat/model.mdl"
    
new iModel CreateEntityByName("prop_physics");
    
TeleportEntity(iModelfPositionNULL_VECTORNULL_VECTOR);
    
SetEntityModel(iModel,sModel); 

Any help would be great, thanks.

I am assuming that I have to somehow "precache" the model with the server? If so, how would I go about doing this?

I sv_pure is set to 0, just incase you were wondering.

Kigen 09-19-2008 14:00

Re: Spawning a prop_physics and making it follow a player.
 
Code:

native PrecacheModel(const String:model[], bool:preload=false);
Do it in OnMapStart().

Try prop_dynamic, since that can be parented.

http://developer.valvesoftware.com/wiki/Prop_dynamic

chundo 09-20-2008 02:03

Re: Spawning a prop_physics and making it follow a player.
 
Actually you should use prop_dynamic_override, if I remember my experimentation correctly. I was trying to do exactly this. I gave up in the end - it always ended up obstructing the player's field of view, even if it looked like it shouldn't.

Spazman0 09-20-2008 07:28

Re: Spawning a prop_physics and making it follow a player.
 
EDIT: Got it to work.


Now, I have it spawning as a prop_dynamic_override.

How would I go about parenting it to the player? (assuming the player is defined by "target")

At the moment this is my entire spawn code (Edited chundo's Achievement trophy code)

PHP Code:

new Float:fPosition[3]
    
GetClientEyePosition(targetfPosition)
    
fPosition[2]+=10
    
new String:sModel[64]
    
sModel "models/Hat/model.mdl"
    
new iModel CreateEntityByName("prop_dynamic_override");
    
TeleportEntity(iModelfPositionNULL_VECTORNULL_VECTOR);
    
DispatchKeyValue(iModel"model""models/Hat/model.mdl");
    
DispatchSpawn(iModel);
    
AcceptEntityInput(iModel"SetParent"targettarget0);
    
AcceptEntityInput(iModel"TurnOn"targettarget0); 


Spazman0 09-21-2008 21:02

Re: Spawning a prop_physics and making it follow a player.
 
Sorry to bump, but I wasn't sure people realised I have edited the last post with more details and a new request.


All times are GMT -4. The time now is 20:52.

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