spawn objects/entities [Help]
I come from amxmodx and just started learning sourcepawn, still got a long road ahead.
But I was wondering, is it possible to drop/spawn an object in the map? and is it possible to register touches and thinks for the object/ent? Will it also work for CS:GO? If possible, could someone show me a simple hook to the events? |
Re: spawn objects
Yes, it is possible. You'll want to look into CreateEntityByName and HookEntityOutput. There is an object spawning plugin in the forums somewhere-- search for it. It's for L4D2 but the concept/code doesn't change. As for detecting touch, you may need to hook the entity's OnStartTouch output.
|
Re: spawn objects
Ok, got it.
Just a lil example here: PHP Code:
And can i not choose coordinates to spawn the entity? like for example when a player died get his origin and spawn the entity there: get origin vector of the player: native GetClientAbsOrigin(client, Float:vec[3]); but how do i set that vector as the spawnpoint for the entity, with SetEntDataVector? |
Re: spawn objects
PHP Code:
|
Re: spawn objects
You can just use TeleportEntity() to teleport the object. You can hook onstarttouch like this:
Code:
HookSingleEntityOutput(entity, "OnStartTouch", ontouch); |
Re: spawn objects
Spoiler
Ok thanks mcpan, - I'm not sure how to use sm_dump_datamaps/netprops. tryed on my server as admin but it said unrecognized command? I'll try in server console when i get home. - What is the diffrence between these 2 hooks: SDKHook_StartTouch, SDKHook_Touch? SDKHook_Touch wil continuisly call itself as long as player is touching it and starttouch only once everytime a player touches it? - Can i use this in Entity_OnStartTouch to store in the clientindex of the player touched it without replacing the entity index? SetEntProp(entity, Prop_Data, "PropField_Integer", client);
Spoiler
-In order to teleport an entity, does it need to be already in the game before doing so? - With that hook the callback would only be performed once and then delete itself right? then what exactly is the diffrence between "HookSingleEntityOutput" and "SDKHook"? - What do you mean by adding a dependency to the plugin? This is what i have thusfar(I hope there are not to many mistakes in it): PHP Code:
|
Re: spawn objects
Quote:
PHP Code:
Adding a dependency means requiring the server to have other plugins/extensions installed in order for your plugin to work. If you want to keep your plugin dependency free (as in, no other extensions need to be installed for your plugin), then stick to HookSingleEntityOutput(). Keep in mind that the latest dev branch (SM 1.5) comes with SDK Hooks included, but the stable SM branch does not. |
Re: spawn objects
Thanks for clarifying
Quote:
With the optional fourth param(bool) false, HookSingleEntityOutput() will not act like a think, it just means that the native isnt gonna unhook itself after it has performed his actions and will never do so unless you code it somewhere in the plugin? - and here: (forgive me if this question sounds abit newb but i'm coming from amxx and these tags confuse me sometime) Code:
HookSingleEntityOutput(entity, "OnStartTouch", ontouch); Code:
19:01:27 sm_dump_netprops test.txt |
Re: spawn objects
Quote:
|
Re: spawn objects
Quote:
Code:
HookSingleEntityOutput(entity, "OnStartTouch", ontouch, true); As for your second question, the "output[]" character array will contain the name of the output (i.e. "OnStartTouch"). The caller is generally the entity that was touched, and the activator is the entity that did the touching. The delay param applies if the output was fired with a delay (i.e. the map developer triggered a delayed I/O chain). Lastly, no, you cannot get rid of any params from the callback, as that would screw up the stack. |
All times are GMT -4. The time now is 15:54. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.