Raised This Month: $ Target: $400
 0% 

[ HELP ] Invalid Player (-1) ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-21-2015 , 08:32   [ HELP ] Invalid Player (-1) ?
Reply With Quote #1

I've got the following error:
Code:
L 11/21/2015 - 11:25:12: Start of error session.
L 11/21/2015 - 11:25:12: Info (map "cs_assault") (file "addons/amxmodx/logs/error_20151121.log")
L 11/21/2015 - 11:25:12: [ZP] Invalid Player (-1)
L 11/21/2015 - 11:25:12: [AMXX] Run time error 10 (plugin "zp_bot_addon_give_random_extras.amxx") (native "zp_force_buy_extra_item") - debug not enabled!
L 11/21/2015 - 11:25:12: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).
I do not know what the problem is, how to fix?
Code:
#include < amxmodx > #include < zombieplague > new const VERSION[] = "1.0"; new g_max_players , g_has_extra[33] , cvar_give_extras_delay; public plugin_init() {     register_plugin("[ZP] Bot Addon: Give Random Extras", VERSION, "CrazY");     cvar_give_extras_delay = register_cvar("zp_give_extras_delay", "20.0");     g_max_players = get_maxplayers() } public zp_round_started()     set_task(get_pcvar_float(cvar_give_extras_delay), "GiveRandomExtraBot", 053, .flags="b"); public zp_round_ended() {     if (task_exists(053)) remove_task(053);     g_has_extra[0] = false; } public GiveRandomExtraBot() {     static iBotName[33], iBotsNum; iBotsNum = fnGetBot();     new BotID = fnGetRandomBot(random_num(1, iBotsNum));     get_user_name(BotID, iBotName, 32);     set_hudmessage(random(255), random(255), random(255), -1.0, 0.7, 1, 6.0, 1.1, 0.5, 0.5);     show_hudmessage(0, "O bot %s ganhou uma  M249 Para Machinegun", iBotName);     zp_force_buy_extra_item(BotID, zp_get_extra_item_id("M249 Para Machinegun"), 1);     g_has_extra[BotID] = true; } stock fnGetBot() {     new iBot, id;     for (id = 1; id <= g_max_players; id++)     {         if (is_user_bot(id) && is_user_connected(id)) iBot++;     }     return iBot; } stock fnGetRandomBot(target_index) {     new iBot, id;     for (id = 1; id <= g_max_players; id++)     {         if (is_user_bot(id) && is_user_connected(id) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id) && !g_has_extra[id]) iBot++;         if (iBot == target_index)             return id;     }     return -1; }
__________________









Last edited by CrazY.; 11-21-2015 at 08:32.
CrazY. is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 11-21-2015 , 08:35   Re: [ HELP ] Invalid Player (-1) ?
Reply With Quote #2

Code:
stock fnGetRandomBot(target_index) {     new iBot, id;     for (id = 1; id <= g_max_players; id++)     {         if (is_user_bot(id) && is_user_connected(id) && !zp_get_user_zombie(id) && !zp_get_user_survivor(id) && !g_has_extra[id]) iBot++;         if (iBot == target_index)             return id;     }     return -1; }
Rirre is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-21-2015 , 08:59   Re: [ HELP ] Invalid Player (-1) ?
Reply With Quote #3

Other log error:
Code:
L 11/21/2015 - 11:57:45: Start of error session.
L 11/21/2015 - 11:57:45: Info (map "cs_assault") (file "addons/amxmodx/logs/error_20151121.log")
L 11/21/2015 - 11:57:45: [ZP] Invalid Player (-1)
L 11/21/2015 - 11:57:45: [AMXX] Displaying debug trace (plugin "zp_bot_addon_give_random_extras.amxx")
L 11/21/2015 - 11:57:45: [AMXX] Run time error 10: native error (native "zp_force_buy_extra_item")
L 11/21/2015 - 11:57:45: [AMXX]    [0] zp_bot_addon_give_random_extras.sma::GiveRandomExtraBot (line 50)
Code:
zp_force_buy_extra_item(BotID, zp_get_extra_item_id("M249 Para Machinegun"), 1); // Line 50

Code:
stock fnGetRandomBot(target_index) {     new iBot, id; iBot = 0;     for (id = 1; id <= g_max_players; id++)     {         if (is_user_bot(id) && is_user_connected(id) && !zp_get_user_zombie(id) && !zp_get_user_sniper(id) && !zp_get_user_survivor(id) && !g_has_extra[id]) iBot++;         if (iBot == target_index)             return id;     }     return-1; }
__________________








CrazY. is offline
Chihuahuax
Senior Member
Join Date: Oct 2014
Location: Malaysia
Old 11-21-2015 , 09:15   Re: [ HELP ] Invalid Player (-1) ?
Reply With Quote #4

Replace is_user_connected(id) with is_user_alive(id) ?
Chihuahuax is offline
Send a message via Skype™ to Chihuahuax
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-21-2015 , 09:23   Re: [ HELP ] Invalid Player (-1) ?
Reply With Quote #5

Does not work, same mistake.
__________________








CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-21-2015 , 10:29   Re: [ HELP ] Invalid Player (-1) ?
Reply With Quote #6

Untested
PHP Code:

#include < amxmodx >
#include < zombieplague >

#define MAX_PLAYERS 32

new const VERSION[] = "1.0";

new 
bool:g_bHasExtraMAX_PLAYERS ]; 

new 
cvar_give_extras_delay;

public 
plugin_init()
{
    
register_plugin("[ZP] Bot Addon: Give Random Extras"VERSION"CrazY");
    
cvar_give_extras_delay register_cvar("zp_give_extras_delay""20.0");
}

public 
zp_round_started()
    
set_task(get_pcvar_float(cvar_give_extras_delay), "GiveRandomExtraBot"053, .flags="b");

public 
zp_round_ended()
{
    
remove_task053 );
        
    
arraysetg_bHasExtra false sizeofg_bHasExtra ) );
    
//g_has_extra[0] = false;
}

public 
GiveRandomExtraBot()
{
    static 
iBotName[33];
    new 
BotID fnGetBot();
    
    if ( 
BotID 
    {
        
get_user_name(BotIDiBotName32);
        
set_hudmessage(random(255), random(255), random(255), -1.00.716.01.10.50.5);
        
show_hudmessage(0"O bot %s ganhou uma  M249 Para Machinegun"iBotName);
        
zp_force_buy_extra_item(BotIDzp_get_extra_item_id("M249 Para Machinegun"), 1);
        
g_bHasExtraBotID ] = true;
    }
}

stock fnGetBot()
{
    new 
iPlayers32 ] , iNum id iBot;
    
    
get_playersiPlayers iNum "dh" );
    
    for ( new 
iNum i++ )
    {
        
id iPlayers];
        
        if ( !
g_bHasExtraid ] )
        {
            
iBot id;
            break;
        }
    }
    
    return 
iBot;

get_players() flags
Code:
Optional list of filtering flags:
  "a" - do not include dead clients
  "b" - do not include alive clients
  "c" - do not include bots
  "d" - do not include human clients
  "e" - match with team
  "f" - match with part of name
  "g" - match case insensitive
  "h" - do not include HLTV proxies
  "i" - include connecting clients
__________________

Last edited by Bugsy; 11-21-2015 at 12:18.
Bugsy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 11-21-2015 , 12:10   Re: [ HELP ] Invalid Player (-1) ?
Reply With Quote #7

It work, But how do I give extra item only to bots that did not receive an extra?
__________________








CrazY. is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 11-21-2015 , 12:18   Re: [ HELP ] Invalid Player (-1) ?
Reply With Quote #8

Quote:
Originally Posted by CrazY. View Post
It work, But how do I give extra item only to bots that did not receive an extra?
I missed that requirement. Code is fixed.
__________________
Bugsy 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 18:14.


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