Raised This Month: $ Target: $400
 0% 

Random_num in no specific index forward


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kotoamatsukami
Member
Join Date: Jan 2017
Location: Malaysia
Old 01-15-2017 , 12:16   Random_num in no specific index forward
Reply With Quote #1

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?

Last edited by Kotoamatsukami; 01-15-2017 at 12:21.
Kotoamatsukami is offline
Craxor
Veteran Member
Join Date: Jan 2016
Location: Romania
Old 01-15-2017 , 12:34   Re: Random_num in no specific index forward
Reply With Quote #2

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 ) ]; 

__________________
Project: Among Us

Last edited by Craxor; 01-15-2017 at 12:37.
Craxor is offline
Send a message via ICQ to Craxor
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-15-2017 , 13:54   Re: Random_num in no specific index forward
Reply With Quote #3

new id = random_num( 1, sizeof(example) )
for( new id = 1;

What do you say about that? Also, better to use get_players.
__________________
HamletEagle is offline
Reply



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 20:56.


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