Raised This Month: $ Target: $400
 0% 

Getting ammo type (particularly grenades)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Kailo
Senior Member
Join Date: Sep 2014
Location: Moscow, Russia
Old 08-21-2017 , 17:32   Getting ammo type (particularly grenades)
Reply With Quote #1

As CreateEntityByName has broken, this my way to get ammo type.
(Ammo type needs for me to check/give/remove grenades from player inventory)
I use engine basic function for it CAmmoDef::Index(const char *).
For call this function we need CAmmoDef object that we can get with GetAmmoDef() function.

PHP Code:
Handle g_hGameConf;
int g_HEGrenadeOffset;
int g_FlashbangOffset;
int g_SmokegrenadeOffset;
int g_MolotovOffset;
int g_DecoyOffset;

public 
void OnPluginStart()
{
    
g_hGameConf LoadGameConfigFile("gamedata");

    
g_HEGrenadeOffset CAmmoDef_Index("AMMO_TYPE_HEGRENADE");
    
g_FlashbangOffset CAmmoDef_Index("AMMO_TYPE_FLASHBANG");
    
g_SmokegrenadeOffset CAmmoDef_Index("AMMO_TYPE_SMOKEGRENADE");
    
g_MolotovOffset CAmmoDef_Index("AMMO_TYPE_MOLOTOV");
    
g_DecoyOffset CAmmoDef_Index("AMMO_TYPE_DECOY");
}

int CAmmoDef_Index(const char[] type)
{
    static 
Handle call null;
    if (
call == null) {
        
StartPrepSDKCall(SDKCall_Raw);
        
PrepSDKCall_SetFromConf(g_hGameConfSDKConf_Signature"CAmmoDef_Index");
        
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);
        
PrepSDKCall_AddParameter(SDKType_StringSDKPass_Pointer);
        
call EndPrepSDKCall();
        if (!
call)
            
SetFailState("Can't load function call.");
    }
    static 
any AmmoDef 0;
    if (
AmmoDef == 0)
        
AmmoDef GetAmmoDef();
    return 
SDKCall(callAmmoDeftype);
}

any GetAmmoDef()
{
    static 
Handle call null;
    if (
call == null) {
        
StartPrepSDKCall(SDKCall_Static);
        
PrepSDKCall_SetFromConf(g_hGameConfSDKConf_Signature"GetAmmoDef");
        
PrepSDKCall_SetReturnInfo(SDKType_PlainOldDataSDKPass_Plain);
        
// No args
        
call EndPrepSDKCall();
        if (!
call)
            
SetFailState("Can't load function call.");
    }
    return 
SDKCall(call);

gamedata:
Code:
"Games"
{
	"csgo"
	{
		"Signatures"
		{
			"GetAmmoDef"
			{
				"library"		"server"
				"windows"		"\x80\x3D\x2A\x2A\x2A\x2A\x00\x0F\x85\x2A\x2A\x2A\x2A\x6A\x0E"
				"linux"			"\x55\x89\xE5\x83\xEC\x38\x80\x3D\x2A\x2A\x2A\x2A\x00\x0F\x85\x2A\x2A\x2A\x2A"
			}
			"CAmmoDef_Index"
			{
				"library"		"server" 
				"windows"		"\x55\x8B\xEC\x8B\x45\x08\x85\xC0\x75\x2A\x83\xC8\xFF"
				"linux"			"\x55\x89\xE5\x57\x56\x53\xBB\xFF\xFF\xFF\xFF\x83\xEC\x1C\x8B\x45\x0C"
			}
		}
	}
}

Last edited by Kailo; 08-21-2017 at 18:17.
Kailo is offline
 



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 22:40.


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