Raised This Month: $ Target: $400
 0% 

Solved Spawn with 25 HP


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 04-17-2023 , 20:08   Re: Spawn with 25 HP
Reply With Quote #10

Quote:
Originally Posted by Celena Luna View Post
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

new cvar_hp
new g_hambots// This variable will check if the hams have been recorded

public plugin_init()
{
    
register_plugin("Low HP""alliedmods""0.1")

    
RegisterHam(Ham_Spawn"player""fwPlayerSpawn"1)

    
cvar_hp register_cvar("spawn_hp_amount""25")

    
register_clcmd("say /bothp""CMD_BotHP")
}

public 
CMD_BotHP(id)
{
    new 
iPlayers[32], iPnumiPlayersName[64];
    
get_players(iPlayersiPnum"ah")

    for(new 
0iPnumi++)
    {
        
get_user_name(iPlayers[i], sNamecharsmax(sName))
        
client_print(idprint_console"%s: %i"sNameget_user_health(iPlayers[i]))
    }
}

// Spawn event hook for bots: https://forums.alliedmods.net/showthread.php?t=294861
public client_putinserver(id)
{
   if(!
g_hambots && is_user_bot(id))
    {
        
g_hambots 1
        set_task
(0.1"Do_RegisterHam"id)
    }
}

public 
Do_RegisterHam(id)
{
    
// Ham Forwards
    
RegisterHamFromEntity(Ham_Spawnid"fwPlayerSpawn"1); // In this case, Ham_TakeDamage
    
client_print(0print_console"Registered Bot: %i"id)
}

public 
fwPlayerSpawn(id)
{
    if(
is_user_alive(id))
    {
        
set_user_health(idget_pcvar_num(cvar_hp))
    }

I am not sure why this work but as long as it work then it should be fine I guess....

I remove IsValid, add cmd to check and change client_putinserver a bit
Also, when testing, I notce that if other type of bot was used (ex:SyPB, PODBot,..) and they spawn first, they will "eat" the RegisterHamFromEntity and ZBot willl not get the RegisterHamFromEntity
Thanks, it does somehow work if with the CZ bots, so thanks Celena
__________________
Extended Arm Weapon Skin v2.1 {16/Apr/23}
(Detect which class is and associate it with the corresponding arms)
SideWeapons v0.2 {01/Sep/22}
(New version of Back Weapons v1.87)

SoulWeaver16 is offline
 



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:46.


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