Raised This Month: $ Target: $400
 0% 

Keep List of players with details!


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
johnally
Member
Join Date: May 2011
Location: Mauritius
Old 05-10-2011 , 14:41   Keep List of players with details!
Reply With Quote #1

I am trying to keep the list of players in my server with details on them as follows:
PHP Code:
playerName newplayerName IP address 
I initialized a 2d array as follows:
PHP Code:
new players[32][3]; 
The Functions are pretty self explanatory:
PHP Code:
// ----------------------------------------------------------------------------
// ------------------------Add details to playerlist---------------------------
public add_players(id) { 
    new 
ip[16];
    new 
playerName[32]
    
    
// Get the name and ip
    
get_user_name(idplayerName31);
    
get_user_ip(idip151/*no port*/);
    
    
// Add these to our array using id as key
    
format(players[id 1][0], strlen(playerName), "%s"playerName);
    
format(players[id 1][1], strlen(playerName), "%s"playerName);
    
format(players[id 1][2], 15"%s"ip);
}
// ----------------------------------------------------------------------------
// -----------------------Record new name for Player---------------------------
public client_infochanged(id) {      
    new 
new_name[32];
    new 
old_name[32];
    
    
get_user_info(id"name"new_name31);
    
get_user_name(idold_name31);
    
    if(!
equal(new_nameold_name)){
        
// Put his new name in details :)
        
format(players[id 1][1], sizeof(new_name), "%s"new_name);
    }
}
// ----------------------------------------------------------------------------
// -----------------------Delete old player details---------------------------
public del_players(id) {      
    
format(players[id 1][0], 32"[none]");
    
format(players[id 1][1], 32"[none]");
    
format(players[id 1][2], 16"PLAYER_LEFT");
}
// ----------------------------------------------------------------------------
// --------------------Detect when a client disconnects-------------------------
public client_disconnect(id) {
    
del_players(id);
}
// ----------------------------------------------------------------------------
// --------------------List all players on server :)-------------------------
public list_players(id) {
    
client_print(idprint_chat"Check console for Players' Details")
    for (new 
i=0i<sizeof(players); i++)
    {
        
console_print(id"%s : %s : %s"players[i][0], players[i][1], players[i][2])
    }

My issue is when I call list_players as clcmd (client command e.g "say /players"), I get the following output in the players console:
PHP Code:
tt127.0.0.1 t127.0.0.1 127.0.0.1
27.0.0.1 
7.0.0.1 .0.0.1
0.0.1 
.0.1 0.1
.1 

 :  : 
 :  : 
Why does the output appear so strangely? Am I doing something wrong?

The ideal output I'm needing should be:
PHP Code:
test123 test123 127.0.0.1 
Thanks guys..
__________________
No allowed!


Last edited by johnally; 05-10-2011 at 14:46.
johnally is offline
 


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 04:23.


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