AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   ham_spawn not works for yapb bot (https://forums.alliedmods.net/showthread.php?t=314373)

WATCH_DOGS UNITED 09-23-2021 21:45

Re: ham_spawn not works for yapb bot
 
Quote:

Originally Posted by HamletEagle (Post 2758144)
Here
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new bool:registeredHamForBots

public plugin_init()
{
    
RegisterHam(Ham_Spawn"player""SpawnHook")
}


public 
client_putinserver(id)
{
    if(
is_user_bot(id) && !registeredHamForBots)
    {
        
registeredHamForBots true
        set_task
(0.1"registerHamForBots"id)
    }
}

public 
registerHamForBots(id)
{
    
RegisterHamFromEntity(Ham_Spawnid"SpawnHook"true)
}

public 
SpawnHook(id)
{
    if(
is_user_alive(id))
    {
        
//do stuff for both players and bots here
    
}


No need to duplicate any code.


THANKS.

HamletEagle 09-24-2021 02:39

Re: ham_spawn not works for yapb bot
 
Just noticed I forgot to hook as post. You should add ",1" to RegisterHam. I also fixed the code so you can just copy/paste.


All times are GMT -4. The time now is 17:57.

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