AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   worst player - server name. Why? (https://forums.alliedmods.net/showthread.php?t=147704)

mati009988 01-12-2011 14:54

worst player - server name. Why?
 
Why it show server name?
How to fix it?


PHP Code:

public RoundEnd()
{
    new 
name[34]
    new 
worstplayerworstscore
    
    
for(new isizeof(Kills); i++)
    {
        if(
Kills[i] < worstscore)
        {
        if(
get_user_team(i) == || get_user_team(i) == 2){
            
worstplayer i
            worstscore 
Kills[i]
        }
        return 
PLUGIN_CONTINUE
        
}
    }
    
    
get_user_name(worstplayername33)

    
client_print(0print_chat"The worst player is: %s ^nKills: %i"nameworstscore)
    return 
PLUGIN_CONTINUE



GXLZPGX 01-12-2011 16:00

Re: worst player - server name. Why?
 
Quote:

Originally Posted by mati009988 (Post 1392183)
Why it show server name?
How to fix it?


PHP Code:

public RoundEnd()
{
    new 
name[34]
    new 
worstplayerworstscore
    
    
for(new isizeof(Kills); i++)
    {
        if(
Kills[i] < worstscore)
        {
        if(
get_user_team(i) == || get_user_team(i) == 2){
            
worstplayer i
            worstscore 
Kills[i]
        }
        return 
PLUGIN_CONTINUE
        
}
    }
    
    
get_user_name(worstplayername33)

    
client_print(0print_chat"The worst player is: %s ^nKills: %i"nameworstscore)
    return 
PLUGIN_CONTINUE



#1: A name can store a maximum of 31 characters. Change the amount of arrays to 32.
#2: The way it's set up, "i" could be greater than the maximum of 32 players allowed in a server. So I wouldn't be surprised if you got errors in the logs.
#3: Even if you set up #2 correctly, the value of "worstplayer" is being changed constantly. So no matter what, it would always return the last player it looped to.

nikhilgupta345 01-12-2011 16:56

Re: worst player - server name. Why?
 
for(new i; i > sizeof(Kills); i++)

should be

for(new i; i < sizeof(Kills); i++)


Also, when worstscore is made, then worstscore is automatically set to 0. Usually most people don't have a score less than 0. So what I think you should do is set worstscore to Kills[0] beforehand.

drekes 01-12-2011 17:15

Re: worst player - server name. Why?
 
Try something like this:
PHP Code:

new g_MaxPlayers;

public 
plugin_init()
    
g_MaxPlayers get_players();
    
public 
RoundEnd()
{    
    new 
worstplayerworstscore;
    
    for(new 
1g_MaxPlayersi++)
    {
        if(
is_user_connected(i) && worstscore && Kills[i] < worstscore)
        {
            switch(
get_user_team(i))
            {
                case 
12:
                {
                    
worstplayer i;
                    
worstscore Kills[i];
                }
            }
        }
    }
    
    new 
name[32];
    
get_user_name(worstplayernamecharsmax(name));
    
    
client_print(0print_chat"The worst player is: %s"name);
    
client_print(0print_chat"Kills: %i"worstscore);



nikhilgupta345 01-12-2011 17:59

Re: worst player - server name. Why?
 
PHP Code:

new g_MaxPlayers;

public 
plugin_init()
    
g_MaxPlayers get_players();
    
public 
RoundEnd()
{    
    new 
worstplayer 1worstscore Kills[1];
    
    for(new 
1g_MaxPlayersi++)
    {
        if(
is_user_connected(i) && worstscore && Kills[i] < worstscore)
        {
            switch(
get_user_team(i))
            {
                case 
12:
                {
                    
worstplayer i;
                    
worstscore Kills[i];
                }
            }
        }
    }
    
    new 
name[32];
    
get_user_name(worstplayernamecharsmax(name));
    
    
client_print(0print_chat"The worst player is: %s"name);
    
client_print(0print_chat"Kills: %i"worstscore);


I think that should work :/


All times are GMT -4. The time now is 02:09.

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