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

Code Fix


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 06-04-2016 , 13:54   Code Fix
Reply With Quote #1

PHP Code:
SetEntData(clientFindDataMapOffs(client"m_iMaxHealth"), 2004true);
SetEntData(clientFindDataMapOffs(client"m_iHealth"), 2004true); 
Why doesn't it change player max health? it gives 200 hp but not setting the max health to 200.
__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 06-04-2016 , 14:04   Re: Code Fix
Reply With Quote #2

Isn't using SentEntProp safer? Or at least it works for me.

Try:
PHP Code:
SetEntProp(clientProp_Data"m_iMaxHealth"200);
SetEntProp(clientProp_Send"m_iHealth"200); 
Maxximou5 is offline
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 06-04-2016 , 14:08   Re: Code Fix
Reply With Quote #3

Quote:
Originally Posted by Maxximou5 View Post
Isn't using SentEntProp safer? Or at least it works for me.

Try:
PHP Code:
SetEntProp(clientProp_Data"m_iMaxHealth"200);
SetEntProp(clientProp_Send"m_iHealth"200); 
Still, Max health aren't setting to 200.
__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker is offline
BraveFox
AlliedModders Donor
Join Date: May 2015
Location: Israel
Old 06-05-2016 , 02:20   Re: Code Fix
Reply With Quote #4

Try to use:
SetEntData(client, FindDataMapOffs(client, "m_iMaxHealth"), 200, 4, true);
SetEntData(client, FindDataMapOffs(client, "m_iHealth"), 200, 4, true);
__________________
Contact Me:
Steam: NoyB
Discord: Noy#9999
Taking Private Requests
BraveFox is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-05-2016 , 03:27   Re: Code Fix
Reply With Quote #5

Quote:
Originally Posted by BraveFox View Post
Try to use:
SetEntData(client, FindDataMapOffs(client, "m_iMaxHealth"), 200, 4, true);
SetEntData(client, FindDataMapOffs(client, "m_iHealth"), 200, 4, true);
that's what he did though..
__________________
retired
shavit is offline
shavit
AlliedModders Donor
Join Date: Dec 2011
Location: Israel
Old 06-05-2016 , 03:29   Re: Code Fix
Reply With Quote #6

@TheUnderTaker: if you're trying to set hp and maxhp on spawn, try doing it within a timer of 0.0 so it fires one tick later

edit:
nvm you're on tf2

use SDKHook_GetMaxHealth

Code:
#include <sourcemod>
#include <sdkhooks>

public void OnPluginStart()
{
    HookEvent("player_spawn", Player_Spawn);
}

public void Player_Spawn(Event e, const char[] n, bool dB)
{
    int userid = e.GetInt("userid");
    int client = GetClientOfUserId(userid);

    SetEntityHealth(client, 200);
}

public void OnClientPutInServer(int client)
{
    SDKHook(client, SDKHook_GetMaxHealth, OnGetMaxHealth);
}

public Action OnGetMaxHealth(int entity, int &maxhealth)
{
    maxhealth = 200;

    return Plugin_Changed;
}
__________________
retired

Last edited by shavit; 06-05-2016 at 03:36.
shavit is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 06-05-2016 , 04:45   Re: Code Fix
Reply With Quote #7

Quote:
Originally Posted by shavit View Post
if you're trying to set hp and maxhp on spawn, try doing it within a timer of 0.0 so it fires one tick later
If you use a timer for this, RequestFrame is way better.
__________________
Benoist3012 is offline
TheUnderTaker
Senior Member
Join Date: Dec 2013
Location: Israel
Old 06-05-2016 , 07:10   Re: Code Fix
Reply With Quote #8

Quote:
Originally Posted by shavit View Post
@TheUnderTaker: if you're trying to set hp and maxhp on spawn, try doing it within a timer of 0.0 so it fires one tick later

edit:
nvm you're on tf2

use SDKHook_GetMaxHealth

Code:
#include <sourcemod>
#include <sdkhooks>

public void OnPluginStart()
{
    HookEvent("player_spawn", Player_Spawn);
}

public void Player_Spawn(Event e, const char[] n, bool dB)
{
    int userid = e.GetInt("userid");
    int client = GetClientOfUserId(userid);

    SetEntityHealth(client, 200);
}

public void OnClientPutInServer(int client)
{
    SDKHook(client, SDKHook_GetMaxHealth, OnGetMaxHealth);
}

public Action OnGetMaxHealth(int entity, int &maxhealth)
{
    maxhealth = 200;

    return Plugin_Changed;
}
I will try.

Quote:
Originally Posted by Benoist3012 View Post
If you use a timer for this, RequestFrame is way better.
I will try.
__________________
SourcePawn, C# and C++ Programmer.

My plugin list
TheUnderTaker 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 05:44.


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