View Single Post
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-20-2009 , 06:44   Re: Bot Apology for TK
Reply With Quote #4

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_numcvar_sorry_onoff ) )
    {
        new 
killerid read_data);
        new 
victimid read_data);
        
        if ( 
victimid != killerid && is_user_botkillerid ) && get_user_teamkillerid ) == get_user_teamvictimid ) )
        {
            
remove_taskkillerid );
            
set_taskget_pcvar_floatcvar_sorry_delay ), "say_sorry"killerid );
        }
    }

PHP Code:
public say_sorry id )
{
    if ( 
is_user_bot id ) && clampget_pcvar_numcvar_sorry_prob ), 0100 ) > random_num099 ) )
    {
        
engclient_cmdid"say"g_sorry_phrasesrandomsizeofg_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" );
Arkshine is offline