Raised This Month: $51 Target: $400
 12% 

Solved Help with saving names


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 10-03-2021 , 19:48   Help with saving names
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new names[5000], g_maxplayers;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say hello""hello");
    
g_maxplayers get_maxplayers();
}

public 
hello(id){
    
    
client_print(idprint_console"%s"names);
}

public 
event_round_start(){
    for(new 
ii<g_maxplayersi++){
        if(
is_user_connected(i)){
            new 
name[32]; get_user_name(iname31);
            
formatex(namescharsmax(names), "%s"name);
        }
    }

I want to show all the names saved on "names", but instead I only get the last name.
How can I do something like "names += name" with this?

Last edited by The overrated maniac; 10-05-2021 at 06:38.
The overrated maniac is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-03-2021 , 20:01   Re: Help with saving names
Reply With Quote #2

There are many ways to do it but the simplest is add() provided that you don't actually need to do any formatting (which you're not currently doing anyways).
__________________
fysiks is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 10-03-2021 , 20:31   Re: Help with saving names
Reply With Quote #3

Quote:
Originally Posted by fysiks View Post
There are many ways to do it but the simplest is add() provided that you don't actually need to do any formatting (which you're not currently doing anyways).
It shows more characters so it works, but its limited to like 110 characters, I dont understand why.
I added formatex in this example to show what I'm doing in a bigger plugin

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

new names[5000], g_maxplayers;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say hello""hello");
    
g_maxplayers get_maxplayers();
}

public 
hello(id){
    
    
client_print(idprint_console"%s"names);
}

public 
event_round_start(){
    for(new 
ii<g_maxplayersi++){
        if(
is_user_connected(i)){
            new 
name[32], asd[5000];
                        
get_user_name(iname31);
            
            
formatex(asdcharsmax(asd), "%s"name);
            
add(namescharsmax(names), asdcharsmax(asd));
        }
    }


Last edited by The overrated maniac; 10-03-2021 at 20:34.
The overrated maniac is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-03-2021 , 21:02   Re: Help with saving names
Reply With Quote #4

Quote:
Originally Posted by The overrated maniac View Post
It shows more characters so it works, but its limited to like 110 characters, I dont understand why.
What?
__________________
fysiks is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 10-03-2021 , 21:15   Re: Help with saving names
Reply With Quote #5

Quote:
Originally Posted by fysiks View Post
What?
deleted

Last edited by The overrated maniac; 10-05-2021 at 06:39.
The overrated maniac is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-03-2021 , 22:00   Re: Help with saving names
Reply With Quote #6

Yeah, you're not going to be able to print that long of string to a player. If you want to print each line separately for example how it's done with amx_who.
__________________

Last edited by fysiks; 10-03-2021 at 22:02.
fysiks is offline
The overrated maniac
Member
Join Date: Jun 2021
Location: Argentina
Old 10-05-2021 , 06:38   Re: Help with saving names
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Yeah, you're not going to be able to print that long of string to a player. If you want to print each line separately for example how it's done with amx_who.
Done, thanks
The overrated maniac 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 10:22.


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