Raised This Month: $51 Target: $400
 12% 

Solved set_hudmessage error


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-21-2021 , 05:48   set_hudmessage error
Reply With Quote #1

hello, i have this error

Code:
L 01/21/2021 - 12:36:44: HudSyncObject -1 is invalid
L 01/21/2021 - 12:36:44: [AMXX] Displaying debug trace (plugin "playermenu.amxx", version "2.0")
L 01/21/2021 - 12:36:44: [AMXX] Run time error 10: native error (native "ShowSyncHudMsg")
L 01/21/2021 - 12:36:44: [AMXX] [0] playermenu.sma::showhud (line 655)
line 654-655

PHP Code:

static SyncHudMessage

public init() SyncHudMessage CreateHudSyncObj( );

set_hudmessageColorRColorGColorB, -1.00.9000.01.00.10.1, -
        
ShowSyncHudMsgidSyncHudMessageszMessage 
i get the same error 3 times/1second. that means there are not free channel left to display that message ?

Last edited by lexzor; 01-22-2021 at 14:34.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-21-2021 , 07:23   Re: set_hudmessage error
Reply With Quote #2

No, it means you're displaying the message before creating the object.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-21-2021 , 09:52   Re: set_hudmessage error
Reply With Quote #3

ok, now i have this error:

Code:
L 01/21/2021 - 16:51:11: [ENGINE] Entity out of range (-423242)
L 01/21/2021 - 16:51:11: [AMXX] Displaying debug trace (plugin "playermenu.amxx", version "2.0")
L 01/21/2021 - 16:51:11: [AMXX] Run time error 10: native error (native "entity_get_int")
L 01/21/2021 - 16:51:11: [AMXX] [0] playermenu.sma::showhud (line 638)
also, idk how to use set_task right. so, is ok what i did:

PHP Code:
#define HudTask 423242
#define CamTask 312321

public client_putinserver(id){
    
set_task1.0"showhud"id HudTask__"b");
}

public 
showhud(id){    
    static 
szMessage[256],
    
name[33],
    
targetid
    
id
    
    targetid 
entity_get_int(idEV_INT_iuser2)
    
id -= HudTask
    
    
if(hudon[id] == ){
        
        if(
is_user_logged(id) == && is_user_alive(id)){
            
get_user_name(idnamecharsmax(name))
            
formatex(szMessagecharsmax(szMessage), "[Name: %s]^n[Money: %d | Cases: %d | Keys: %d | Scraps: %d]"nameget_user_money(id), get_user_cases(id), get_user_keys(id), get_user_scraps(id))
            
        } else if(
is_user_logged(id) == && is_user_alive(id))
        
formatex(szMessagecharsmax(szMessage), "[Not logged in!]")
        
        else if( !
is_user_alive(id) && is_user_alive(targetid) && is_user_logged(targetid) == 1){
            
get_user_name(targetidnamecharsmax(name))
            
formatex(szMessagecharsmax(szMessage), "[Name: %s]^n[Money: %d | Cases: %d | Keys: %d | Scraps: %d]"nameget_user_money(targetid), get_user_cases(targetid), get_user_keys(targetid), get_user_scraps(targetid))
            
            } else if (!
is_user_alive(id) && is_user_alive(targetid) && is_user_logged(targetid) == 0){
            
get_user_name(targetidnamecharsmax(name))
            
formatex(szMessagecharsmax(szMessage), "[Player %s is not logged in!]"name);
            
        } else if (!
is_user_alive(targetid))    return PLUGIN_HANDLED
        
        set_hudmessage
ColorRColorGColorB, -1.00.9000.01.00.10.1, -
        
ShowSyncHudMsgidSyncHudMessageszMessage )
        
    } else if (
hudon[id] == 1)    return PLUGIN_HANDLED    
}

public 
camroundstart(id){
    
set_task(15.0"camreset",id CamTask)
    
camset[id] = false
}

public 
camreset(id){
    static 
id
    id 
-= CamTask
    remove_task
(id)
    
    
camset[id] = true
    camera
[id] = false
    
if (is_user_alive(id))    set_view(idCAMERA_NONE)

line 638:
PHP Code:
targetid entity_get_int(idEV_INT_iuser2

Last edited by lexzor; 01-21-2021 at 09:55.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-21-2021 , 09:57   Re: set_hudmessage error
Reply With Quote #4

Check if the entity is valid with "is_valid_ent" before using "entity_*" functions on it.

You're creating an "id" variable inside the task when you already have it in the body.
Just do "id -= HudTask" in the first line of showHud(). Otherwise the usage of "set_task" is correct.

If this is a HUD message that shows info about the player you're aiming at, I'd suggest you use the "StatusValue" event instead of tasks. This way you can immediately show and remove the message with 0 delay.

Code:
register_event("StatusValue", "OnStatusValue", "be", "1=2", "2!0") register_event("StatusValue", "OnStatusValue", "be", "1=1", "2=0") public OnStatusValue(id) // id is the player who should see the message {     new iType = read_data(1) // type is 1 when the message should be removed, or 2 when the message should display     new iPlayer = read_data(2) // iPlayer is the player you're aiming at         switch(iType)     {         case 1:         {             // ClearSyncHud()         }         case 2:         {             // ShowSyncHudMsg()         }     }    }
__________________

Last edited by OciXCrom; 01-21-2021 at 10:02.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-21-2021 , 10:11   Re: set_hudmessage error
Reply With Quote #5

i'm trying to show info about player's that i'm spectating on
lexzor is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-21-2021 , 10:29   Re: set_hudmessage error
Reply With Quote #6

i get the error from first reply for this code

PHP Code:
public showhud(id){
    
id -= HudTask    
    
static szMessage[256],
    
targetid
    
    
/*if(!is_valid_ent(targetid))
        targetid = entity_get_int(id, EV_INT_iuser2) */
    
    
if(hudon[id] == ){
        
formatex(szMessagecharsmax(szMessage), "[Not logged in!]")
        
set_hudmessageColorRColorGColorB, -1.00.9000.01.00.10.1, -
        
ShowSyncHudMsgidSyncHudMessageszMessage )
        
    } else if (
hudon[id] == 1)    remove_task(id HudTask)    


Last edited by lexzor; 01-21-2021 at 10:34.
lexzor is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-21-2021 , 12:22   Re: set_hudmessage error
Reply With Quote #7

Ok, idk how but i managed to get rid of that error, but i got a problem.

My text looks like set_task is on 0.1, but he's not
https://imgur.com/JDSHhfQ

the text above is how it should look and the text below is how's looking rn

PHP Code:
public client_authorized(id){    
    
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) ); 
    
set_task1.0"showhud"id HudTask__"b");
    
cmdGet(id)    
}

public 
showhud(id){
    
id -= HudTask    
    
static szMessage[256]
    static 
name[33]
    static 
targetidtargetid entity_get_int(idEV_INT_iuser2)
    
    if(
hudon[id] == ){
        
        if(
is_user_logged(id) == && is_user_alive(id)){
            
get_user_name(idnamecharsmax(name))
            
formatex(szMessagecharsmax(szMessage), "[Name: %s]^n[Money: %d | Cases: %d | Keys: %d | Scraps: %d]"nameget_user_money(id), get_user_cases(id), get_user_keys(id), get_user_scraps(id))
            
        } else if(
is_user_logged(id) == && is_user_alive(id))
        
formatex(szMessagecharsmax(szMessage), "[Not logged in!]")
        
        else if( !
is_user_alive(id) && is_user_alive(targetid) && is_user_logged(targetid) == 1){
            
get_user_name(targetidnamecharsmax(name))
            
formatex(szMessagecharsmax(szMessage), "[Name: %s]^n[Money: %d | Cases: %d | Keys: %d | Scraps: %d]"nameget_user_money(targetid), get_user_cases(targetid), get_user_keys(targetid), get_user_scraps(targetid))
            
            } else if (!
is_user_alive(id) && is_user_alive(targetid) && is_user_logged(targetid) == 0){
            
get_user_name(targetidnamecharsmax(name))
            
formatex(szMessagecharsmax(szMessage), "[Player %s is not logged in!]"name);
            
        } else if (!
is_user_alive(targetid))    return PLUGIN_HANDLED
        
        set_hudmessage
ColorRColorGColorB, -1.00.9000.01.00.10.1, -
        
ShowSyncHudMsgidSyncHudMessageszMessage )
        
    } else if (
hudon[id] == 1)    return PLUGIN_HANDLED    

lexzor is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-21-2021 , 12:54   Re: set_hudmessage error
Reply With Quote #8

Try calling ClearSyncHud before the ShowSyncHudMsg or decreasing the holdtime, fadeintime and fadeouttime parameters of set_hudmessage.
__________________








CrazY. is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-22-2021 , 06:33   Re: set_hudmessage error
Reply With Quote #9

now i get this
Code:
L 01/22/2021 - 13:29:17: [AMXX] [0] playermenu.sma::showhud (line 648)
L 01/22/2021 - 13:29:17: [ENGINE] Entity out of range (3225)
L 01/22/2021 - 13:29:17: [AMXX] Displaying debug trace (plugin "playermenu.amxx", version "2.0")
L 01/22/2021 - 13:29:17: [AMXX] Run time error 10: native error (native "entity_get_int")
on this line


PHP Code:
if(!is_user_alive(id) && !is_valid_ent(targetid))
    
targetid entity_get_int(idEV_INT_iuser2

Last edited by lexzor; 01-22-2021 at 06:33.
lexzor is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-22-2021 , 06:44   Re: set_hudmessage error
Reply With Quote #10

Delete the exclamation point that is at the left of is_valid_ent
__________________









Last edited by CrazY.; 01-22-2021 at 07:04.
CrazY. 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 00:17.


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