Im using this metod:
https://forums.alliedmods.net/showthread.php?t=129597 with a func_button but when I press use on it just falls down out of the map and cannot be used again.
I can see it falling becouse i have sv showimpacts on and im constantly shooting it with the negev.
Do anyone know how to solve it?
Thanks
PHP Code:
public int ButtonTest( const float origin[3], const float angles[3] ) {
int ent = CreateEntityByName("func_button");
if (ent == -1)
{
return -1;
}
DispatchKeyValue(ent, "targetname", "test");
DispatchKeyValue(ent, "spawnflags", "1024"); //Tried also with 1025
DispatchKeyValue(ent, "pushdir", "0 90 0"); //Tried also without this and without speed
DispatchKeyValue(ent, "movedir", "0 0 0"); //goes to "0 0 0"
DispatchKeyValue(ent, "speed", "1"); //speed 1 so i can see falling out of the map
DispatchSpawn(ent);
TeleportEntity(ent, origin, angles, NULL_VECTOR);
SetEntityModel(ent, "models/props/cs_office/vending_machine.mdl");
new Float:minbounds[3] = {-20.0, -20.0, 20.0};
new Float:maxbounds[3] = {20.0, 20.0, 40.0};
SetEntPropVector(ent, Prop_Send, "m_vecMins", minbounds);
SetEntPropVector(ent, Prop_Send, "m_vecMaxs", maxbounds);
SetEntProp(ent, Prop_Send, "m_nSolidType", 2);
SetEntProp(ent, Prop_Send, "m_CollisionGroup", 1);
int effects = GetEntProp(ent, Prop_Send, "m_fEffects");
effects |= 32; // Sets EF_NODRAW.
SetEntProp(ent, Prop_Send, "m_fEffects", effects);
PrintToChatAll("ent created");
HookSingleEntityOutput( ent, "OnPressed", OnButtonPressed_func, false );
return ent;
}
public OnButtonPressed_func(const char[] output, int caller, int activator, float delay)
{
PrintToChatAll("Button Pressed");
}
Edit: I finally know the reason why it falls down, the movedir keyvalue is where the button is going to in relation to the map not in relation to itself, so it just goes to position 0 0 0, If I remove movedir its just the same default value(0 0 0), is there anyway to pass the origin[3] float to a string so it can be put as a keyvalue in movedir? Or is it possible to dont make the func_button move at all(tried with flag 1024 + 1, didnt work)?