Raised This Month: $32 Target: $400
 8% 

[TF2] DHooks of "IsPlacementPosValid" wont work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
oplkill
Member
Join Date: Aug 2015
Old 09-14-2019 , 12:11   [TF2] DHooks of "IsPlacementPosValid" wont work
Reply With Quote #1

Hi, i trying to hook game function "CBaseObject::IsPlacementPosValid", but it doesnt work, its always return 0(false) in any cases...
What i doing wrong?

PHP Code:
int sentryEntity = -1;
Handle hIsPlacementPosValid;

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_canPlace"Command_ForcePlacementADMFLAG_GENERIC);

    
Handle gamedatafile=LoadGameConfigFile("buildonbuildings_defs.games");
    if(
gamedatafile==null)
    {
        
SetFailState("Cannot find file buildonbuildings_defs.games!");
    }
    
StartPrepSDKCall(SDKCall_Entity);
    
PrepSDKCall_SetFromConf(gamedatafileSDKConf_Signature"CBaseObject::IsPlacementPosValid");
    
PrepSDKCall_SetReturnInfo(SDKType_BoolSDKPass_ByValue);
    
PrepSDKCall_AddParameter(SDKType_CBaseEntitySDKPass_ByValue);
    
PrepSDKCall_AddParameter(SDKType_VectorSDKPass_ByRef);
    
hIsPlacementPosValid EndPrepSDKCall();
}

public 
Action Command_ForcePlacement(int clientint args)
{
    
float flPos[3];
    
GetClientLookPosition(clientflPos);
    
    if (
sentryEntity == -1)
    {
        
sentryEntity SpawnSentry(clientflPos);
    }
    
//TeleportEntity(sentryEntity, NULL_VECTOR, NULL_VECTOR, flPos);
    
    
bool can SDKCall(hIsPlacementPosValidsentryEntityflPos);
    
PrintToChat(client"%d"can);

Attached Files
File Type: sp Get Plugin or Get Source (_testPlacement.sp - 79 views - 4.4 KB)
File Type: txt buildonbuildings_defs.games.txt (473 Bytes, 69 views)
oplkill is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 09-21-2019 , 18:47   Re: [TF2] DHooks of "IsPlacementPosValid" wont work
Reply With Quote #2

You are creating an SDKCall which as the name implies calls a function. Check the DHooks extension documention and the detour documention on how to set it up.
xerox8521 is offline
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 09-22-2019 , 09:24   Re: [TF2] DHooks of "IsPlacementPosValid" wont work
Reply With Quote #3

Exactly why you're trying to hook the function? I noticed that the gamedata's filename and content is the same as the one I posted in Dhooks thread and it's used by build on buildings plugin. You are trying to make such plugin?
__________________
My plugins:
*None for now*


Steam:
naydef
Naydef is offline
oplkill
Member
Join Date: Aug 2015
Old 09-22-2019 , 17:12   Re: [TF2] DHooks of "IsPlacementPosValid" wont work
Reply With Quote #4

Quote:
Originally Posted by Naydef View Post
Exactly why you're trying to hook the function? I noticed that the gamedata's filename and content is the same as the one I posted in Dhooks thread and it's used by build on buildings plugin. You are trying to make such plugin?
I want to call that function with my custom placed sentry to know is that placement that i see by my player is correct by standart valve engineers sentry placements rules or not. For not allow build a sentires at sky boxes or other places...
I guess i messed up with thread name, maybe it supposed to be "How to call game function and get return from it"
oplkill is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 09-22-2019 , 17:26   Re: [TF2] DHooks of "IsPlacementPosValid" wont work
Reply With Quote #5

Quote:
Originally Posted by oplkill View Post
I want to call that function with my custom placed sentry to know is that placement that i see by my player is correct by standart valve engineers sentry placements rules or not. For not allow build a sentires at sky boxes or other places...
I guess i messed up with thread name, maybe it supposed to be "How to call game function and get return from it"
Sounds like you just want to check if a sentry that is being held is placeable where you are trying to built it at currently.

if that is the case then this snippet will tell you whether or not the current placement of the building you are holding is valid:

Code:
if(IsWeapon(actor, TF_WEAPON_BUILDER))
{
	int objBeingBuilt = GetEntPropEnt(GetActiveWeapon(actor), Prop_Send, "m_hObjectBeingBuilt");
	
	if(!IsValidEntity(objBeingBuilt))
		return false;
	
	bool m_bPlacementOK = !!GetEntData(objBeingBuilt, FindSendPropInfo("CObjectSentrygun", "m_iKills") - 4);
}
__________________

Last edited by Pelipoika; 09-22-2019 at 17:26.
Pelipoika is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:15.


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