Raised This Month: $ Target: $400
 0% 

About register_native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
griefhy
Member
Join Date: Jul 2006
Old 12-21-2008 , 08:08   About register_native
Reply With Quote #1

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.
griefhy is offline
hzqst
Senior Member
Join Date: Jul 2008
Old 12-21-2008 , 08:15   Re: About register_native
Reply With Quote #2

public native_user_name(id, const name[], len){
get_user_name(id,name,len)
return
name
}


new name[32]
user_name(id, name, 31)
hzqst is offline
Dr.G
Senior Member
Join Date: Nov 2008
Old 12-21-2008 , 08:19   Re: About register_native
Reply With Quote #3

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)

Dr.G is offline
hzqst
Senior Member
Join Date: Jul 2008
Old 12-21-2008 , 08:21   Re: About register_native
Reply With Quote #4

maybe he doesn't like amxx module...
hzqst is offline
griefhy
Member
Join Date: Jul 2006
Old 12-21-2008 , 08:54   Re: About register_native
Reply With Quote #5

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

Quote:
Originally Posted by hzqst View Post
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.
griefhy is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 12-21-2008 , 09:46   Re: About register_native
Reply With Quote #6

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));
__________________
hleV is offline
Spunky
Senior Member
Join Date: May 2008
Location: Orlando, Fl.
Old 12-21-2008 , 14:34   Re: About register_native
Reply With Quote #7

Is your native included in the other file from an .inc?
Spunky is offline
Send a message via AIM to Spunky
griefhy
Member
Join Date: Jul 2006
Old 12-21-2008 , 22:05   Re: About register_native
Reply With Quote #8

Reply #6

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

Reply #7
yes,included.
griefhy is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 12-21-2008 , 22:09   Re: About register_native
Reply With Quote #9

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.
__________________

Community / No support through PM
danielkza is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-21-2008 , 22:24   Re: About register_native
Reply With Quote #10

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); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 12-22-2008 at 13:14.
Exolent[jNr] 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 09:12.


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