AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved UNfreezing an entity? func_physbox (https://forums.alliedmods.net/showthread.php?t=302511)

heroicpower7613 11-01-2017 03:26

UNfreezing an entity? func_physbox
 
hey i put up this code that freezes an entity fine
but when i try to unfreeze it, it just disappears?
i've tried all MOVETYPE's, none of it worked and VPHYSICS makes it disappear.
also tried some entity inputs and stuff but i can't seem to get it unfreeze properly.
help?

PHP Code:

public void OnPluginStart() {
    
RegConsoleCmd("sm_entfreeze"CMD_Freeze);
    
RegConsoleCmd("sm_unfreeze"CMD_UnFreeze);



public 
Action:CMD_Freeze(clientargs
{
    new 
ent Entity_FindByHammerId(89937"func_physbox");
    
SetEntityMoveType(entMOVETYPE_NONE);
    
    
PrintToChatAll("frozen");
    return 
Plugin_Handled;
}


public 
Action:CMD_UnFreeze(clientargs
{
    new 
ent Entity_FindByHammerId(89937"func_physbox");
    
SetEntityMoveType(entMOVETYPE_VPHYSICS);
    
    
PrintToChatAll("unfreeze");
    return 
Plugin_Handled;


some info from stripper:

Spoiler

hmmmmm 11-01-2017 03:37

Re: UNfreezing an entity? func_physbox
 
try MOVETYPE_FLYGRAVITY

heroicpower7613 11-01-2017 03:47

Re: UNfreezing an entity? func_physbox
 
Quote:

Originally Posted by hmmmmm (Post 2557858)
try MOVETYPE_FLYGRAVITY

thanks for reply but as i mentioned in my post i tried all MOVETYPE's and none of it is unfreezing the entity, its still frozen.

hmmmmm 11-01-2017 04:03

Re: UNfreezing an entity? func_physbox
 
Sorry didn't see that. Might want to try doing some debug prints to check velocity/position of block before and after unfreezing it and to check if it still exists or if it's moved.

heroicpower7613 11-01-2017 06:14

Re: UNfreezing an entity? func_physbox
 
PHP Code:

    new Float:iEntOrigin[3];
    
GetEntPropVector(entProp_Send"m_vecOrigin"iEntOrigin);
    
PrintToChatAll("Origin0: %.3f Origin1: %.3f Origin2: %.3f"iEntOrigin[0], iEntOrigin[1], iEntOrigin[2]); 

i did some position checks, and when trying to unfreeze it with MOVETYPE_FLYGRAVITY nothing happens. the origin stays the same:

PHP Code:

Origin04579.900 Origin1: -387.174 Origin2: -430.626 //moving
Origin04423.630 Origin1: -422.721 Origin2: -430.216 //moving
Origin04497.734 Origin1: -603.363 Origin2: -429.107 //moving
entity freezed
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
unfreezed
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890
Origin0
4595.532 Origin1: -580.904 Origin2: -428.890 

with MOVETYPE_VPHYSICS however, the entity starts falling underground and out of bounds:

PHP Code:

Origin04406.973 Origin1: -514.886 Origin2: -427.262 //moving
Origin04500.112 Origin1: -601.705 Origin2: -428.239 //moving
Origin04620.349 Origin1: -544.750 Origin2: -428.291 //moving
entity freezed
Origin0
4629.990 Origin1: -441.098 Origin2: -429.964
Origin0
4629.990 Origin1: -441.098 Origin2: -429.964
Origin0
4629.990 Origin1: -441.098 Origin2: -429.964
Origin0
4629.990 Origin1: -441.098 Origin2: -429.964
Origin0
4629.990 Origin1: -441.098 Origin2: -429.964
unfreezed
Origin0
4555.744 Origin1: -361.949 Origin2: -2895.005 //falling
Origin04555.744 Origin1: -361.949 Origin2: -3116.121
Origin0
4555.744 Origin1: -361.949 Origin2: -3346.939
Origin0
4555.744 Origin1: -361.949 Origin2: -3567.766
Origin0
4555.744 Origin1: -361.949 Origin2: -3817.415
Origin0
4555.744 Origin1: -361.949 Origin2: -4048.789
Origin0
4555.744 Origin1: -361.949 Origin2: -4281.076
Origin0
4555.744 Origin1: -361.949 Origin2: -4514.711
Origin0
4555.744 Origin1: -361.949 Origin2: -4770.500
Origin0
4555.744 Origin1: -361.949 Origin2: -5024.881
Origin0
4555.744 Origin1: -361.949 Origin2: -5386.742
Nov  1 10
:58:40:  Ignoring unreasonable position (4555.744141,-361.949768,-46345.417969from vphysics! (entity roulette_boll1

i guess it becomes unsolid or something?
i tried to make it somewhat solid with
PHP Code:

    DispatchKeyValue(ent"solid""1");
    
SetEntProp(entProp_Send"m_CollisionGroup"5); 

but it keeps falling

heroicpower7613 11-01-2017 07:25

Re: UNfreezing an entity? func_physbox
 
okay i solved it.

before you freeze it, get the entity origin and store it to global float variable like this:
PHP Code:

new Float:g_WorldPosition[3];

public 
Action:CMD_Freeze(clientargs
{
    new 
ent Entity_FindByHammerId(89937"func_physbox");
    
    new 
Float:iEntOrigin[3];
    
GetEntPropVector(entProp_Send"m_vecOrigin"iEntOrigin);
    
    
g_WorldPosition[0] = iEntOrigin[0];
    
g_WorldPosition[1] = iEntOrigin[1];
    
g_WorldPosition[2] = iEntOrigin[2] + 1.0//Move it up just a little bit 
    
    
SetEntityMoveType(entMOVETYPE_NONE);
    
    
PrintToChatAll("entity freezed");
    return 
Plugin_Handled;



when you unfreeze it, use MOVETYPE_VPHYSICS and set the entity origin to what we made before:

PHP Code:

public Action:CMD_UnFreeze(clientargs
{
    new 
ent Entity_FindByHammerId(89937"func_physbox");
    
SetEntityMoveType(entMOVETYPE_VPHYSICS);
    
    
TeleportEntity(entg_WorldPositionNULL_VECTORNULL_VECTOR);
    
    
PrintToChatAll("unfreeze");
    return 
Plugin_Handled;


i think it was stuck inside the ground before because there was moving ground under it that was not flat.
so it works when i teleport the entity slightly up like this g_WorldPosition[2] = iEntOrigin[2] + 1.0;


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

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