AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Help with saving names (https://forums.alliedmods.net/showthread.php?t=334556)

The overrated maniac 10-03-2021 19:48

Help with saving names
 
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?

fysiks 10-03-2021 20:01

Re: Help with saving names
 
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).

The overrated maniac 10-03-2021 20:31

Re: Help with saving names
 
Quote:

Originally Posted by fysiks (Post 2759543)
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));
        }
    }



fysiks 10-03-2021 21:02

Re: Help with saving names
 
Quote:

Originally Posted by The overrated maniac (Post 2759546)
It shows more characters so it works, but its limited to like 110 characters, I dont understand why.

What?

The overrated maniac 10-03-2021 21:15

Re: Help with saving names
 
Quote:

Originally Posted by fysiks (Post 2759549)
What?

deleted

fysiks 10-03-2021 22:00

Re: Help with saving names
 
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.

The overrated maniac 10-05-2021 06:38

Re: Help with saving names
 
Quote:

Originally Posted by fysiks (Post 2759555)
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


All times are GMT -4. The time now is 11:32.

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