Raised This Month: $51 Target: $400
 12% 

SDK Hooks 2.1 - Updated 2011-9-10


Post New Thread Closed Thread   
 
Thread Tools Display Modes
xbatista
Veteran Member
Join Date: Mar 2008
Location: Lithuania
Old 06-02-2011 , 16:03   Re: SDK Hooks 2.0
#1441

I think I found that bug, since all the day there were no weapon disappearing.

WeaponEquip, WeaponCanUse and if you're hooking other callbacks on entities you must always check:
PHP Code:
IsValidEntity(weapon/entity) && IsValidEdict(weapon/entity
Example how I noticed is using only one plugin that uses sdkhooks and where I didn't check for is edict valid:
PHP Code:
// Example hooking when entity created
SDKHook(pHatEnt[client], SDKHook_SetTransmitOnSetTransmitCallback);

//callback thats only my code example
public Action:OnSetTransmitCallback(entityclient
{
    if ( !
IsValidEntity(entity) || !IsValidClient(client) ) return Plugin_Continue;
    
    new 
iSpecModeUser GetEntProp(clientProp_Send"m_iObserverMode");
    new 
iTargetUser GetEntPropEnt(clientProp_Send"m_hObserverTarget");

    if ( 
pHatEnt[client] > )
    {
        if (
pHatEnt[client] == entity )
            return 
Plugin_Handled
    }
    
    if ( 
IsValidAlive(iTargetUser) && pHatEnt[iTargetUser] > && iSpecModeUser == )
    {
        if (
pHatEnt[iTargetUser] == entity )
            return 
Plugin_Handled;
    }
        
    return 
Plugin_Continue;
    

Without using IsValidEntity and IsValidEdict, will cause your active weapon for disappearing. This is on CS:S.
__________________

Last edited by xbatista; 06-02-2011 at 16:11.
xbatista is offline
Send a message via Skype™ to xbatista
TnTSCS
AlliedModders Donor
Join Date: Oct 2010
Location: Undisclosed...
Old 06-04-2011 , 12:14   Re: SDK Hooks 2.0
#1442

is there an easy way for SDKHooks to determine if the damage being given is from C4? DMG_BLAST works, but it also is for grenade...

Maybe I could add an if(DMG_BLAST && !weapon_hegrenade) or something... I know I would need to get the edict name, just simplifying
TnTSCS is offline
psychonic

BAFFLED
Join Date: May 2008
Old 06-04-2011 , 12:17   Re: SDK Hooks 2.0
#1443

Quote:
Originally Posted by TnTSCS View Post
is there an easy way for SDKHooks to determine if the damage being given is from C4? DMG_BLAST works, but it also is for grenade...

Maybe I could add an if(DMG_BLAST && !weapon_hegrenade) or something... I know I would need to get the edict name, just simplifying
Check that inflictor is a valid edict, get it's classname, compare to whatever c4 classname is.
psychonic is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 06-05-2011 , 02:22   Re: SDK Hooks 2.0
#1444

Is there a way to use this to block rounds ending in css? Didn't see anything like so, compared to DukeHacks.

Thanks
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 06-05-2011 , 13:59   Re: SDK Hooks 2.0
#1445

Any idea on how to hook players switching team ?

I want to get clientId of someone going spectator.

Also what is "Think" ? (Pre/(void)/Post)think ? You hook everything someone can do ?
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
psychonic

BAFFLED
Join Date: May 2008
Old 06-05-2011 , 14:10   Re: SDK Hooks 2.0
#1446

Quote:
Originally Posted by RedSword View Post
Any idea on how to hook players switching team ?
Hooking team change is easier said than done.

The ChangeTeam function can easily be hooked, but some games have functions that bypass it, making it less useful as not all changes go through it. An example of this is CS:S's CCSPlayer::SwitchTeam function (same function called by the CS_SwitchTeam native).

Hooking the player_team event is probably just as useful and wouldn't require any extension changes.

Quote:
Originally Posted by RedSword View Post
Also what is "Think" ? (Pre/(void)/Post)think ? You hook everything someone can do ?
Think can be thought of as the equivalent to OnGameFrame, where an entity does most of it's continuous logic. Pre- and Post- think are also provided on players, where similar occurs, but allowing things to happen either before or after. SDKHooks provides pre and post hook options for all three so that timing can be perfect for functionality that is dependent on timing, though PreThinkPost and Think(Pre), as well as ThinkPost and PostThink(Pre) are probably redundant and are only provided for api consistency.
psychonic is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 06-05-2011 , 17:49   Re: SDK Hooks 2.0
#1447

Thanks for your clear answer psychonic.

Also does that mean that on the first page, with the OnPreThink example :

"public OnPreThink(client)"

"client" could be any entity ? (not just a client)
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
psychonic

BAFFLED
Join Date: May 2008
Old 06-05-2011 , 18:49   Re: SDK Hooks 2.0
#1448

Quote:
Originally Posted by RedSword View Post
Thanks for your clear answer psychonic.

Also does that mean that on the first page, with the OnPreThink example :

"public OnPreThink(client)"

"client" could be any entity ? (not just a client)
PreThink and PostThink don't exist on all entity types (but do on client). Think should exist on all.

It can be an ent of whatever type that you hook and give that callback for.
psychonic is offline
Chanz
Veteran Member
Join Date: Aug 2008
Location: Germany - Stuttgart
Old 06-06-2011 , 17:57   Re: SDK Hooks 2.0
#1449

The following code snipped won't work in CSS, it won't block the jump:
Code:
public OnClientPutInServer(client) {     
  SDKHook(client, SDKHook_PreThink, OnPreThink); 
}  
public OnPreThink(client) {     
  new iButtons = GetClientButtons(client);    
  if(iButtons & IN_JUMP){         
    iButtons &= ~IN_JUMP;         
    SetEntProp(client, Prop_Data, "m_nButtons", iButtons);    
  } 
}
but with IN_ATTACK it works.
__________________
[ SourceModPlugins.org ][ My Plugins ]

Thank you for donations: [ Paypal ]

Video Tutorial (German): [ Gameserver & SourceMod Plugins mit HLSW verwalten ]

Last edited by Chanz; 06-07-2011 at 11:53.
Chanz is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-06-2011 , 20:54   Re: SDK Hooks 2.0
#1450

In L4D2 when using SDKHook_WeaponCanSwitchTo or SDKHook_WeaponCanSwitchToPost it fires when picking up items. But players still have their original weapon and never switch to it, so I think the hook should fire again for their current weapon, or not fire at all unless they switch to that slot.

Am I not understanding the hooks function correctly or is that an actual bug? Can anything be done about this?
__________________
Silvers is offline
Closed Thread



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 03:22.


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