Quote:
I assume you say this because it will be faster/more efficient?
|
Yep. Always better to avoid unnecessary native call. Bot will keep a bot so it's not bad to save one time the value in putinserver into a global var.
Quote:
It's not a print_chat message [...] Also, engclient_cmd deos not work like that. "say" is the command and g_sorry_phrase[#] is arg1.
|
You're right. I did not think that when I reviewed your plugin.
Quote:
I check if it's a bot because in 3 seconds time (or what ever time set with the cvar) the bot could leave and a real player enters. I don't want the real player to say sorry for that which he has not done.
I check is_user_connected because the bot could leave (and not be replaced) in the time set with the delay cvar.
|
is_user_bot, yes, but is_user_connected no because engclient_cmd() won't send if player is not in-game. There is only a check if id is not out of range.
But, anyway, you should remove the task on client_disconnect, so the check is_user_bot would be useless and also avoiding possible problems.
Quote:
WOW, that is quite the insult.
|
Sorry, it was not my intention.
Anyway, you should avoid this way of coding, returning each time something. It will generate more code. You could do something like :
PHP Code:
public player_death ()
{
if ( get_pcvar_num( cvar_sorry_onoff ) )
{
new killerid = read_data( 1 );
new victimid = read_data( 2 );
if ( victimid != killerid && is_user_bot( killerid ) && get_user_team( killerid ) == get_user_team( victimid ) )
{
remove_task( killerid );
set_task( get_pcvar_float( cvar_sorry_delay ), "say_sorry", killerid );
}
}
}
PHP Code:
public say_sorry ( id )
{
if ( is_user_bot ( id ) && clamp( get_pcvar_num( cvar_sorry_prob ), 0, 100 ) > random_num( 0, 99 ) )
{
engclient_cmd( id, "say", g_sorry_phrases[ random( sizeof( g_sorry_phrases ) ) ] );
}
}
Also you should add that attacker should be > 0, it will skip suicide and killed by world :
register_event( "DeathMsg", "player_death", "a", "1>0" );