Raised This Month: $ Target: $400
 0% 

Problem with dynamic function in other sma.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wangningyu
Member
Join Date: Dec 2011
Location: China.GuangDong
Old 02-23-2012 , 12:46   Problem with dynamic function in other sma.
Reply With Quote #1

Hello ,here is the mainplugin,like this:

LoginSystem.inc

PHP Code:
#pragma reqlib "LoginSystem"

/*
    user access type
*/
enum
{
    
MT_UNLOGIN 0,   // unRegister
    
MT_NORMAL  1,   // Normal player
    
MT_VIP1  2,     // vip1
    
MT_VIP2  3,     // vip2
    
MT_VIP3  4,     // vip3
    
MT_OP    5      // OP
};

/*
  export function
*/
native get_user_type(id
LoginSystem.sma

when call the client_connect(id), I will find the access type from the mysql ,then call client_text_color said :"Hello ,welcome [vip1] name !"....

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <LoginSystem.inc>

/*****************************************************************
enum
{
    MT_UNLOGIN = 0,   // unRegister
    MT_NORMAL  = 1,   // Normal player
    MT_VIP1  = 1,     // vip1
    MT_VIP2  = 2,     // vip2
    MT_VIP3  = 3,     // vip3
    MT_OP    = 4      // OP
};
*****************************************************************/

new userType[33]

public 
plugin_init()
{
    
register_plugin(PLUGIN_NAMEVERSIONAUTHOR)
}

public 
plugin_natives()
{
    
register_library("LoginSystem")
    
register_native("get_user_type","_get_user_type")
}

public 
_get_user_type(id)
{
    new 
type userType[id]
    
client_print(id,print_console,"get id= %d, get type = %d",id,type)
    return 
type


and then , I use the function in other sma files:

get_user_type(id) , it also return 0.(unRegister)

But in LoginSystem.sma, it normal show vip1 or vip2 and more.

I find this note:

[TUT] Dynamic / Fake Natives


and I carefully contrast this, is all the same way.

why isn't right?
__________________
One Code , One Dream !
wangningyu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-23-2012 , 12:49   Re: Problem with dynamic function in other sma.
Reply With Quote #2

You use the old style in the header of the native callback when you register such native with the new style.

http://www.amxmodx.org/funcwiki.php?go=func&id=821
__________________
Arkshine is offline
wangningyu
Member
Join Date: Dec 2011
Location: China.GuangDong
Old 02-23-2012 , 12:55   Re: Problem with dynamic function in other sma.
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
You use the old style in the header of the native callback when you register such native with the new style.

http://www.amxmodx.org/funcwiki.php?go=func&id=821

Thanks !

I know the mean ,beacause it must used get_param(1) to get the ID .

__________________
One Code , One Dream !

Last edited by wangningyu; 02-23-2012 at 12:56.
wangningyu 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 16:25.


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