AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_user_weapon errors w/ bots (https://forums.alliedmods.net/showthread.php?t=168370)

urban_ninja 09-28-2011 00:08

get_user_weapon errors w/ bots
 
The get_user_weapon seems to have mad compatibility issues with FoxBot. Is there an other function that does the exact same thing but is stable with bots?

You guys would probably recommend I use is_user_bot function to disclude bots but it would feel to awkward that extra dynamic light flashes with weapon fire would only work with real players.

My usage of this funtion
PHP Code:

if(get_user_weapon(id) == TFC_WPN_AC

Resulting in an error spam in the amxx error logs if bots were ever spawned any time from map start to map end. amxx error logs would range up to 1 terabyte after a day filled with nothing but the following error.
Code:

L 09/27/2011 - 00:00:00: [AMXX] Displaying debug trace (plugin "myplugin.amxx")
L 09/27/2011 - 00:00:00: [AMXX] Run time error 10: native error (native "get_user_weapon")
L 09/27/2011 - 00:00:00: [AMXX]    [0] huf.sma::tfc_ac_FireFlash (line 446)
L 09/27/2011 - 00:00:00: Invalid player id 0

Severity of the error spam varies.

r0ck 09-28-2011 00:28

Re: get_user_weapon errors w/ bots
 
code?

ConnorMcLeod 09-28-2011 01:11

Re: get_user_weapon errors w/ bots
 
Seems to be a code error rather than a bot issue.

urban_ninja 09-28-2011 03:08

Re: get_user_weapon errors w/ bots
 
Spectator used just to start the infinite loop
PHP Code:

public plugin_init(){
 
register_event("Spectator""speed""abcde")


The loop.
PHP Code:

public speed(id)
{
    
set_task(0.0"tfc_ac_FireFlash"id,_,_,"b")


Whats being looped
PHP Code:

public tfc_ac_FireFlash(id)
{
    if(
get_user_weapon(id) == TFC_WPN_AC)
    {    
        if(
pev(idpev_button) & IN_ATTACK)
        {
            new 
origin[3]
            
get_user_origin(idorigin)
            
set_dynamic_light(origin32150130700.1150)
        }
    }


Thats pretty much all there is thats relevant to this part of the plugin with the error. Very small and simple.

The code works in game on both player and bot HW guys shooting the auto-cannon but the errors only happen if theres bots. More bots the more harder the error spams.

EDIT:
Quote:

L 09/27/2011 - 00:00:00: [AMXX] Displaying debug trace (plugin "myplugin.amxx") L 09/27/2011 - 00:00:00: [AMXX] Run time error 10: native error (native "get_user_weapon") L 09/27/2011 - 00:00:00: [AMXX] [0] huf.sma::tfc_ac_FireFlash (line 446) L 09/27/2011 - 00:00:00: Invalid player id 0
Im guessing bots id is 0 for every bot and amxx is not liking it?

r0ck 09-28-2011 04:23

Re: get_user_weapon errors w/ bots
 
PHP Code:

public speed(id)
{
    
set_task(0.1"tfc_ac_FireFlash"id,_,_,"b")


PHP Code:

public tfc_ac_FireFlash(id)
{
    if(!
is_user_connected(id))
         return 
PLUGIN_HANDLED

    
if(get_user_weapon(id) == TFC_WPN_AC)
    {    
        if(
pev(idpev_button) & IN_ATTACK)
        {
            new 
origin[3]
            
get_user_origin(idorigin)
            
set_dynamic_light(origin32150130700.1150)
        }
    }
    return 
PLUGIN_HANDLED



ConnorMcLeod 09-28-2011 11:28

Re: get_user_weapon errors w/ bots
 
register_event("Spectator", "speed", "abcde")

Flags are wrong.

Stereo 09-28-2011 11:51

Re: get_user_weapon errors w/ bots
 
PHP Code:

new g_maxplayers
#define IsPlayer(%1) (1 <= %1 <= g_maxplayers)


//init
g_maxplayers get_maxplayers() 


PHP Code:

//function
if(!IsPlayer(index) ) return PLUGIN_HANDLED 


urban_ninja 09-29-2011 01:41

Re: get_user_weapon errors w/ bots
 
Quote:

Originally Posted by r0ck (Post 1564593)
PHP Code:

public speed(id)
{
    
set_task(0.1"tfc_ac_FireFlash"id,_,_,"b")


PHP Code:

public tfc_ac_FireFlash(id)
{
    if(!
is_user_connected(id))
         return 
PLUGIN_HANDLED

    
if(get_user_weapon(id) == TFC_WPN_AC)
    {    
        if(
pev(idpev_button) & IN_ATTACK)
        {
            new 
origin[3]
            
get_user_origin(idorigin)
            
set_dynamic_light(origin32150130700.1150)
        }
    }
    return 
PLUGIN_HANDLED



Thanks man. That fixed the issue.

ConnorMcLeod 09-29-2011 02:07

Re: get_user_weapon errors w/ bots
 
This is not the good way to fix it, check flags in register_event !!

http://www.amxmodx.org/funcwiki.php?...vent&go=search

Don't put "a" in flags but only "b", for other flags, it depends on what you need.

urban_ninja 09-29-2011 04:45

Re: get_user_weapon errors w/ bots
 
Quote:

Originally Posted by ConnorMcLeod (Post 1565116)
This is not the good way to fix it, check flags in register_event !!

http://www.amxmodx.org/funcwiki.php?...vent&go=search

Don't put "a" in flags but only "b", for other flags, it depends on what you need.

Yep, Already set flags to only "b" when I added the fix.


All times are GMT -4. The time now is 19:32.

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