AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Client 1 is not in game (https://forums.alliedmods.net/showthread.php?t=331800)

thaiguitar 04-08-2021 05:53

Client 1 is not in game
 
2 Attachment(s)
Hello I want you guys to help
now i use one mod but for a long time in 2008

https://forums.alliedmods.net/showthread.php?p=500636

PHP Code:

#pragma semicolon 1

/*
 *    HP Regeneration
 *    by MaTTe (mateo10)
 */

#define VERSION "1.0"

public Plugin:myinfo =
{
    
name "HP Regeneration",
    
author "MaTTe",
    
description "As the title says, this plugin regenerates your hp to maximum",
    
version VERSION,
    
url "http://www.sourcemod.net/"
};

new 
Handle:g_hRegenTimer[MAXPLAYERS 1];

new 
Handle:g_Interval;
new 
Handle:g_MaxHP;
new 
Handle:g_Inc;

public 
OnPluginStart()
{
    
CreateConVar("hpregeneration_version"VERSION"HP Regeneration Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);

    
g_Interval CreateConVar("hpregen_interval""1.0");
    
g_MaxHP CreateConVar("hpregen_maxhp""100");
    
g_Inc CreateConVar("hpregen_inc""10");

    
HookEvent("player_hurt"HookPlayerHurt);
}

public 
HookPlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
iUserId GetEventInt(event"userid");
    new 
client GetClientOfUserId(iUserId);

    if(
g_hRegenTimer[client] == INVALID_HANDLE)
    {
        
g_hRegenTimer[client] = CreateTimer(GetConVarFloat(g_Interval), RegenerateclientTIMER_REPEAT);
    }
}

public 
Action:Regenerate(Handle:timerany:client)
{
    new 
ClientHealth GetClientHealth(client);

    if(
ClientHealth GetConVarInt(g_MaxHP))
    {
        
SetClientHealth(clientClientHealth GetConVarInt(g_Inc));
    }
    else
    {
        
SetClientHealth(clientGetConVarInt(g_MaxHP));
        
g_hRegenTimer[client] = INVALID_HANDLE;
        
KillTimer(timer);
    }
}

SetClientHealth(clientamount)
{
    new 
HealthOffs FindDataMapOffs(client"m_iHealth");
    
SetEntData(clientHealthOffsamounttrue);


The problems i encountered are
in the beginning the mod works normally
but when someone leaves the server the mod will inform that the player has left and cannot find that player

https://i.ibb.co/9ZWJ7g1/error.png

What should i do to fix it?
Thank you very much.

andi67 04-08-2021 06:42

Re: Client 1 is not in game
 
Just add a check if Player is in game....

thaiguitar 04-08-2021 08:03

Re: Client 1 is not in game
 
After defining player
look like i can do it
thank you very much.


All times are GMT -4. The time now is 13:39.

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