Raised This Month: $ Target: $400
 0% 

Check For C4


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mrAbstract
Junior Member
Join Date: Feb 2008
Old 02-18-2008 , 11:36   Check For C4
Reply With Quote #1

Hello everyone, i'm new in sourcemod, pawn etc.
I am searching for solution that detect that player, which have C4 bomb.
I'm looking for, like this "m_bHasDefuser" (This for ct).
I dunno how to detect c4 on player.

I'll glad for any help, thanks.
mrAbstract is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-18-2008 , 12:01   Re: Check For C4
Reply With Quote #2

You will probably have to loop thought all the entities, find the bomb, and find it's owner.
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
mrAbstract
Junior Member
Join Date: Feb 2008
Old 02-18-2008 , 12:07   Re: Check For C4
Reply With Quote #3

Ehmm...maybe...any examples?
I found "m_hOwnerEntity" in CC4 class.
But how to check player entity == ownerent? =\
i have no ideas, how to check it.
mrAbstract is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-18-2008 , 12:11   Re: Check For C4
Reply With Quote #4

Here is how I find a sentry in TF2:

PHP Code:
TF_TRoffsets[TURRET_OWNED] = FindSendPropOffs("CObjectSentrygun""m_hBuilder"); 
PHP Code:
maxplayers GetMaxClients();
maxents GetMaxEntities(); 
PHP Code:
stock FindSentryByOwner(index){
    new 
iString:classname[64];
    
    
//Loop all entites
    
for(maxplayers<= maxentsi++){
         
//Is it valid?
         
if(IsValidEntity(i)){
            
GetEntityNetClass(iclassname64);
            
//Is the entity a sentry?
            
if(StrEqual(classname"CObjectSentrygun")){
                
//Is the builder the guy I am looking for?
                
if(GetEntDataEnt2(iTF_TRoffsets[TURRET_OWNED]) == index)
                    return 
i;
            }
        }
    }
    
//Nothing found.
    
return 0;

__________________
http://www.nican132.com
I require reputation!

Last edited by Nican; 02-18-2008 at 12:14.
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
mrAbstract
Junior Member
Join Date: Feb 2008
Old 02-18-2008 , 12:27   Re: Check For C4
Reply With Quote #5

Eehh...wait wwait....i already know the "entity id" of C4-Owner, i can't get player entity-id.
Maybe you can help with it too?

Last edited by mrAbstract; 02-18-2008 at 12:43.
mrAbstract is offline
KMFrog
Senior Member
Join Date: Oct 2007
Old 02-18-2008 , 13:24   Re: Check For C4
Reply With Quote #6

Another option is just to hook the events to do with the C4 and track where the bomb goes.... This is much more simple.

There is an event for picking up and dropping the C4.
__________________
Was I helpful or not? Rate Me!
KMFrog is offline
Greyscale
SourceMod Plugin Approver
Join Date: Dec 2007
Location: strYoMommasHouse[you];
Old 02-18-2008 , 18:45   Re: Check For C4
Reply With Quote #7

I think KMFrog's suggestion would be the easiest to do, any other method would probably require more work

EDIT: For a more solid way you can try using

Code:
/**
 * Returns the weapon in a player's slot.  
 *
 * @param client        Client index.
 * @param slot            Slot index (mod specific).
 * @return                Entity index on success, -1 if no weapon existed.
 * @error                Invalid client or client not in game, or lack of mod support.
 */
native GetPlayerWeaponSlot(client, slot);
Just find the c4 ent index and then check against all the player's bomb slot (which for CS:S I believe is 4? 0 = primary, 1 = secondary, 2 = knife, 3 = grenade)

EDIT2: Even better, just loop through all the players and check if there is any weapon in slot 4 (only thing that can possible be there is the bomb), it would return -1 for all players with no bomb

Last edited by Greyscale; 02-18-2008 at 18:50.
Greyscale is offline
mrAbstract
Junior Member
Join Date: Feb 2008
Old 02-19-2008 , 17:00   Re: Check For C4
Reply With Quote #8

Problem solved, thanks to Nican & Greyscale.
mrAbstract 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 18:41.


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