AlliedModders

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

griefhy 12-21-2008 08:08

About register_native
 
plugin A.sma
PHP Code:

public plugin_natives()
{
    
register_native("user_name","native_user_name",1)
}

public 
native_user_name(id)
{
    new 
name[32];
    
get_user_name(id,name,31);
    return 
name;


plugin B.sma
PHP Code:

public client_putinserver(id)
{
    ?????????
user_name(id)???????????????
    
client_print(id,??????????)


it's fail, is it impossible? Where is it wrong? Please give us your comments. thanks.

hzqst 12-21-2008 08:15

Re: About register_native
 
public native_user_name(id, const name[], len){
get_user_name(id,name,len)
return
name
}


new name[32]
user_name(id, name, 31)

Dr.G 12-21-2008 08:19

Re: About register_native
 
a native is atully... a native... iam not 100% sure i get what u are looking for... but if u want the server to print the client name on connect do it like this:

PHP Code:

public client_putinserver(id)
{
 new 
name[32
 
get_user_name(id,name,31)
 
client_print(0,print_chat"Lets all say welcome to %s"name)



hzqst 12-21-2008 08:21

Re: About register_native
 
maybe he doesn't like amxx module...

griefhy 12-21-2008 08:54

Re: About register_native
 
Thanks #3 and #4,
I hope to draw inferences about other cases from one instance .

Quote:

Originally Posted by hzqst (Post 730791)
public native_user_name(id, const name[], len){
get_user_name(id,name,len)
return
name
}


new name[32]
user_name(id, name, 31)

I do,I suspect it is impossible,Because can not show.

hleV 12-21-2008 09:46

Re: About register_native
 
Maybe this.
Code:
public plugin_init()         register_native("user_name", "native_user_name");   public native_user_name() {         new szName[32];         get_user_name(get_param(1), szName, 31);           return szName; // Not sure about this }   public client_putinserver(id)         client_print(0, print_chat, "%s has joined the server", user_name(id));

Spunky 12-21-2008 14:34

Re: About register_native
 
Is your native included in the other file from an .inc?

griefhy 12-21-2008 22:05

Re: About register_native
 
Reply #6

thanks,But has not reacted !!!
Is it really impossible?

Reply #7
yes,included.

danielkza 12-21-2008 22:09

Re: About register_native
 
You register the native in plugin_natives, not in plugin_int. And, also in plugin_natives, don't forget to do 'register_library("your_lib_name")', otherwise plugins requesting your lib will fail to load.

Exolent[jNr] 12-21-2008 22:24

Re: About register_native
 
I don't think you can return arrays with dynamic natives.
However, you can do this:

Code:
#include <amxmodx> public plugin_natives() {     register_library("username");     register_native("user_name", "_user_name"); } public _user_name(plugin, params) {     new client = get_param(1);     if( !is_user_connected(client) ) return;         static name[32];     get_user_name(client, name, sizeof(name) - 1);         set_array(2, name, get_param(3)); }

Code:
// username.inc #if defined _username_included     #endinput #endif #define _username_included #pragma library "username" native user_name(client, name[], len);

Code:
#include <amxmodx> #include <username> function(client) {     static name[32];     user_name(client, name, sizeof(name) - 1); }


All times are GMT -4. The time now is 09:12.

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