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

[FAQ/Tutorial] CS Bomb Scripting


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 12-26-2014 , 13:53   Re: [FAQ/Tutorial] CS Bomb Scripting
Reply With Quote #34

Another way for checking if a player has c4 is:
PHP Code:
new const m_rgpPlayerItems_CBasePlayer[6] = {367 368 , ...}
const 
XO_PLAYER 5

if(get_pdata_cbase(idm_rgpPlayerItems_CBasePlayer[5], XO_PLAYER) !=-1
To get the C4 entity index(weapon_c4) it's not needed to keep searching for the bomb with find_ent_by_class, you can hook Ham_Item_AddToPlayer with weapon_c4 as classname. The only checks are to see if the item is valid and if the player is alive. Here you can save it into a global variable and use it later.

To get the planted C4 entity index(grenade) a direct way would be to hook CGrenade::ShootSatchelCharge with okapi(orpheu can't hook it because it doesn't support vector class).

PHP Code:
new const ShootSatchelChargeSignature[] = {0x830xDEF0xDEF0x530x560x570xFF0xDEF0xDEF0xDEF0xDEF0xDEF0x33}
    new const 
ShootSatchelChargeSymbol[] = "_ZN8CGrenade18ShootSatchelChargeEP9entvars_s6VectorS2_"

    
new ShootSatchelChargeFunc 
    
    
if
    ( 
    (
ShootSatchelChargeFunc okapi_mod_get_symbol_ptr(ShootSatchelChargeSymbol)) || 
    (
ShootSatchelChargeFunc okapi_mod_find_sig(ShootSatchelChargeSignaturesizeof ShootSatchelChargeSignature)) 
    ) 
    { 
        
okapi_add_hook(okapi_build_function(ShootSatchelChargeFuncarg_cbasearg_entvarsarg_vecarg_vec), "OnShootSatchelCharge", .post 1


public 
OnShootSatchelCharge(OwnerEntFloat:Origin[], Float:Angles[])
{
    new 
C4EntityIndex okapi_get_orig_return()

In order to give c4 to a player the best way is:

PHP Code:
give_item(id"weapon_c4")
cs_set_user_plant(id11
To remove the c4 weaponbox hook Ham_Touch with "weaponbox" as classname, check if it's a c4 weaponbox and call think on it.

If you want to detect when a user stop planting, you need to register BarTime event but also Ham_Item_Holster to prevent it being innacurate due to weapon switch.
__________________

Last edited by HamletEagle; 12-26-2014 at 14:06.
HamletEagle is offline
 


Thread Tools
Display Modes

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 19:01.


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