AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   If false add to hudmessage (https://forums.alliedmods.net/showthread.php?t=162600)

Diegorkable 07-20-2011 20:48

If false add to hudmessage
 
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!

nikhilgupta345 07-20-2011 21:11

Re: If false add to hudmessage
 
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.

Kreation 07-20-2011 21:14

Re: If false add to hudmessage
 
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

nikhilgupta345 07-20-2011 21:22

Re: If false add to hudmessage
 
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)

fysiks 07-21-2011 03:43

Re: If false add to hudmessage
 
Quote:

Originally Posted by nikhilgupta345 (Post 1514971)
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.

nikhilgupta345 07-21-2011 04:13

Re: If false add to hudmessage
 
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.

Diegorkable 07-21-2011 05:47

Re: If false add to hudmessage
 
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....

Diegorkable 07-21-2011 06:26

Re: If false add to hudmessage
 
Nvm I fixed it by my own, I just used the function get_players instead, and it worked, for some wierd reason.

nikhilgupta345 07-21-2011 12:46

Re: If false add to hudmessage
 
Quote:

Originally Posted by Diegorkable (Post 1515166)
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.


All times are GMT -4. The time now is 01:05.

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