Raised This Month: $51 Target: $400
 12% 

[EXTENSION] Weapons Extension


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dalto
Veteran Member
Join Date: Jul 2007
Old 09-05-2007 , 02:06   [EXTENSION] Weapons Extension
Reply With Quote #1

This is a very simple extension to expose some functionality that cannot currently be accessed via Sourcemod directly.

Currently 3 forwards are exposed.

Code:
/**
 * @brief Called to determine if a player can use a given weapon
 *
 * @param client    A client index
 * @param weapon    The classname of the weapon
 * @return            Plugin_Handled to block usage, Plugin_Continue to allow it.
 */
forward Action:Weapon_CanUse(client, const String:weapon[]);

/**
 * @brief Called when the active weapon changes
 *
 * @param client    A client index
 * @param oldWeapon    The weapon entity index of the weapon switching from
 * @param newWeapon    The weapon entity index of the weapon switching to
 * @return            None
 */
forward OnChangeActiveWeapon(client, oldWeapon, newWeapon);

/**
 * @brief Called to determine if a player can switch to a given weapon
 *
 * @param client    A client index
 * @param weapon    The classname of the weapon
 * @return            Plugin_Handled to block usage, Plugin_Continue to allow it.
 */
forward Action:Weapon_CanSwitchTo(client, const String:weapon[]);
I would warn the OnChangeActiveWeapon() probably doesn't do what you would expect. I left it in because it can be used to catch certain events.

The focus with this extension is simplicity, I tried to make these functions as simple as possible to use. In doing so I have sacrificed some of the flexibility and power that something like the hacks extension has.

I will be adding to this over time so let me know if you need anything specific.

I believe that the ability to hook virtual forwards is something that will eventually be added to sourcemod but this is intended to help in the interim.

Instructions:
Copy the extension to your addons/sourcemod/extensions directory and include the include file in your plugin. You also need to copy the weapons.games.txt file to your addons/sourcemod/gamedata directory.

The source code is also available.

Supported Mods:
Counter Strike: Source
Day of Defeat: Source
Halflife2: Deathmatch
Sourceforts
Pirates, Vikings and Knights
Insurgency(Weapon_CanUse and Weapon_CanSwitchTo only)
Attached Files
File Type: inc weapons.inc (1.0 KB, 1065 views)
File Type: txt weapons.games.txt (1,013 Bytes, 1117 views)

Last edited by dalto; 09-09-2007 at 02:42. Reason: New Release
dalto is offline
dalto
Veteran Member
Join Date: Jul 2007
Old 09-05-2007 , 02:07   Re: [EXTENSION] Weapons Extension
Reply With Quote #2

I should warn that the linux binary is somewhat untested. I have tested the Windows binary extensively though.

EDIT: I just noticed that all the function briefs are the same. I will fix it tomorrow when I am more awake.

Last edited by dalto; 09-05-2007 at 02:11.
dalto is offline
BAILOPAN
Join Date: Jan 2004
Old 09-06-2007 , 08:29   Re: [EXTENSION] Weapons Extension
Reply With Quote #3

Looks good ;)

Since you didn't include a gameconf file, you may wish to note that it's specific to a game.
__________________
egg
BAILOPAN is offline
dalto
Veteran Member
Join Date: Jul 2007
Old 09-06-2007 , 09:31   Re: [EXTENSION] Weapons Extension
Reply With Quote #4

Quote:
Originally Posted by BAILOPAN View Post
Since you didn't include a gameconf file, you may wish to note that it's specific to a game.
Good point.

As it is it should work with:

Counter-Strike Source
Day of Defeat Source
Halflife 2: Deathmatch
and PVK

If anyone needs something else I can change this to read the function offsets from a gamecon file at runtime.

Last edited by dalto; 09-06-2007 at 23:39.
dalto is offline
dalto
Veteran Member
Join Date: Jul 2007
Old 09-06-2007 , 23:45   Re: [EXTENSION] Weapons Extension
Reply With Quote #5

I added a gameconf file as BAILOPAN suggested.

I also added support for the following games:
Insurgency
Sourceforts
dalto is offline
bobbobagan
SourceMod Donor
Join Date: May 2007
Location: New Zealand
Old 09-07-2007 , 19:49   Re: [EXTENSION] Weapons Extension
Reply With Quote #6

This extention caused major problems on my linux server, when somebody fired a gun it would crash the server making it unplayable. Just letting you know
__________________
bobbobagan is offline
Send a message via Skype™ to bobbobagan
dalto
Veteran Member
Join Date: Jul 2007
Old 09-07-2007 , 22:37   Re: [EXTENSION] Weapons Extension
Reply With Quote #7

Quote:
Originally Posted by bobbobagan View Post
This extention caused major problems on my linux server, when somebody fired a gun it would crash the server making it unplayable. Just letting you know
What mod was it and what script were you using that used it?

EDIT: Hmm...I was able to duplicate this. I will try to figure out why it does not work with linux.

Last edited by dalto; 09-07-2007 at 23:18.
dalto is offline
dalto
Veteran Member
Join Date: Jul 2007
Old 09-08-2007 , 17:51   Re: [EXTENSION] Weapons Extension
Reply With Quote #8

The linux binary should be fixed now.

Make sure you also cp weapons.games.txt to your gamedata directory
dalto is offline
steambob
Member
Join Date: Sep 2007
Old 09-20-2007 , 11:59   Re: [EXTENSION] Weapons Extension
Reply With Quote #9

well, sorry, but i do not find a link to download binaries (i would like to try the linux ones). could you add it ?

or am i blind?

thanks.
steambob is offline
SamuraiBarbi
Senior Member
Join Date: Aug 2006
Location: United States
Old 09-25-2007 , 02:30   Re: [EXTENSION] Weapons Extension
Reply With Quote #10

yeah where's the download at?
SamuraiBarbi is offline
Send a message via AIM to SamuraiBarbi Send a message via MSN to SamuraiBarbi Send a message via Yahoo to SamuraiBarbi
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 18:50.


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