Raised This Month: $ Target: $400
 0% 

Solved Colors and Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IcannotScript
Junior Member
Join Date: Nov 2016
Old 11-21-2017 , 21:43   Colors and Damage
Reply With Quote #1

hey,

I need some help with a script im creating,
parts of my plugin let admins color players and once those players are colored I dont want them to be able to damage eachother.
currently the segment of the code looks something like
Code:
public void OnPluginStart()
{
        HookEvent("player_hurt", PlayerDamaged);
}

public PlayerDamaged(Event event, const char[] name, bool dontBroadcast)
{
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	new victim = GetClientOfUserId(GetEventInt(event, "victim"));
	
	if(GetEntSendPropOffs(attacker, "m_clrRender") == GetEntSendPropOffs(victim,"m_clrRender"))
        {
		//set damage to 0?	 	
	}		
}
I want the victim to take no damage from the attacker if they are the same color, though I believe the code above will not work as intended, any suggestions?

Last edited by IcannotScript; 11-22-2017 at 05:23.
IcannotScript is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 11-21-2017 , 23:33   Re: [HELP] Colors and Damage
Reply With Quote #2

You should use SDKHooks to hook OnTakeDamage instead. Also the way you're getting the render colour is wrong. Thankfully, theres some nice stock functions to Get and Set render colour of entities.

e.g.
PHP Code:
public void OnClientPostAdminCheckint client )
{
    
SDKHookclientSDKHook_OnTakeDamageHook_OnTakeDamageCallback );
}

public 
Action Hook_OnTakeDamageCallbackint victimintattackerintinflictorfloatdamageintdamagetype )
{
    
int r1g1b1a1;
    
GetEntityRenderColorvictimr1g1b1a1 );
    
int r2g2b2a2;
    
GetEntityRenderColorattackerr2g2b2a2 );
    
    if( 
r1 == r2 &&
        
g1 == g2 &&
        
b1 == b2 &&
        
a1 == a2 )
    {
        return 
Plugin_Handled;
    }
    
    return 
Plugin_Continue;


Last edited by hmmmmm; 11-21-2017 at 23:35.
hmmmmm is offline
IcannotScript
Junior Member
Join Date: Nov 2016
Old 11-22-2017 , 05:19   Re: [HELP] Colors and Damage
Reply With Quote #3

cheers didn't think the render color thing would work, that works nicely
thanks again
IcannotScript 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 01:11.


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