Raised This Month: $ Target: $400
 0% 

Block pickup for everything except C4


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-08-2009 , 10:26   Block pickup for everything except C4
Reply With Quote #1

To not create a new thread, I've changed the title and the first post.
So, how can I block any entity from picking up except C4?

It just can't catch 'models/w_c4.mdl' while catches any other model perfectly.
Code:
#include <fakemeta>   public plugin_init()         register_forward(FM_Touch, "fwTouch");   public fwTouch(iEnt, iCl) {         if (!pev_valid(iEnt) || !is_user_alive(iCl))                 return FMRES_IGNORED;           static szClass[32], szMdl[32];         pev(iEnt, pev_classname, szClass, sizeof(szMdl) - 1);         pev(iEnt, pev_model, szMdl, sizeof(szMdl) - 1);           if (equali(szClass, "weaponbox") || equali(szClass, "armoury_entity")         || equali(szClass, "weapon_shield") || equali(szClass, "grenade")))                 if (!equali(szMdl, "models/w_c4.mdl"))                         return FMRES_SUPERCEDE;           return FMRES_IGNORED; }
__________________

Last edited by hleV; 01-08-2009 at 12:53. Reason: Block pickup for everything except C4
hleV is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-08-2009 , 11:17   Re: Is it better to register new event instead?
Reply With Quote #2

Quote:
Originally Posted by hleV
you can use it if you press weapon's slot button many times.
maybe it will called many times, but not each frame on client like prethink doing
__________________
xPaw is offline
Old 01-08-2009, 11:52
ConnorMcLeod
This message has been deleted by ConnorMcLeod.
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 01-08-2009 , 12:31   Re: Is it better to register new event instead?
Reply With Quote #3

Quote:
Originally Posted by ConnorMcLeod View Post
/**
* Description: Deploys the entity (usually a weapon).
* Forward params: function(this);
* Return type: Integer (boolean).
* Execute params: ExecuteHam(Ham_Item_Deploy, this);
*/
Ham_Item_Deploy,

You have to register it for each weapon, but it will still be more efficient than prethink.
I think CurWeapon is just fine for this... bug is when you use client_cmd and not engclient_cmd (bug engclient_cmd(id, "weapon_XXX") mess up custom models)
Do you guys have any idea how often CurWeapon is called? I read somewhere (don't ask me where, don't remember) it's called on every shot, on every weapon switch, etc.
__________________

Community / No support through PM
danielkza is offline
Old 01-08-2009, 12:33
ConnorMcLeod
This message has been deleted by ConnorMcLeod.
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-08-2009 , 12:36   Re: Is it better to register new event instead?
Reply With Quote #4

Quote:
Originally Posted by xPaw View Post
maybe it will called many times, but not each frame on client like prethink doing
Called many times? I'm not talking about CALLING. I'm saying that you can use your WEAPON if you press that weapon's slot many times...

EDIT: Looks like I made it to work propertly. Code I'm using right now:
Code:
public eCurWeapon(iCl) {         if (!is_user_alive(iCl))                 return;           static iWeapon;         iWeapon = read_data(2);           if (iWeapon != CSW_KNIFE && iWeapon != CSW_C4)                 engclient_cmd(iCl, "weapon_knife");           fm_set_user_maxspeed(iCl, get_pcvar_float(g_pKnifePowerSpeed)); }
__________________

Last edited by hleV; 01-08-2009 at 13:00.
hleV is offline
Old 01-08-2009, 12:39
ConnorMcLeod
This message has been deleted by ConnorMcLeod.
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-08-2009 , 12:52   Re: Block pickup for everything except C4
Reply With Quote #5

Changed title and question of the thread. Please take attention. ^^
__________________
hleV is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-08-2009 , 13:13   Re: Block pickup for everything except C4
Reply With Quote #6

Quote:
Originally Posted by hleV View Post
Changed title and question of the thread. Please take attention. ^^
What an idiot, all answers are non-sense now...
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-08-2009 , 13:23   Re: Block pickup for everything except C4
Reply With Quote #7

Well, I'm not an idiot for sure. And I believe that I'm the only one who had that problem with CurWeapon (which was easily solved). I don't think anyone could have used this thread, so I changed it instead of creating a new one.

If you wont answer to question, don't post non-sense.
__________________
hleV is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-08-2009 , 13:48   Re: Block pickup for everything except C4
Reply With Quote #8

ok i'm were working on situation like yours, but i deleted that code
ok you need hook touch forwards, and check what he touched, if weaponbox, and get his classname, if its equal to csw_c4 (dont remmeber really how i did) then continue, if something other do supercede
__________________
xPaw is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-08-2009 , 13:51   Re: Block pickup for everything except C4
Reply With Quote #9

LOL, does C4 have an individual class name?
__________________
hleV is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-08-2009 , 14:14   Re: Block pickup for everything except C4
Reply With Quote #10

grenade or otherway there is way to get CSW_c4
__________________
xPaw 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 09:13.


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