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

Solved Spawn with 25 HP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 04-10-2023 , 13:21   Spawn with 25 HP
Reply With Quote #1

Hello, Is there a plugin that at the beginning of the round you have 25 HP? or with cvar to spawn with custom HP
I was thinking of trying a plugin that 1 Shot = 1 Kill but they usually have a lot of problems, I think it's better to directly modify the HP
(I plan to use it for a kind of "Realistic Mode", in which a shot from a Glock is something serious.)

Edit (thanks lexzor and Celene): LowHP.sma
__________________
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)


Last edited by SoulWeaver16; 04-17-2023 at 20:12.
SoulWeaver16 is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-10-2023 , 13:46   Re: Spawn with 25 HP
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

#define IsValid(%0) (0 < %0 < 33)

new g_cvar

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

    
RegisterHam(Ham_Spawn"player""fwPlayerSpawn"1)

    
g_cvar register_cvar("spawn_hp_amount""25")
}

public 
fwPlayerSpawn(id)
{
    if(
is_user_alive(id) && IsValid(id))
    {
        
set_user_health(idget_pcvar_num(g_cvar))
    }


Last edited by lexzor; 04-10-2023 at 13:47.
lexzor is offline
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 04-10-2023 , 18:20   Re: Spawn with 25 HP
Reply With Quote #3

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

#define IsValid(%0) (0 < %0 < 33)

new g_cvar

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

    
RegisterHam(Ham_Spawn"player""fwPlayerSpawn"1)

    
g_cvar register_cvar("spawn_hp_amount""25")
}

public 
fwPlayerSpawn(id)
{
    if(
is_user_alive(id) && IsValid(id))
    {
        
set_user_health(idget_pcvar_num(g_cvar))
    }

Thanks, it works fine even in DeathMatch, but the BOTs are not affected when they respawn, they keep respawning at 100% HP
__________________
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)


Last edited by SoulWeaver16; 04-10-2023 at 18:25.
SoulWeaver16 is offline
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 04-11-2023 , 03:51   Re: Spawn with 25 HP
Reply With Quote #4

Quote:
Originally Posted by SoulWeaver16 View Post
Thanks, it works fine even in DeathMatch, but the BOTs are not affected when they respawn, they keep respawning at 100% HP
ZBot need some extra step for them to work with HamSandwich
You can try and test it with PodBot, SyPB or any other type of bot

The extra step: https://forums.alliedmods.net/showthread.php?t=294861
__________________
My plugin:

Last edited by Celena Luna; 04-11-2023 at 03:52.
Celena Luna is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 04-11-2023 , 09:55   Re: Spawn with 25 HP
Reply With Quote #5

thank celena

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

#define IsValid(%0) (0 < %0 < 33)

new cvar_hp
new g_hambots// This variable will check if the hams have been recorded
new cvar_botquota// This variable will check if there is bots in the game

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

    
RegisterHam(Ham_Spawn"player""fwPlayerSpawn"1)

    
cvar_hp register_cvar("spawn_hp_amount""25")
}

// Spawn event hook for bots: https://forums.alliedmods.net/showthread.php?t=294861
public client_putinserver(id)
{
    
// If the ID dont is bot
    
if (!is_user_bot(id))
        return;
        
    
// If the ham already registered
    
if (g_hambots)
        return;
        
    
// If dont have any bot in game
    
if (!cvar_botquota)
        return;
        
    
// Set a register ham bots task into bot id
    
set_task(0.1"fw_RegisterHamBots"id);
}

public 
fw_RegisterHamBots(id)
{
    
// Ham Forwards
    
RegisterHamFromEntity(Ham_Spawnid"fwPlayerSpawn"); // In this case, Ham_TakeDamage

    // Here you add any Ham you need
    
    // Register complete
    
g_hambots true;
}

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

lexzor is offline
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 04-13-2023 , 17:49   Re: Spawn with 25 HP
Reply With Quote #6

Quote:
Originally Posted by lexzor View Post
thank celena

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

#define IsValid(%0) (0 < %0 < 33)

new cvar_hp
new g_hambots// This variable will check if the hams have been recorded
new cvar_botquota// This variable will check if there is bots in the game

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

    
RegisterHam(Ham_Spawn"player""fwPlayerSpawn"1)

    
cvar_hp register_cvar("spawn_hp_amount""25")
}

// Spawn event hook for bots: https://forums.alliedmods.net/showthread.php?t=294861
public client_putinserver(id)
{
    
// If the ID dont is bot
    
if (!is_user_bot(id))
        return;
        
    
// If the ham already registered
    
if (g_hambots)
        return;
        
    
// If dont have any bot in game
    
if (!cvar_botquota)
        return;
        
    
// Set a register ham bots task into bot id
    
set_task(0.1"fw_RegisterHamBots"id);
}

public 
fw_RegisterHamBots(id)
{
    
// Ham Forwards
    
RegisterHamFromEntity(Ham_Spawnid"fwPlayerSpawn"); // In this case, Ham_TakeDamage

    // Here you add any Ham you need
    
    // Register complete
    
g_hambots true;
}

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

Attached Thumbnails
Click image for larger version

Name:	de_dust2_cz0005.jpg
Views:	40
Size:	87.2 KB
ID:	200240  
__________________
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
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 04-16-2023 , 11:48   Re: Spawn with 25 HP
Reply With Quote #7

Quote:
PHP Code:
public fw_RegisterHamBots(id)
{
    
// Ham Forwards
    
RegisterHamFromEntity(Ham_Spawnid"fwPlayerSpawn"); // In this case, Ham_TakeDamage

    // Here you add any Ham you need
    
    // Register complete
    
g_hambots true;

PHP Code:
RegisterHamFromEntity(Ham_Spawnid"fwPlayerSpawn"1); // trhis one should be post 
__________________
My plugin:
Celena Luna is offline
SoulWeaver16
Senior Member
Join Date: May 2021
Location: Uruguay
Old 04-16-2023 , 15:57   Re: Spawn with 25 HP
Reply With Quote #8

Quote:
Originally Posted by Celena Luna View Post
PHP Code:
RegisterHamFromEntity(Ham_Spawnid"fwPlayerSpawn"1); // trhis one should be post 
I tried and nothing, it seems strange to me but thanks for the help anyway
__________________
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
Celena Luna
Veteran Member
Join Date: Aug 2013
Location: Nagazora
Old 04-16-2023 , 21:23   Re: Spawn with 25 HP
Reply With Quote #9

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
__________________
My plugin:

Last edited by Celena Luna; 04-16-2023 at 21:30.
Celena Luna is offline
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
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 11:49.


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