Raised This Month: $ Target: $400
 0% 

Save String Array


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-11-2021 , 20:07   Re: Save String Array
Reply With Quote #1

I think you're pretty close.
  • The missing part is you need a 2-dimension array so that each players name can be stored. Your current code would make each player overwrite the next.
  • You do not need to use flag 'a' with 1 in set_task() to execute the task once, that is only if you need it triggered/repeated more than once.
  • You want to call remove_task() on client_disconnect, just incase they disconnect between spawn and the 5 second task.

I would recommend you explain what you are trying to accomplish instead of asking questions in code.

PHP Code:
#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

new g_szNameMAX_PLAYERS ][ MAX_NAME_LENGTH ];

public 
fw_spawnClient )
{
    
get_user_nameClient g_szNameClient ] , charsmaxg_szName[] ) );
    
    
set_task5.0 "LoadString" Client );
}

public 
client_disconnectClient 
{
    
remove_taskClient );
}

public 
LoadStringClient )
{
    if ( 
equalg_szNameClient ] , "XSlayer" ))
    {
        
client_printClient print_chat"XSlayer entered the game" );
    }

__________________

Last edited by Bugsy; 12-11-2021 at 20:10.
Bugsy is offline
XSlayer
Member
Join Date: Dec 2021
Old 12-12-2021 , 00:05   Re: Save String Array
Reply With Quote #2

Quote:
Originally Posted by Bugsy View Post
I think you're pretty close.
  • The missing part is you need a 2-dimension array so that each players name can be stored. Your current code would make each player overwrite the next.
  • You do not need to use flag 'a' with 1 in set_task() to execute the task once, that is only if you need it triggered/repeated more than once.
  • You want to call remove_task() on client_disconnect, just incase they disconnect between spawn and the 5 second task.

I would recommend you explain what you are trying to accomplish instead of asking questions in code.

PHP Code:
#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32

new g_szNameMAX_PLAYERS ][ MAX_NAME_LENGTH ];

public 
fw_spawnClient )
{
    
get_user_nameClient g_szNameClient ] , charsmaxg_szName[] ) );
    
    
set_task5.0 "LoadString" Client );
}

public 
client_disconnectClient 
{
    
remove_taskClient );
}

public 
LoadStringClient )
{
    if ( 
equalg_szNameClient ] , "XSlayer" ))
    {
        
client_printClient print_chat"XSlayer entered the game" );
    }

Thanks! and thanks for explaining the reasons why it didn't work, that helps me learn more and supremache too

Last edited by XSlayer; 12-12-2021 at 00:06.
XSlayer 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 11:36.


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