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

Solved How force health to 100


Post New Thread Reply   
 
Thread Tools Display Modes
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 10-05-2018 , 12:31   Re: How force health to 100
Reply With Quote #11

Quote:
Originally Posted by 8guawong View Post
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if (
IsClientInGame(client) && IsPlayerAlive(client))
    {
        if (
GetClientTeam(client) == 2)
            
SetEntityHealth(client100);
        else
            
SetEntityHealth(client999);
    }

Not working also, maybe fix it with a timer, because i think the health point of map have the priority on spawn, and if we create a timer, when terrorist spawn for example, he spawn with 9999 hp but 2 seconds after (with timer) change health point to 100 hp. but i dont know how to put timer in script if you can help me
vegeta1241 is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 10-05-2018 , 12:42   Re: How force health to 100
Reply With Quote #12

Try this one:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>

#pragma semicolon 1
#pragma newdecls required

public void OnPluginStart()
{
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
void Event_PlayerSpawn(Event event, const char[] namebool dontBroadcast)
{
    
RequestFrame(Frame_Callbackevent.GetInt("userid"));
}

public 
void Frame_Callback(int userid)
{
    
int client GetClientOfUserId(userid);
    if (
client && IsClientInGame(client) && IsPlayerAlive(client))
    {
        if (
GetClientTeam(client) == 2)
        {
            
CreateTimer(2.0Timer_CallbackGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
        } else {
            
SetEntityHealth(client999);
        }
    }
}

public 
Action Timer_Callback(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if (
client && IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 2)
    {
        
SetEntityHealth(client100);
    }

Also, be sure to check for errors in logs and post them here if you have any.

Last edited by ThatKidWhoGames; 10-05-2018 at 12:44.
ThatKidWhoGames is offline
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 10-05-2018 , 12:50   Re: How force health to 100
Reply With Quote #13

WORKING ! THANKS, no error !
vegeta1241 is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 10-05-2018 , 12:53   Re: How force health to 100
Reply With Quote #14

Quote:
Originally Posted by vegeta1241 View Post
WORKING ! THANKS, no error !
Glad we found a solution! Have fun! Go ahead and mark this thread as solved so others know that you no longer need assistance.

Last edited by ThatKidWhoGames; 10-05-2018 at 12:54.
ThatKidWhoGames is offline
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 10-05-2018 , 13:01   Re: How force health to 100
Reply With Quote #15

yes thanks !
vegeta1241 is offline
vegeta1241
AlliedModders Donor
Join Date: Apr 2017
Location: Switzerland
Old 10-05-2018 , 13:02   [SOLVED] How force health to 100
Reply With Quote #16

solved
vegeta1241 is offline
mug1wara
AlliedModders Donor
Join Date: Jun 2018
Old 10-05-2018 , 13:41   Re: How force health to 100
Reply With Quote #17

Just use EventHookMode_Post, also I don't see why sdkhooks is necessary here.
mug1wara is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 10-06-2018 , 00:21   Re: How force health to 100
Reply With Quote #18

Quote:
Originally Posted by mug1wara View Post
Just use EventHookMode_Post, also I don't see why sdkhooks is necessary here.
Post is set by default when hooking events. You also need to realize that just because the event has been called, that doesn't mean the player has fully spawned yet.
ThatKidWhoGames 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 07:42.


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