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

Solved [CS:GO] List of Event Function Prototypes?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Austin
Senior Member
Join Date: Oct 2005
Old 08-31-2021 , 06:02   [CS:GO] List of Event Function Prototypes?
Reply With Quote #1

I am writing plugins using this list of CSGO events.
https://wiki.alliedmods.net/Counter-...fensive_Events
It states:
The following events can be found in csgo\pak01_dir.vpk in the file resource\modevents.res.

But I can’t extract any of the csgo pak files. VPK will not list or extract any of them.

How do I get a copy of these res files and how do I get a list of all CSGO events with their function prototypes (return type, number of parameters and their types)?

Last edited by Austin; 09-06-2021 at 14:28.
Austin is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 08-31-2021 , 06:30   Re: [CS:GO] List of Event Function Prototypes?
Reply With Quote #2

You have to open up pak01_dir.vpk with GCFScape to view the contents and extract the file you want directly.
__________________
Psyk0tik is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-01-2021 , 19:13   Re: [CS:GO] List of Event Function Prototypes?
Reply With Quote #3

I tried the latest GCFScape v1.8.6 (from 2006!)
It "opens" the pak files but just shows
root
and nothing else.

Last edited by Austin; 09-01-2021 at 19:13.
Austin is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 09-01-2021 , 22:16   Re: [CS:GO] List of Event Function Prototypes?
Reply With Quote #4

Like Psyk0tik mentioned, you only need to open one file not files, pak01_dir.vpk,

Maxximou5 is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-04-2021 , 00:16   Re: [CS:GO] List of Event Function Prototypes?
Reply With Quote #5

Quote:
Originally Posted by Maxximou5 View Post
Like Psyk0tik mentioned, you only need to open one file not files, pak01_dir.vpk,
So you have to open the dir vpk file!
Thank you (both) for making that perfectly clear!

Back to the original question.
Now that I have the modevents.res file for csgo I still don't see how I would know the function prototype for any given event.

All this res file is a text version of what is shown on the SourceMod site.

So for example player_hurt event shows
Code:
	"player_hurt"
	{
		"userid"	"short"   	// player index who was hurt
		"attacker"	"short"	 	// player index who attacked
		"health"	"byte"		// remaining health points
		"armor"		"byte"		// remaining armor points
		"weapon"	"string"	// weapon name attacker used, if not the world
		"dmg_health"	"short"	// damage done to health
		"dmg_armor"	"byte"		// damage done to armor
		"hitgroup"	"byte"		// hitgroup that was damaged
	}
To hook this event you need a function with this return type and these parameters.
public Action:Event_player_hurt(Handle:event, const String:name[], bool:dontBroadcast)

I can't know this from looking at this event in the res file or from the Sourcemodd site that lists the csgo events.

What I have been doing is looking for a plugin that uses the praticular event I need and then copying the prototype from there.

It looks like most or a lot of events have that return type and those three parms but others do not.
This one has two int parms.
public Action WeaponEquip_Hook(int client, int weapon)

Again, when I hook an event how do I know what the parms and return type I need for the hook function I need to to create?
Austin is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 09-04-2021 , 00:49   Re: [CS:GO] List of Event Function Prototypes?
Reply With Quote #6

Quote:
Originally Posted by Austin View Post
So you have to open the dir vpk file!
Thank you (both) for making that perfectly clear!

Back to the original question.
Now that I have the modevents.res file for csgo I still don't see how I would know the function prototype for any given event.

All this res file is a text version of what is shown on the SourceMod site.

So for example player_hurt event shows
Code:
	"player_hurt"
	{
		"userid"	"short"   	// player index who was hurt
		"attacker"	"short"	 	// player index who attacked
		"health"	"byte"		// remaining health points
		"armor"		"byte"		// remaining armor points
		"weapon"	"string"	// weapon name attacker used, if not the world
		"dmg_health"	"short"	// damage done to health
		"dmg_armor"	"byte"		// damage done to armor
		"hitgroup"	"byte"		// hitgroup that was damaged
	}
To hook this event you need a function with this return type and these parameters.
public Action:Event_player_hurt(Handle:event, const String:name[], bool:dontBroadcast)

I can't know this from looking at this event in the res file or from the Sourcemodd site that lists the csgo events.

What I have been doing is looking for a plugin that uses the praticular event I need and then copying the prototype from there.
You're confusing the event's params with the event hook prototype.

When you hook any event, the prototype will always be the same.

From events.inc:
PHP Code:
/**
 * Hook function types for events.
 */
typeset EventHook
{
    
// Called when a game event is fired.
    //
    // @param event         Handle to event. This could be INVALID_HANDLE if every plugin hooking 
    //                      this event has set the hook mode EventHookMode_PostNoCopy.
    // @param name          String containing the name of the event.
    // @param dontBroadcast True if event was not broadcast to clients, false otherwise.
    //                      May not correspond to the real value. Use the property BroadcastDisabled.
    // @return              Ignored for post hooks. Plugin_Handled will block event if hooked as pre.
    ///
    
function Action (Event event, const char[] namebool dontBroadcast);
    
    
//
    // Called when a game event is fired.
    //
    // @param event         Handle to event. This could be INVALID_HANDLE if every plugin hooking 
    //                      this event has set the hook mode EventHookMode_PostNoCopy.
    // @param name          String containing the name of the event.
    // @param dontBroadcast True if event was not broadcast to clients, false otherwise.
    ///
    
function void (Event event, const char[] namebool dontBroadcast);
}; 
Quote:
Originally Posted by Austin View Post
It looks like most or a lot of events have that return type and those three parms but others do not.
This one has two int parms.
public Action WeaponEquip_Hook(int client, int weapon)

Again, when I hook an event how do I know what the parms and return type I need for the hook function I need to to create?
The WeaponEquip hook you are referring to is hooked through SDKHooks, not game events.

From sdkhooks.inc:
PHP Code:
// WeaponCanSwitchTo
// WeaponCanUse
// WeaponDrop
// WeaponEquip
// WeaponSwitch
function Action (int clientint weapon);

// WeaponCanSwitchToPost
// WeaponCanUsePost
// WeaponDropPost
// WeaponEquipPost
// WeaponSwitchPost
function void (int clientint weapon); 
A few things you need to understand about these two types of hooks:

1. Event hooks always use the same prototype which include the event handle, the name of the event, and the toggle for broadcasting the event to clients.
2. In order to access each param of an event, you use the event handle provided. Here are some examples for the "player_hurt" event:
PHP Code:
int attacker GetClientOfUserId(event.GetInt("attacker"));
int dmg event.GetInt("dmg_health");
int hitgroup event.GetInt("hitgroup"); 
3. SDK hooks are specific hooks to common functions provided in most, if not all, games supported by SourceMod. For example, the WeaponEquip hook is available in every supported Source game so SDKHooks' API allows developers to hook that function in their plugins. They are not the same as event hooks since event hooks act as notifications while SDK hooks act as forwards for plugins.
__________________

Last edited by Psyk0tik; 09-04-2021 at 01:37.
Psyk0tik is offline
Austin
Senior Member
Join Date: Oct 2005
Old 09-04-2021 , 07:04   Re: [CS:GO] List of Event Function Prototypes?
Reply With Quote #7

Quote:
Originally Posted by Psyk0tik View Post
1. Event hooks always use the same prototype which include the event handle, the name of the event, and the toggle for broadcasting the event to clients.
2. In order to access each param of an event, you use the event handle provided. Here are some examples for the "player_hurt" event:
3. SDK hooks are specific hooks to common functions provided in most, if not all, games supported by SourceMod...
1) I was sort of starting to get this for event hooks, now I know.
2) I wasn't toatally clear but yes I have been using events and parms and the accessor functions on them so I did understand this part, tx.
3) Look in the inc files! Yes! Thanks you for this tip and I should have thought of that.

4) I got it! All of the prototypes are in those and probably other inc files.
Thank you and great job on explaining it all.
Austin is offline
Reply



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:17.


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