Raised This Month: $ Target: $400
 0% 

Small help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 09-30-2017 , 15:16   Small help
Reply With Quote #1

hello guys
i using bots plugin

look to this code

PHP Code:
formatexg_Query255"%s",g_Names[random_num(0,sizeof(g_Names)-1)]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 
PHP Code:
new const g_Names[][]=
{
    
"RadioShack",
    
"Paul Kalkbrenner",
    
"ZombieSV"
}; 
i have only one problem

sometimes Bot name is repeated

like
RadioShack
(1)RadioShack

Paul Kalkbrenner
(1)Paul Kalkbrenner

how i can fix this problem ? i don't want Bot name to repeated !

any idea ?
bakir123 is offline
Send a message via Skype™ to bakir123
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-30-2017 , 15:22   Re: Small help
Reply With Quote #2

Check if the name already exists and if it does choose another one. Make sure that your list of names is long.
__________________
fysiks is offline
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 09-30-2017 , 15:25   Re: Small help
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
Check if the name already exists and if it does choose another one. Make sure that your list of names is long.

look
i'm really noop with coding , not too much

this is full code
i hope you help me..

PHP Code:
#include amxmodx
#include fakemeta

new const g_Names[][]=
{
    
"RadioShack",
    
"Paul Kalkbrenner",
    
"ZombieSV"
};

public 
plugin_init()
{
    
set_task10.0"TaskManageBots", .flags="b" );
}

new 
g_Bot[33], g_BotsCount;
new 
g_Query[256];
public 
TaskManageBots(){
    static 
PlayersNumPlayersNum  get_playersnum);
    if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
CreateBot();
    } else if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
RemoveBot();
    }}

public 
client_disconnect(i)
{
    if( 
g_Bot] ) {
        
g_Bot] = 0g_BotsCount -- ;
    }
}

RemoveBot(){
    static 
i;
    for( 
1<= get_maxplayers(); i++ ) {
        if( 
g_Bot] ) {
            
server_cmd"kick #%d"get_user_userid) );break;
        }}}

CreateBot(){
    static 
Bot;
    
//formatex( g_Query, 255, !random_num(0,1)?"%s (%c%c)":"%s - %c%c",g_Names[random_num(0,sizeof(g_Names)-1)],random_num('A','Z'),random_num('A','Z') );Bot = engfunc( EngFunc_CreateFakeClient, g_Query );
    
formatexg_Query255"%s",g_Names[random_num(0,sizeof(g_Names)-1)]);Bot engfuncEngFunc_CreateFakeClientg_Query );
    if( 
Bot &&pev_valid(Bot)) {
        
dllfunc(MetaFunc_CallGameEntity,"player",Bot);
        
set_pev(Bot,pev_flags,FL_FAKECLIENT);
        
set_pev(Botpev_model"");
        
set_pev(Botpev_viewmodel2"");
        
set_pev(Botpev_modelindex0);
        
set_pev(Botpev_renderfxkRenderFxNone);
        
set_pev(Botpev_rendermodekRenderTransAlpha);
        
set_pev(Botpev_renderamt0.0);
        
set_pdata_int(Bot,114,0);
        
message_begin(MSG_ALL,get_user_msgid("TeamInfo"));
        
write_byte(Bot);
        
write_string("UNASSIGNED");
        
message_end();
        
g_Bot[Bot]=1;
        
g_BotsCount++;
    }

bakir123 is offline
Send a message via Skype™ to bakir123
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 09-30-2017 , 15:51   Re: Small help
Reply With Quote #4

Just dont use random_num function

PHP Code:
formatexg_Query255"%s",g_Names[random_num(0,sizeof(g_Names)-1)]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 

to

PHP Code:
formatexg_Query255"%s",g_Names[sizeof(g_Names)]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 
__________________
ghost95v is offline
Send a message via Skype™ to ghost95v
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 09-30-2017 , 15:59   Re: Small help
Reply With Quote #5

Quote:
Originally Posted by ghost95v View Post
Just dont use random_num function

PHP Code:
formatexg_Query255"%s",g_Names[random_num(0,sizeof(g_Names)-1)]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 

to

PHP Code:
formatexg_Query255"%s",g_Names[sizeof(g_Names)]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 

error 032: array index out of bounds (variable "g_Names")
bakir123 is offline
Send a message via Skype™ to bakir123
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 09-30-2017 , 16:05   Re: Small help
Reply With Quote #6

i changed
PHP Code:
formatexg_Query255"%s",g_Names[sizeof(g_Names)]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 
to

PHP Code:
formatexg_Query255"%s",g_Names[sizeof(g_Names)-1]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 
it's compiled. but , it's give double name (1)

Still same !

i think we should edit on
PHP Code:
new const g_Names[][]= 
bakir123 is offline
Send a message via Skype™ to bakir123
ghost95v
Senior Member
Join Date: Apr 2014
Location: somewhere in universe
Old 09-30-2017 , 16:19   Re: Small help
Reply With Quote #7

PHP Code:
#include amxmodx
#include fakemeta


new g_Names[3][]=
{
    
"Name0",
    
"Name1",
    
"Name2"

};


new 
g_Query[256];

public 
plugin_init()
{
    
    
set_task15.0"TaskManageBots", .flags="b" );
    
}
new 
g_Bot[33], g_BotsCount;
public 
TaskManageBots(){
    static 
PlayersNumPlayersNum  get_playersnum);
    if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
CreateBot();
    } else if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
RemoveBot();
    }}

public 
client_disconnect(i)
{
    if( 
g_Bot] ) {
        
g_Bot] = 0g_BotsCount -- ;
    }
}

RemoveBot(){
    static 
i;
    for( 
1<= get_maxplayers(); i++ ) {
        if( 
g_Bot] ) {
            
server_cmd"kick #%d"get_user_userid) );break;
        }}}

CreateBot(){
    static 
Bot;
    if(
g_BotsCount == 0)
    
            
formatexg_Query255,"%s" ,g_Names[0])
    else if(
g_BotsCount == 1)
            
formatexg_Query255,"%s" ,g_Names[1])
    else 
            
formatexg_Query255,"%s" ,g_Names[2])
    
    
Bot engfuncEngFunc_CreateFakeClientg_Query );
    if( 
Bot &&pev_valid(Bot)) {
        
dllfunc(MetaFunc_CallGameEntity,"player",Bot);
        
set_pev(Bot,pev_flags,FL_FAKECLIENT);
        
set_pev(Botpev_model"");
        
set_pev(Botpev_viewmodel2"");
        
set_pev(Botpev_modelindex0);
        
set_pev(Botpev_renderfxkRenderFxNone);
        
set_pev(Botpev_rendermodekRenderTransAlpha);
        
set_pev(Botpev_renderamt0.0);
        
set_pdata_int(Bot,114,0);
        
message_begin(MSG_ALL,get_user_msgid("TeamInfo"));
        
write_byte(Bot);
        
write_string("UNASSIGNED");
        
message_end();
        
g_Bot[Bot]=1;
        
g_BotsCount++;
    }

__________________
ghost95v is offline
Send a message via Skype™ to ghost95v
TheSpaniard
Senior Member
Join Date: Jul 2017
Location: Hell
Old 10-01-2017 , 00:37   Re: Small help
Reply With Quote #8

Quote:
Originally Posted by bakir123 View Post
i changed
PHP Code:
formatexg_Query255"%s",g_Names[sizeof(g_Names)]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 
to

PHP Code:
formatexg_Query255"%s",g_Names[sizeof(g_Names)-1]);Bot engfuncEngFunc_CreateFakeClientg_Query ); 
it's compiled. but , it's give double name (1)

Still same !
Quote:
Originally Posted by bakir123 View Post
i think we should edit on
PHP Code:
new const g_Names[][]= 
That's because you are adding more no of bots than the plugins specifies by that i mean there are little names and many bots thats whats happening.
Either you can add less bots or specify more no of names for the bots.

EDIT: You are right didnt read the whole post you have to edit the g_names var.
__________________
And I Am Back.

Last edited by TheSpaniard; 10-01-2017 at 00:41. Reason: im such a lazya*s
TheSpaniard is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 10-01-2017 , 03:35   Re: Small help
Reply With Quote #9

You can check if name exist and then create bot. But be aware, check also if bot numbers don't exceed the names number, because it will give you an infinite loop(and crash), as all names will be used by other bots.

Last edited by siriusmd99; 10-01-2017 at 03:35.
siriusmd99 is offline
bakir123
Senior Member
Join Date: Jan 2015
Location: Palestine, Hebron
Old 10-01-2017 , 07:53   Re: Small help
Reply With Quote #10

Quote:
Originally Posted by ghost95v View Post
PHP Code:
#include amxmodx
#include fakemeta


new g_Names[3][]=
{
    
"Name0",
    
"Name1",
    
"Name2"

};




new 
g_Query[256];

public 
plugin_init()
{
    
    
set_task15.0"TaskManageBots", .flags="b" );
    
}
new 
g_Bot[33], g_BotsCount;
public 
TaskManageBots(){
    static 
PlayersNumPlayersNum  get_playersnum);
    if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
CreateBot();
    } else if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
RemoveBot();
    }}

public 
client_disconnect(i)
{
    if( 
g_Bot] ) {
        
g_Bot] = 0g_BotsCount -- ;
    }
}

RemoveBot(){
    static 
i;
    for( 
1<= get_maxplayers(); i++ ) {
        if( 
g_Bot] ) {
            
server_cmd"kick #%d"get_user_userid) );break;
        }}}

CreateBot(){
    static 
Bot;
    if(
g_BotsCount == 0)
    
            
formatexg_Query255,"%s" ,g_Names[0])
    else if(
g_BotsCount == 1)
            
formatexg_Query255,"%s" ,g_Names[1])
    else 
            
formatexg_Query255,"%s" ,g_Names[2])
    
    
Bot engfuncEngFunc_CreateFakeClientg_Query );
    if( 
Bot &&pev_valid(Bot)) {
        
dllfunc(MetaFunc_CallGameEntity,"player",Bot);
        
set_pev(Bot,pev_flags,FL_FAKECLIENT);
        
set_pev(Botpev_model"");
        
set_pev(Botpev_viewmodel2"");
        
set_pev(Botpev_modelindex0);
        
set_pev(Botpev_renderfxkRenderFxNone);
        
set_pev(Botpev_rendermodekRenderTransAlpha);
        
set_pev(Botpev_renderamt0.0);
        
set_pdata_int(Bot,114,0);
        
message_begin(MSG_ALL,get_user_msgid("TeamInfo"));
        
write_byte(Bot);
        
write_string("UNASSIGNED");
        
message_end();
        
g_Bot[Bot]=1;
        
g_BotsCount++;
    }



your code only given bot name0 and name1
not random name !!

anyhelp


Edit:

as Ghost Code
i made this and working fine without bug:

PHP Code:
#include amxmodx
#include fakemeta

new const g_Names[][]=
{
    
"name1",
    
"name2"
};

new const 
g_Names2[][]=
{
    
"name1",
    
"name2"
};

public 
plugin_init()
{
    
set_task10.0"TaskManageBots", .flags="b" );
}

new 
g_Bot[33], g_BotsCount;
new 
g_Query[256];
public 
TaskManageBots(){
    static 
PlayersNumPlayersNum  get_playersnum);
    if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
CreateBot();
    } else if( 
PlayersNum get_maxplayers() - && g_BotsCount ) {
        
RemoveBot();
    }}

public 
client_disconnect(i)
{
    if( 
g_Bot] ) {
        
g_Bot] = 0g_BotsCount -- ;
    }
}

RemoveBot(){
    static 
i;
    for( 
1<= get_maxplayers(); i++ ) {
        if( 
g_Bot] ) {
            
server_cmd"kick #%d"get_user_userid) );break;
        }}}

CreateBot(){ 
    static 
Bot
    if(
g_BotsCount == 0
     
            
formatexg_Query255,"%s" ,g_Names[random_num(0,sizeof(g_Names)-1)]) 
    else if(
g_BotsCount == 1
            
formatexg_Query255,"%s" ,g_Names2[random_num(0,sizeof(g_Names2)-1)]) 
 
    
Bot engfuncEngFunc_CreateFakeClientg_Query ); 
    if( 
Bot &&pev_valid(Bot)) { 
        
dllfunc(MetaFunc_CallGameEntity,"player",Bot); 
        
set_pev(Bot,pev_flags,FL_FAKECLIENT); 
        
set_pev(Botpev_model""); 
        
set_pev(Botpev_viewmodel2""); 
        
set_pev(Botpev_modelindex0); 
        
set_pev(Botpev_renderfxkRenderFxNone); 
        
set_pev(Botpev_rendermodekRenderTransAlpha); 
        
set_pev(Botpev_renderamt0.0); 
        
set_pdata_int(Bot,114,0); 
        
message_begin(MSG_ALL,get_user_msgid("TeamInfo")); 
        
write_byte(Bot); 
        
write_string("UNASSIGNED"); 
        
message_end(); 
        
g_Bot[Bot]=1
        
g_BotsCount++; 
    } 

did you think it's a right way to use it ? not cause any probelm ?

Last edited by bakir123; 10-01-2017 at 08:00.
bakir123 is offline
Send a message via Skype™ to bakir123
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 02:23.


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