AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Ham_Spawn vs. FM_Spawn (https://forums.alliedmods.net/showthread.php?t=106107)

vitorrd 10-11-2009 17:48

Ham_Spawn vs. FM_Spawn
 
I just ran into a problem involving entities and I have a few questions about them (the main one being the thread's name).

1 - What is the difference between Ham_Spawn and FM_Spawn (besides being from different modules, obviously)?

2 - When an entity like a func_button is created, is it removed in any moment or is if I get its ID a single time it's guaranteed to work at all times (suppose the button is only pressed, not destroyed or moved in any way)?

3 - How do I check the state of a button (i.e. if a button is on "activated" state, if that exists, of course)?

Thanks in advance, and, I shall update this post if any more questions are related to them.

Arkshine 10-11-2009 17:59

Re: Ham_Span vs. FM_Spawn
 
1 - With Ham you can provide a classname. ( generic classname, custom won't work ). So it should be called only for the entities with this classname. FM_Spawn is called for all entities, and you would need to retrieve pev_classname + doing a check. It's more efficient to use Ham here. But attention, Ham is buggy because it seems that RegisterHam registers all the entities which share the same internal class instead of the classname. ( RegisterHamFromEntity exist for that but RegisterHam should not work like that. )

2 - If an entity is created it will not removed and you can use it all the times unless you delete it manually.

3 - You can try Ham_GetToggleState. There is probably an offset for that. ( m_toggle_state = 41 ) ; edit: the enum used : enum TOGGLE_STATE {TS_AT_TOP, TS_AT_BOTTOM, TS_GOING_UP ,TS_GOING_DOWN }; ( see buttons.cpp )

vitorrd 10-11-2009 18:32

Re: Ham_Spawn vs. FM_Spawn
 
If I'm not wrong I've already tried Ham_GetToggleState and it always returned the same value.

Arkshine 10-11-2009 18:53

Re: Ham_Spawn vs. FM_Spawn
 
GetToggleState seems to return m_toggle_state. ( but you can try directly m_toggle_state )

If you pass a button index, it should work fine.

vitorrd 10-11-2009 20:13

Re: Ham_Spawn vs. FM_Spawn
 
When you press a button, the button usually lightens up and then, after some time, lightens down again (so you can press it again). I need to check for the state of the button according to its activity.
Would I then need to count the amount of button presses?

Arkshine 10-11-2009 20:21

Re: Ham_Spawn vs. FM_Spawn
 
Did you try the offset ? It should work.

vitorrd 10-11-2009 20:23

Re: Ham_Spawn vs. FM_Spawn
 
I actually didn't try it, to be honest. But I did try Ham_GetToggleState and it returned the very same value both times (before and after pressing it). Do you mind telling me how to read an offset from an entity? Kinda new to AMXX API.

Arkshine 10-11-2009 20:34

Re: Ham_Spawn vs. FM_Spawn
 
const m_toggle_state = 41;

get_pdata_int( button_index, m_toggle_state );

vitorrd 10-11-2009 20:36

Re: Ham_Spawn vs. FM_Spawn
 
Thank you.

vitorrd 10-12-2009 10:38

Re: Ham_Spawn vs. FM_Spawn
 
Ok, so then I was trying to check for a func_button at FM_Spawn:

PHP Code:

g_spawnFwd register_forward(FM_Spawn"Forward_Spawn_Post"1

It simply happens that Forward_Spawn_Post is never called. I added a simply counter to it, like:

PHP Code:

public Forward_Spawn_Post (ent)
{
    
g_count++


But g_count stays 0.
Any clues?


All times are GMT -4. The time now is 22:33.

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