AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Spawn with 25 HP (https://forums.alliedmods.net/showthread.php?t=342427)

SoulWeaver16 04-10-2023 13:21

Spawn with 25 HP
 
1 Attachment(s)
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): Attachment 200280

lexzor 04-10-2023 13:46

Re: Spawn with 25 HP
 
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))
    }



SoulWeaver16 04-10-2023 18:20

Re: Spawn with 25 HP
 
Quote:

Originally Posted by lexzor (Post 2802500)
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

Celena Luna 04-11-2023 03:51

Re: Spawn with 25 HP
 
Quote:

Originally Posted by SoulWeaver16 (Post 2802512)
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

lexzor 04-11-2023 09:55

Re: Spawn with 25 HP
 
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))
    }



SoulWeaver16 04-13-2023 17:49

Re: Spawn with 25 HP
 
1 Attachment(s)
Quote:

Originally Posted by lexzor (Post 2802560)
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))
    }




Celena Luna 04-16-2023 11:48

Re: Spawn with 25 HP
 
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 


SoulWeaver16 04-16-2023 15:57

Re: Spawn with 25 HP
 
Quote:

Originally Posted by Celena Luna (Post 2802860)
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

Celena Luna 04-16-2023 21:23

Re: Spawn with 25 HP
 
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
https://i.imgur.com/jR3hDoq.png

SoulWeaver16 04-17-2023 20:08

Re: Spawn with 25 HP
 
Quote:

Originally Posted by Celena Luna (Post 2802895)
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
https://i.imgur.com/jR3hDoq.png

Thanks, it does somehow work if with the CZ bots, so thanks Celena


All times are GMT -4. The time now is 18:27.

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