Raised This Month: $ Target: $400
 0% 

If false add to hudmessage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 07-20-2011 , 20:48   If false add to hudmessage
Reply With Quote #1

Hey guys
I have an array, that fills every cell with each player that connects, gives him his timeleft and sets that he is not ready (false). Now, I did a code that before a pug starts it shows who's not ready in a hudmessage column, that updates every 1 seconds. The problem is that it shows in the Not Ready list the server's name only and nobody else. could someone please tell me why is that? I'll post the public of client_connect so people would see that when client connects he gets a false in the boolean if he's ready or not, only when he types .ready it sets it to true but thats not relevant to the topic. So here's the code:

PHP Code:
/* GLOBAL Variables in this code */
new bool:g_bIsReady[11]
new 
g_iTimeLeft[11]
new 
notrdy[200] = "Not Ready:"
/* GLOBAL Variables in this code */

public client_connect(id)
{    
    new 
pug fopen(pug_ini_file"r")
        new 
getchar
    
    fseek
(pug, -1SEEK_END)
    
getchar fgetc(pug)
    
    if (
getchar == '0')
    {
        
g_bIsReady[id] = false        /* LOOK HERE - THINK AS IF IT PASSES THE 'IF' AND DONT ASK ME WHAT IT DOES, CUZ IT DOES PASS IT AND IM 100 PRECENT SURE CUZ I TESTED IT. look it gives a client who connects that he's false of being ready, which is relevant to my issue. */
        
remove_task(id)
        
g_iTimeLeft[id] = 140
        set_task
(10.0"Continue"id, .flags="a", .repeat=14)
        
    }
    
    else
    {
        
client_print(idprint_chat"%s You have entered to this match as it has already started, you will be used as a substitution."PREFIX)
        return 
PLUGIN_HANDLED
    
}
    
    return 
PLUGIN_HANDLED
}

public 
ShowLeft() /* THINK As if there is a set_task to this public at plugin_precache, so think as if it would reach it, and dont ask me to show how I hooked the public cuz it works, so just think as if it works. */
{
    if (
playersleft != 0)
    {
        for (new 
ii<sizeof(g_bIsReady); i++)
        {
            
            if (
g_bIsReady[i] == false)
            {
                new 
playername[32]
                
get_user_name(g_bIsReady[i], playername31)
                new 
toadd[32] = "^n"
                
add(toadd31playername)
                
add(notrdy31toadd)
            }
            
        }
        
        
set_hudmessage(1272552550.030.0506.012.0)
        
show_hudmessage(0notrdy)
        
set_task(1.0"ShowLeft")
    }
    
    else
    {
        return 
PLUGIN_HANDLED
    
}
    return 
PLUGIN_HANDLED

Thanks alot for the help!

Last edited by Diegorkable; 07-20-2011 at 20:51.
Diegorkable is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-20-2011 , 21:11   Re: If false add to hudmessage
Reply With Quote #2

PHP Code:
get_user_name(g_bIsReady[i], playername31
Something's wrong here (hint)

While i'm at it, as you're probably going to forget, you need to check if the user is connected or alive depending on the situation before you try to get his name.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 07-20-2011 , 21:14   Re: If false add to hudmessage
Reply With Quote #3

g_bIsReady( hint #2 ).

EDIT:
Code:
new g_iMaxPlayers; // global variable for your player loop public plugin_init( ) {     g_iMaxPlayers = get_maxplayers( ); // what it does } for( new i = 1; i <= g_iMaxPlayers; i++ ) // how to loop through the players
__________________
Hi.

Last edited by Kreation; 07-20-2011 at 21:18.
Kreation is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-20-2011 , 21:22   Re: If false add to hudmessage
Reply With Quote #4

Didn't see this before but

PHP Code:
new bool:g_bIsReady[11]
new 
g_iTimeLeft[11]
new 
notrdy[200] = "Not Ready:" 
->
PHP Code:
new bool:g_bIsReady[33]
new 
g_iTimeLeft[33]
new 
notrdy[] = "Not Ready:" 
Because there are a max of 32 ids allowed, and you only filled space for 10. (ids start at 1)
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-21-2011 , 03:43   Re: If false add to hudmessage
Reply With Quote #5

Quote:
Originally Posted by nikhilgupta345 View Post
Didn't see this before but

PHP Code:
new notrdy[200] = "Not Ready:" 
->
PHP Code:
new notrdy[] = "Not Ready:" 
This suggestion is not correct. Maybe you didn't mean to do it, I don't know but it needs to be stated. If you declare it without a dimension it will only be as long as the assigned string (+1 for the terminator). So, in this case in the second php box it would only be 11 cells.
__________________
fysiks is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-21-2011 , 04:13   Re: If false add to hudmessage
Reply With Quote #6

Oh shit, didn't see that he was adding to notrdy later in the code. I thought he made another string to hold the HUD message.

Sorry.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 07-21-2011 , 05:47   Re: If false add to hudmessage
Reply With Quote #7

5 Posts and I didn't get ANYTHING about what I should do to make it work. lol

Ingame it DOES send the hudmessage, but for some wierd reason it gives the server is name, so if the server was named "AlliedModders Pug", then you'd see:

"Not Ready:
AlliedModders Pug"

And that's it, nothing more, and it doesnt get players names who are not ready, just the server name in there.

I tried doing what Kreation said and use in the 'for' a variable that has get_maxplayers(), but didnt help still....

Last edited by Diegorkable; 07-21-2011 at 06:03.
Diegorkable is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 07-21-2011 , 06:26   Re: If false add to hudmessage
Reply With Quote #8

Nvm I fixed it by my own, I just used the function get_players instead, and it worked, for some wierd reason.
Diegorkable is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 07-21-2011 , 12:46   Re: If false add to hudmessage
Reply With Quote #9

Quote:
Originally Posted by Diegorkable View Post
Nvm I fixed it by my own, I just used the function get_players instead, and it worked, for some wierd reason.
Here's what you were doing wrong

get_user_name(g_bIsReady[i], playername, 31)

->

get_user_name( i, playername, 31 )

Otherwise you were putting in a boolean for the first parameter, and I'm not sure why you didn't get a tag mismatch error.
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
Reply


Thread Tools
Display Modes

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 01:05.


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