Raised This Month: $404 Target: $400
 101% 

Some manipulations with friendly fire..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
impossible_cc
Junior Member
Join Date: Sep 2018
Location: Ukraine
Old 10-09-2018 , 09:28   Some manipulations with friendly fire..
Reply With Quote #1

I have this code, but it doesn't work... I have no idea why. Is something wrong with me?



PHP Code:
public void OnClientPutInServer(int client

    
SDKHook(clientSDKHook_OnTakeDamageHook_OnTakeDamage);
}
public 
Action Hook_OnTakeDamage(int victimintattackerintinflictorfloatdamageintdamagetype
{
    if(
ValidPlayer(victim) && ValidPlayer(attacker))
    {
        if(
GetClientTeam(attacker) == GetClientTeam(victim))
        {
            
int heal 20;
            
int oldhp GetClientHealth(victim);
            
            if(
oldhp heal 100)
            {
                
SetEntityHealth(victim,100);
            }
            else
            {
                
SetEntityHealth(victimheal oldhp);
            }
            
            
PrintToChat(attacker"You healed your teammate!");
            
PrintToChat(victim"Your teammate healed you!");
        }
    }
    return 
Plugin_Continue;


Last edited by impossible_cc; 10-09-2018 at 13:41.
impossible_cc is offline
ThatKidWhoGames
Senior Member
Join Date: Jun 2013
Location: IsValidClient()
Old 10-09-2018 , 09:49   Re: Some manipulations with friendly fire..
Reply With Quote #2

Post your ValidPlayer() function.

EDIT: Change the ValidPlayer to IsClientInGame.
__________________


I take custom plugin requests, add me on Steam for details.

Last edited by ThatKidWhoGames; 10-09-2018 at 09:52.
ThatKidWhoGames is offline
Cruze
Senior Member
Join Date: May 2017
Old 10-09-2018 , 12:14   Re: Some manipulations with friendly fire..
Reply With Quote #3

Quote:
Originally Posted by impossible_cc View Post
PHP Code:
else
{
    
SetEntityHealth(victimheal oldhp);

__________________
Github | Steam
Looking to work for some CSGO community!
Cruze is offline
shanapu
Veteran Member
Join Date: Apr 2015
Location: .de
Old 10-09-2018 , 13:26   Re: Some manipulations with friendly fire..
Reply With Quote #4

Code:
SetEntityHealth(heal + oldhp);
should throw an error on compile...
...so you couldn't have tested it to see if it worked!?
__________________
free software
coding
shanapu is offline
impossible_cc
Junior Member
Join Date: Sep 2018
Location: Ukraine
Old 10-09-2018 , 13:45   Re: Some manipulations with friendly fire..
Reply With Quote #5

Quote:
Originally Posted by shanapu View Post
Code:
SetEntityHealth(heal + oldhp);
should throw an error on compile...
...so you couldn't have tested it to see if it worked!?
I didn't get an error on compile. I'm just using another functions void HealToMaxHP(int client, int heal).
Function is very simple. Just checks maxHp, then compares it with current hp, and if current hp + heal more then maxHp, set to maxHp. Else SetEntityHealth(client, maxHp)
It's correct in the code, I'm sure. Made a mistake when rewriting.
impossible_cc is offline
impossible_cc
Junior Member
Join Date: Sep 2018
Location: Ukraine
Old 10-09-2018 , 13:49   Re: Some manipulations with friendly fire..
Reply With Quote #6

Okay. Here is full code. I'm sure that War3 function is correct, I'm also sure about ValidPlayer(client).

PrintToChat(attacker, "You healed...");
this message displays correctly, but the next one doesn't...

I tried to do heal manually, without war3 funct, doesnt work anyways
I tried to use timer with short delayy, but it sucks anyways. I guess something is wrong with victim index, but I don't understand WHY/

PHP Code:
public Action Hook_OnTakeDamage(int victimintattackerintinflictorfloatdamageintdamagetype
{
    if(
ValidPlayer(victim) && ValidPlayer(attacker))
    {
        if(
GetClientTeam(attacker) == GetClientTeam(victim))
        {
            if(
War3_GetRace(attacker)==thisRaceID)
            {
                if(
FORM_CURRENT[attacker] == FORM_TREE)
                {
                    
int skill_level_tree War3_GetSkillLevel(victim,thisRaceID,SKILL_TREE);
                    
int heal FORMTREE_HEAL_TEAMMATE_ATTACK[skill_level_tree];
                    
                    
                    
War3_HealToMaxHP(victimheal);
                    
                    
EmitSoundToAll(SOUND_ATTACK_HEAL_TREEvictim);
                    
PrintToChat(attacker"You healed...");
                    
PrintToChat(victim"you've been healed...");
                }
            }
        }
    }
    return 
Plugin_Continue;


Last edited by impossible_cc; 10-09-2018 at 14:08. Reason: add info
impossible_cc is offline
Reply


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


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