AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block pickup for everything except C4 (https://forums.alliedmods.net/showthread.php?t=83358)

hleV 01-08-2009 10:26

Block pickup for everything except C4
 
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; }

xPaw 01-08-2009 11:17

Re: Is it better to register new event instead?
 
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

danielkza 01-08-2009 12:31

Re: Is it better to register new event instead?
 
Quote:

Originally Posted by ConnorMcLeod (Post 740421)
/**
* 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.

hleV 01-08-2009 12:36

Re: Is it better to register new event instead?
 
Quote:

Originally Posted by xPaw (Post 740412)
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)); }

hleV 01-08-2009 12:52

Re: Block pickup for everything except C4
 
Changed title and question of the thread. Please take attention. ^^

ConnorMcLeod 01-08-2009 13:13

Re: Block pickup for everything except C4
 
Quote:

Originally Posted by hleV (Post 740472)
Changed title and question of the thread. Please take attention. ^^

What an idiot, all answers are non-sense now...

hleV 01-08-2009 13:23

Re: Block pickup for everything except C4
 
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.

xPaw 01-08-2009 13:48

Re: Block pickup for everything except C4
 
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

hleV 01-08-2009 13:51

Re: Block pickup for everything except C4
 
LOL, does C4 have an individual class name?

xPaw 01-08-2009 14:14

Re: Block pickup for everything except C4
 
grenade or otherway there is way to get CSW_c4


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

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