Raised This Month: $ Target: $400
 0% 

CZ Bots Class name


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 04-18-2012 , 01:35   Re: CZ Bots Class name
Reply With Quote #1

Quote:
Originally Posted by ConnorMcLeod View Post
No, you can even replace register_message with register_event.

PHP Code:
#include <amxmodx>

#define VERSION "0.0.5"
#define PLUGIN "Ham Register Cz Bots"

new g_pCvarBotJoinAfterPlayerg_pCvarBotQuota

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")

    
g_pCvarBotQuota get_cvar_pointer("bot_quota")
    if( !
g_pCvarBotQuota )
    {
        
set_fail_state("Mode is not Condition Zero")
    }
    
g_pCvarBotJoinAfterPlayer get_cvar_pointer("bot_join_after_player")

    
state deactivated
}

public 
client_putinserverid ) <send_forward> {}
public 
client_putinserverid ) <deactivated>
{
    if( 
is_user_bot(id) && get_pcvar_num(g_pCvarBotQuota) )
    {
        if( 
get_pcvar_num(g_pCvarBotJoinAfterPlayer) )
        {
            new 
iPlayers[32], iNum
            get_players
(iPlayersiNum"ch")
            if( !
iNum )
            {
                return
            }
        }

        
register_event("TextMsg""Event_TextMsg""a")
        
state send_forward
    
}
}

public 
Event_TextMsg() <deactivated> {}
public 
Event_TextMsg() <send_forward>
{
    new 
szName[32]
    
read_data(3szNamecharsmax(szName))
    new 
iForward CreateMultiForward("cz_bot_ham_registerable"ET_IGNOREFP_CELL)
    new 
iRet
    ExecuteForward
(iForwardiRetget_user_index(szName))
    
DestroyForward(iForward)
    
    
pause("a")

Nice, this one works fine with no crash. Thanks.
__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019
yokomo is offline
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 04-18-2012 , 03:44   Re: CZ Bots Class name
Reply With Quote #2

Quote:
Originally Posted by yokomo View Post
Nice, this one works fine with no crash. Thanks.
Ive had issues with mass plugins using this forward... it would continue running and not register the bots... i have been using this method from rage without issue and same load of plugin


http://forums.alliedmods.net/showpos...7&postcount=41
Doc-Holiday is offline
yokomo
Surprise Ascot!
Join Date: May 2010
Location: Malaysia
Old 04-18-2012 , 05:50   Re: CZ Bots Class name
Reply With Quote #3

Quote:
Originally Posted by Doc-Holiday View Post
Ive had issues with mass plugins using this forward... it would continue running and not register the bots... i have been using this method from rage without issue and same load of plugin


http://forums.alliedmods.net/showpos...7&postcount=41
Hurmm strange, but for me it work fine. The 1st code that Connor attached is error, but this 1 no error.

Test result:
Code:
[Ham Test] Bot [13] killed.
[Ham Test] Bot [1] spawned.
[Ham Test] Bot [2] spawned.
[Ham Test] Bot [3] spawned.
[Ham Test] Bot [4] spawned.
[Ham Test] Bot [5] spawned.
[Ham Test] Bot [6] spawned.
[Ham Test] Bot [7] spawned.
[Ham Test] Bot [8] spawned.
[Ham Test] Bot [9] spawned.
[Ham Test] Bot [10] spawned.
[Ham Test] Bot [17] hitted by [15.0] damage.
[Ham Test] Bot [17] hitted by [15.0] damage.
[Ham Test] Bot [17] hitted by [65.0] damage.
[Ham Test] Bot [15] hitted by [195.0] damage.
[Ham Test] Bot [17] hitted by [65.0] damage.
[Ham Test] Bot [17] hitted by [260.0] damage.
[Ham Test] Bot [17] hitted by [114.7] damage.
[Ham Test] Bot [17] hitted by [95.0]
Test plugin:
PHP Code:
#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("Test CZ bot Ham""0.0.1""wbyokomo")
    
    
RegisterHam(Ham_Spawn"player""OnPlayerSpawnPost"1)
    
RegisterHam(Ham_Killed"player""OnPlayerKilled")
    
RegisterHam(Ham_TakeDamage"player""OnPlayerTakeDamage")
}

public 
cz_bot_ham_registerable(id)
{
    
RegisterHamFromEntity(Ham_Spawnid"OnPlayerSpawnPost"1)
    
RegisterHamFromEntity(Ham_Killedid"OnPlayerKilled")
    
RegisterHamFromEntity(Ham_TakeDamageid"OnPlayerTakeDamage")
}

public 
OnPlayerSpawnPost(id)
{
    if(!
is_user_alive(id)) return;
    
client_print(0print_chat"[Ham Test] Bot [%i] spawned."id)
}

public 
OnPlayerKilled(id)
{
    
client_print(0print_chat"[Ham Test] Bot [%i] killed."id)
}

public 
OnPlayerTakeDamage(victiminflictorattackerFloat:damagedamagetype)
{
    if(!
is_user_connected(attacker)) return HAM_IGNORED;
    
client_print(attackerprint_chat"[Ham Test] Bot [%i] hitted by [%.1f] damage."victimdamage)
    
    return 
HAM_IGNORED;

__________________
Team-MMG CS1.6 Servers:
✅ MultiMod -- 103.179.44.152:27016
✅ Zombie Plague -- 103.179.44.152:27015
✅ Zombie Escape -- 103.179.44.152:27017
✅ Klassik Kombat -- 103.179.44.152:27018
✅ Boss-Battle -- 103.179.44.152:27019

Last edited by yokomo; 04-18-2012 at 06:12.
yokomo 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 00:47.


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