AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Make script better. "Just Joined" (https://forums.alliedmods.net/showthread.php?t=201501)

xOscar 11-22-2012 20:26

Make script better. "Just Joined"
 
Hey, I wonder how to make this script even better!
When a player joins, it should print to server console.

PHP Code:

#include < amxmodx >
#include < amxmisc >

#define PLUGIN "justJoined"
#define VERSION "0.1"

public plugin_init() {
    
register_plugin(PLUGINVERSION"Blend");
}

public 
client_putinserver(id) {
    new 
szSteamID[32];
    new 
szName[32];
    new 
szStatus[32];
    
    if (
is_user_admin(id))
        
status "[ADMIN]";
    else
        
status "[USER]";
    
    
get_user_authid(idszSteamIDcharsmax(szSteamID));
    
get_user_name(id,szName,31);
    
server_print("---^n--- Name: %s - SteamID: %s, just joined %s^n---"szNameszSteamIDszStatus);


Updated Code (Compiling without errors)
PHP Code:

#include < amxmodx >
#include < amxmisc >

#define PLUGIN "justJoined"
#define VERSION "0.1"

public plugin_init()
    
register_plugin(PLUGINVERSION"Blend");

public 
client_putinserver(id){
    new 
szName[32];
    new 
szStatus[8];
    new 
szSteamID[22];
    new 
szIp[16];

    
get_user_authid(idszSteamIDcharsmax(szSteamID));
    
get_user_name(idszNamecharsmax(szName));
    
get_user_ip(idszIpcharsmax(szIp), 1);
    
formatex(szStatuscharsmax(szStatus), "%s"is_user_admin(id) ? "ADMIN" "USER");
    
server_print("] Name: %s [%s]^n] SteamID: %s^n] IP: %s"szNameszStatusszSteamIDszIp);


Description: Printing out Player Name, SteamID & IP to the servers console when a player is put in to server.
Also the Access-Status.. ADMIN / USER

EDUTz 11-23-2012 03:51

Re: Make script better. "Just Joined"
 
Maybe like this ?

Code:

#include < amxmodx >
#include < amxmisc >

#define PLUGIN "justJoined"
#define VERSION "0.1"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, "Blend");
}

public client_putinserver(id) {
    if (is_user_admin(id))
            server_print("---^n--- Name: %s - SteamID: %s, just joined [ADMIN]^n---", get_user_name(id), get_user_authid(id));
    else
            server_print("---^n--- Name: %s - SteamID: %s, just joined [USER]^n---", get_user_name(id), get_user_authid(id));

}


pokemonmaster 11-23-2012 04:32

Re: Make script better. "Just Joined"
 
Quote:

Originally Posted by EDUTz (Post 1842288)
Maybe like this ?

Code:

#include < amxmodx >
#include < amxmisc >

#define PLUGIN "justJoined"
#define VERSION "0.1"

public plugin_init() {
    register_plugin(PLUGIN, VERSION, "Blend");
}

public client_putinserver(id) {
    if (is_user_admin(id))
            server_print("---^n--- Name: %s - SteamID: %s, just joined [ADMIN]^n---", get_user_name(id), get_user_authid(id));
    else
            server_print("---^n--- Name: %s - SteamID: %s, just joined [USER]^n---", get_user_name(id), get_user_authid(id));

}


Totally wrong.
The first one was the best

jimaway 11-23-2012 05:05

Re: Make script better. "Just Joined"
 
Code:
new szStatus[32];         if (is_user_admin(id))         status = "[ADMIN]";     else         status = "[USER]";
->
Code:
new szStatus[8]; //no point in making this array bigger than you will ever use formatex(szStatus, charsmax(szStatus), "%s", is_user_admin(id) ? "[ADMIN]" : "[USER]");

xOscar 11-23-2012 05:34

Re: Make script better. "Just Joined"
 
Thanks for help, I would appreciate more help!

PHP Code:

#include < amxmodx >
#include < amxmisc >

#define PLUGIN "justJoined"
#define VERSION "0.1"

public plugin_init() {
    
register_plugin(PLUGINVERSION"Blend");
}

public 
client_putinserver(id) {
    new 
szSteamID[32];
    new 
szName[32];
    new 
szStatus[8];
    new 
szIp[32];

    
get_user_authid(idszSteamIDcharsmax(szSteamID));
    
get_user_name(id,szName,31);
    
get_user_ip(idszIp311);
    
formatex(szStatuscharsmax(szStatus), "%s"is_user_admin(id) ? "[ADMIN]" "[USER]");
    
server_print("[] Name: %s - SteamID: %s - IP: %s ^n[] %s"szNameszSteamIDszIpszStatus);



jimaway 11-23-2012 06:04

Re: Make script better. "Just Joined"
 
new szIp[32];
->
new szIp[16];

why do you want to create every array with size 32? a ipv4 address cant be over 15 charecters

xOscar 11-23-2012 07:53

Re: Make script better. "Just Joined"
 
Quote:

Originally Posted by jimaway (Post 1842316)
new szIp[32];
->
new szIp[16];

why do you want to create every array with size 32? a ipv4 address cant be over 15 charecters

A habit xD
Well, thanks for your help.

One question, why can't you make every array like 512? ( :) )

xOscar 11-23-2012 10:00

Re: Make script better. "Just Joined"
 
Why not make szName[32] -> szName[16] ?

YamiKaitou 11-23-2012 10:14

Re: Make script better. "Just Joined"
 
Because that is the max length of a name

xClient 11-23-2012 10:44

Re: Make script better. "Just Joined"
 
Quote:

Originally Posted by YamiKaitou (Post 1842370)
Because that is the max length of a name

szSteamID[32]; -> szSteamID[8]; then?


All times are GMT -4. The time now is 03:57.

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