AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Hostname (https://forums.alliedmods.net/showthread.php?t=160119)

Artifact 06-25-2011 09:17

Hostname
 
How to include hostname??

Example:
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

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


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
client_connect(id)
{
    
client_print(idprint_chat"Welcome to hostname")
    return 
PLUGIN_HANDLED



drekes 06-25-2011 09:19

Re: Hostname
 
PHP Code:

new g_cHostName;

public 
plugin_init()
    
g_cHostName get_cvar_pointer("hostname");


public 
Something()
{
    new 
szHostname[35];
    
get_pcvar_string(g_cHostnameszHostnamecharsmax(szHostname));
    
client_print(0print_chat"Welcome to %s"szHostname);



Artifact 07-11-2011 04:23

Re: Hostname
 
PHP Code:

get_pcvar_pointer 

???

I know for get_cvar_pointer... But this is not exist...
Code:

Error: Undefined symbol "get_pcvar_pointer" on line 17

NiHiLaNTh 07-11-2011 04:47

Re: Hostname
 
It should be
Code:

get_cvar_pointer 



jimaway 07-11-2011 05:50

Re: Hostname
 
Quote:

Originally Posted by NiHiLaNTh (Post 1508307)
It should be
Code:

get_cvar_pointer 



no it shouldnt, get_cvar_pointer doesent exist, since get_cvar_* and set_cvar_* dont use pointers

Exolent[jNr] 07-11-2011 05:54

Re: Hostname
 
Quote:

Originally Posted by BodyBuilder (Post 1508319)
PHP Code:

new hostname[64]
get_cvar_string("hostname",hostname,63)
client_print(idprint_chat"Welcome to %s",hostname


Pcvars are much faster and should be used if the cvar is to be used more than once for the map.

Quote:

Originally Posted by jimaway (Post 1508333)
no it shouldnt, get_cvar_pointer doesent exist, since get_cvar_* and set_cvar_* dont use pointers

Actually, it does exist.
It is used to get an existing cvar's pointer.
You can also get a cvar's pointer by registering it.
Cvar pointers (Pcvars) are much faster than normal cvars because it removes the cvar pointer lookup when using the functions.

drekes 07-11-2011 06:34

Re: Hostname
 
Fixed my code above.


All times are GMT -4. The time now is 23:29.

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