AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   CZ Bots Class name (https://forums.alliedmods.net/showthread.php?t=162184)

Doc-Holiday 07-15-2011 22:22

CZ Bots Class name
 
I know they dont have the "player" class name is there a specific classname for them?

After some testing This is what i got back from the code below.

Code:

Bot Class Name player
Bot Class Name player
Bot Class Name player
Bot Class Name player
Bot Class Name player

PHP Code:

public client_authorizedid )
{    
    if( !
gBotsRegistered && is_user_botid ) )
    {
        
set_task0.1"register_bots"id );
    }
}

public 
register_botsid )
{
    if( !
gBotsRegistered && is_user_connectedid ) )
    {
        
RegisterHamFromEntityHam_Spawnid"BotSpawn");
        
gBotsRegistered true;
    }
}

public 
BotSpawn(id)
{
    new 
classname[33]
    
pevidpev_classnameclassname32 )
    
    
client_print(0print_chat"Bot Class Name %s"classname);


If thats the case why do i have to register ham from ent ??

ConnorMcLeod 07-16-2011 06:05

Re: CZ Bots Class name
 
3 Attachment(s)
Works fine with orpheu but not with ham.

If you are interested, i'm using a multiforward to register bots so you don't have to exec multiple tasks through all plugins that need them.

Plugin then looks like this :

PHP Code:

#include <amxmodx>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("bla","bla","bla")
}

public 
cz_bot_ham_registerableid )
{
    
RegisterHamFromEntityHam_Spawnid"BotSpawn")
}

public 
BotSpawnid )
{
    
// your code here



Doc-Holiday 07-18-2011 20:18

Re: CZ Bots Class name
 
1 Attachment(s)
btw just so ppl dont try this and it doesnt work...

get_pcvar_num(g_pCvarBotQuota).... doesnt exist

ConnorMcLeod 07-19-2011 01:17

Re: CZ Bots Class name
 
Ops, fixed.

Doc-Holiday 07-19-2011 02:06

Re: CZ Bots Class name
 
Quote:

Originally Posted by ConnorMcLeod (Post 1513565)
Ops, fixed.

Question you dont have to "include" anything for your plugin it just executes all forwards in any plugin we use using that name?

ConnorMcLeod 07-19-2011 02:10

Re: CZ Bots Class name
 
I don't remember if i had to put (or not) :

forward cz_bot_ham_registerable(index);

at top of .sma, that would be equivalent to include something.


I don't think it is needed for forwards though.

yokomo 04-17-2012 05:19

Re: CZ Bots Class name
 
Hi, sorry revive this old thread, Connor i've bug on your API posted on no 2, Server crash when got another plugin using the same register_message
PHP Code:

register_message(get_user_msgid("TextMsg"), "Message_TextMsg"

I have a plugin that using same function too. To solve this i need to comment on your API:
PHP Code:

//unregister_message(iMsgId, g_iMhTextMsg) 

Just want to know. Is that necessary to unregister back that message?

ConnorMcLeod 04-18-2012 00:13

Re: CZ Bots Class name
 
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")



yokomo 04-18-2012 01:35

Re: CZ Bots Class name
 
Quote:

Originally Posted by ConnorMcLeod (Post 1691523)
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.

Doc-Holiday 04-18-2012 03:44

Re: CZ Bots Class name
 
Quote:

Originally Posted by yokomo (Post 1691561)
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


All times are GMT -4. The time now is 00:47.

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