AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [TF2] Weapon Steal (3.0) (https://forums.alliedmods.net/showthread.php?t=223076)

Arkarr 08-09-2013 14:42

[TF2] Weapon Steal (3.0)
 
3 Attachment(s)
Description :

Okay, this plugin can be totally funny (seeing a scout with a minigun isn't usual) and change gameplay.
It allows you to pickup weapons from killed ennemy.

Commands & Cvar :

No commands

No Cvar

Installation :

1) Put WeaponStealV2.smx (DON'T USE THE 'OLD.zip' ARCHIVE! Unless you want a old crappy version of this plugin) in your plugin folder : sourcemode/plugins
2) Restart server, reload map or reload plugins folder.
3) ???
4) Walk on a weapon and enjoy !
NOTE: You will need to install this plugin, otherwise, you won't be able to run mine.

If you want to compille it manually :

Require the library tf2items_giveweapon and kvizzle.

What I plan to do ?
- Sometimes, a wrong weapon is stealed (exemple : walk on a minigun, you will get 'Natasha')
- Let the user the choice of stealing a wep or not.
- Restrict to admins / donators ?
- Command and cvar

Request :

None for the moment... feel free to ask !


Logs :
3.0 : Fully rewrite all the plugin. Less code.

Old version of the plugin, I won't blame if you use it ;)
Spoiler

7106 08-11-2013 06:54

Re: [TF2] Weapon Steal (1.1)
 
i dont know y it doesn't workin'

Arkarr 08-11-2013 07:46

Re: [TF2] Weapon Steal (1.1)
 
Quote:

Originally Posted by 7106 (Post 2010599)
i dont know y it doesn't workin'

What doesn't work ?

FlaminSarge 08-14-2013 12:59

Re: [TF2] Weapon Steal (1.2)
 
This is pretty cool, though it looks like you're giving the weapons on kill/death rather than on pickup (of a dropped weapon).

If you know how, I'd say you should give that a try: when a player walks over the dropped "weapon" (ammo), they pick it up, instead of on death. Try SDKHooks' touch functions for that, as I don't think tf_ammo_pack's outputs or the item_pickup event will suffice. Good luck.

Why, again, aren't renamed (Upgradeable) and stranges working? The indices work fine in GiveWeapon (with the latest update, at least).

Arkarr 08-14-2013 15:10

Re: [TF2] Weapon Steal (1.2)
 
Well, I thinked about this option. I just needed some infos, and now I just got it !! Thanks a lot, I will probably update it in about 3 days... :)

Quote:

Why, again, aren't renamed (Upgradeable) and stranges working? The indices work fine in GiveWeapon (with the latest update, at least).
Actually I don't know, it does work for some weapons only (tested : Loch-n-load and The Liberty Launcher) but other weapons appears something like this "Upgradable TF_WEAPON_[WEAPON-NAME]" with a invalid weapon index. Any idea why ?

FlaminSarge 08-14-2013 18:14

Re: [TF2] Weapon Steal (1.2)
 
You're using "weaponindex" as a global variable, where you need to use it as a global array of variables (so each client has their own weapons).

Change it to "new weaponindex[MAXPLAYERS + 1]" to make it an array that has enough space to store a weaponindex for each client (I'd use "new weaponindex[MAXPLAYERS + 1] = { -1, ... };" so that it sets it to -1 for everyone automatically when the plugin is first loaded).
Then, any time you use weaponindex, instead use the weaponindex array element for the client involved ("weaponindex[client]"). Before you actually use it, however, you should check to make sure it's greater than or equal to 0, so that people who have not killed anybody (and will have -1 as their weaponindex[client]) won't get anything.

Understand? Make sure you understand what these changes mean, if you're going to learn how to program plugins/anything, instead of just following the instructions.

Also, you're using public Action:Steal_Menu(client, args). While it's not breaking the plugin, you've got it named and set up as if it were a command callback instead of just a generic function, and you pass in Steal_Menu(client, weaponindex) in the death hook. That means that you're setting the "args" parameter to the value of weaponindex (but you never end up using it). Since you're storing the weaponindex in the global array already, you don't need this, and you can name the function "stock Steal_Menu(client)" and call it with Steal_Menu(client).

Arkarr 08-15-2013 02:36

Re: [TF2] Weapon Steal (1.2)
 
It wasn't my first plugin but it appears to looks like :wink:. Okay thanks for precision. I already know this "client variable" but I thought it wasn't necessary. I will include this changes in the update. Thanks !

FlaminSarge 08-15-2013 14:05

Re: [TF2] Weapon Steal (2.0*)
 
After you call TF2Items_GiveWeapon and give the weapon, you can set weaponindex[client] back to -1 so that next time they pick up the ammo pack, it's not given.

Also, if you can figure out a way to get the entity of the item_pickup event, you can drop this system entirely and use m_nItemDef from the tf_ammo_pack entity to determine the weapon index. But that is ONLY if you can find the entity, which I'm not sure you can at the moment.

Arkarr 08-15-2013 14:23

Re: [TF2] Weapon Steal (2.0*)
 
Quote:

Originally Posted by FlaminSarge (Post 2013980)
After you call TF2Items_GiveWeapon and give the weapon, you can set weaponindex[client] back to -1 so that next time they pick up the ammo pack, it's not given.

Also, if you can figure out a way to get the entity of the item_pickup event, you can drop this system entirely and use m_nItemDef from the tf_ammo_pack entity to determine the weapon index. But that is ONLY if you can find the entity, which I'm not sure you can at the moment.

Okay, thanks. Can't do the changes now. But, sure ! I will do this.

FlaminSarge 08-17-2013 00:18

Re: [TF2] Weapon Steal (2.0*)
 
Also, if you want to *try*, you can look for an SDKHooks "Touch" hook right before the itempickup event. While it may take a bit of working to get it to detect properly, you can get the entity from the "touch" hook and then use the item_pickup to determine if they actually picked up the entity in question.


All times are GMT -4. The time now is 01:13.

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