AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   use_buttons_once error (https://forums.alliedmods.net/showthread.php?t=135434)

BeeT 08-16-2010 07:08

use_buttons_once error
 
Hello,
i would like to ask about use_buttons_once plugin.
I often have error:
Code:

L 08/16/2010 - 11:03:19: Player 2 is not ingame
L 08/16/2010 - 11:03:19: [AMXX] Displaying debug trace (plugin "use_button_once.amxx")
L 08/16/2010 - 11:03:19: [AMXX] Run time error 10: native error (native "player_menu_info")
L 08/16/2010 - 11:03:19: [AMXX]    [0] use_button_once.sma::show_menu_ (line 580)

How to i can fix this error?
Thanks for help.

Arkshine 08-16-2010 07:17

Re: use_buttons_once error
 
Make sure player is ingame when using the native player_menu_info. ( is_user_connected or is_user_alive depending your need )

BeeT 08-16-2010 07:27

Re: use_buttons_once error
 
It's looks like this?:

Code:

public show_menu_(tid){
        new id=tid-TASK_SHOWMENU;
        new iTeam=get_user_team(id);
        new menu_id, keys;
        new menuUp = player_menu_info( id, menu_id, keys );
        // Only display menu if another isn't shown
        if ( iTeam && (menuUp <= 0 || menu_id < 0) ){
                new iTime=get_pcvar_num(gcvarFRVoteTime);
                new iOffset=get_systime()-giVoteStart;
                iTime-=iOffset;
                new szMenu[128];
                formatex(szMenu, 127, "\y%L^n^n\w1. %L^n2. %L",id,"FREERUN_VOTEMENU",id,"FREE",id,"NORMALUS");
                show_menu(id, KeysFFVote, szMenu, iTime, "FRVote");
        }else
                set_task(1.0, "show_menu_", tid);
}

public eventInGame(id){
        if(giVotes[id][VOTE_ON] || giVotes[id][VOTE_OFF])
                return;
        if(gbVote)
        if (is_user_connected(id) && is_user_alive(id) && !is_user_bot(id))
                set_task(1.0, "show_menu_", id+TASK_SHOWMENU);
}


Arkshine 08-16-2010 07:42

Re: use_buttons_once error
 
Do the check in show_menu_() after the first line. And you need only is_user_connected() or is_user_alive ( depending if you want the menu to be showed on dead player or not )

BeeT 08-16-2010 08:06

Re: use_buttons_once error
 
Thanks for help.
Last question it's looks like this?:

Code:

public show_menu_(tid){
        new id=tid-TASK_SHOWMENU;
        if (is_user_alive(id) && !is_user_bot(id)) {
        new iTeam=get_user_team(id);
        new menu_id, keys;
        new menuUp = player_menu_info( id, menu_id, keys );
        // Only display menu if another isn't shown
        if ( iTeam && (menuUp <= 0 || menu_id < 0) ){
                new iTime=get_pcvar_num(gcvarFRVoteTime);
                new iOffset=get_systime()-giVoteStart;
                iTime-=iOffset;
                new szMenu[128];
                formatex(szMenu, 127, "\y%L^n^n\w1. %L^n2. %L",id,"FREERUN_VOTEMENU",id,"FREE",id,"NORMALUS");
                show_menu(id, KeysFFVote, szMenu, iTime, "FRVote");
        }else
                set_task(1.0, "show_menu_", tid);
        }
}



All times are GMT -4. The time now is 22:00.

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