AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Random_num in no specific index forward (https://forums.alliedmods.net/showthread.php?t=292838)

Kotoamatsukami 01-15-2017 12:16

Random_num in no specific index forward
 
Hello, I am trying to pick 1 single client/player to be chosen and get his name and print to the server like "%s name has been chosen!"
PHP Code:

public plugin_init( ) 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event"HLTV""NewRound""a""1=0""2=0" )
    
    
g_Maxplayer get_maxplayers( )
}

public 
NewRound( )
{
    new 
example[32]
    new 
id random_num1sizeof(example) )
    
    for( new 
id 1id <= g_Maxplayerid++ )
    {
        
get_user_nameidexamplecharsmax(example) )
        
        
client_print0print_chat"%s has been chosen!"example )
    }


It's just that I get warning it said I never used the 'id' index inside the loop... Any improvement?

EDIT : I think I should remove the loop?

Craxor 01-15-2017 12:34

Re: Random_num in no specific index forward
 
Test this one:

PHP Code:

#include <amxmodx>

public plugin_init( )
{
    
register_clcmd"say /test" "test" );
}

public 
testid )
{
    new 
szName[32];
    
get_user_nameRandomPlayer() , szNamecharsmaxszName ) );

    
client_printid print_chat"The name of a random players is %s" szName );
}

// Return the ID of a random ALIVE player
RandomPlayer()
{
    new 
Players[32] , Num;

    
get_playersPlayersNum"a" );

    return 
PlayersrandomNum ) ]; 



HamletEagle 01-15-2017 13:54

Re: Random_num in no specific index forward
 
new id = random_num( 1, sizeof(example) )
for( new id = 1;

What do you say about that? Also, better to use get_players.


All times are GMT -4. The time now is 20:56.

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