AlliedModders

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

Crizzatu 07-01-2014 11:18

Native Problem
 
How i can get name days with native? I need to put in hudmessage syntax!

Problem:
Code:

L 07/01/2014 - 14:34:11: [AMXX] Run time error 10 (plugin "jbextream.amxx") (native "get_game") - debug not enabled!
L 07/01/2014 - 14:34:11: [AMXX] To enable debug mode, add "debug" after the plugin name in plugins.ini (without quotes).

Native:
Code:

public native_get_game(){ return gs_DaysList[ gi_WichDay-1 ]
List of Game name:
Code:

new const gs_DaysList[ ][ ] =
{
        "GodMode Day",        // 1
        "Furien Day",        // 2
        "HNS Day",        // 3
        "Nightcrawler Day", // 4
        "Zombie Day",        // 5
        "Spartan Day",        // 6
        "Gravity Day",        // 7
        "Grenade Day",        // 8
        "HNS Simple Day"// 9
};


Flick3rR 07-01-2014 12:30

Re: Native Problem
 
This should not be native. It's better as a stock, I think. (not really sure for the stock, but definately native is not the best) Just replace
PHP Code:

public native_get_game() 

with
PHP Code:

stock get_game() 


Freezo Begin 07-01-2014 12:47

Re: Native Problem
 
Quote:

Originally Posted by Flick3rR (Post 2160353)
This should not be native. It's better as a stock, I think. (not really sure for the stock, but definately native is not the best) Just replace
PHP Code:

public native_get_game() 

with
PHP Code:

stock get_game() 


i think it's the same thing .
Crizzatu did you add register_native ?

Flick3rR 07-01-2014 13:25

Re: Native Problem
 
I don't think he needs natives here, since I guess he is not going to use it in other plugins. Just modifying it to stock will solute the problem. That's why I mentioned, that creating a native is not the best way.

Crizzatu 07-01-2014 14:41

Re: Native Problem
 
What is the best way ?

Flick3rR 07-01-2014 14:49

Re: Native Problem
 
Try with stock. I think it should be the most usefull way, since you don't use it as a native in other plugins.

Crizzatu 07-01-2014 16:30

Re: Native Problem
 
I need with native because i need to put hudmessage name of days in another plugin.

Flick3rR 07-01-2014 16:43

Re: Native Problem
 
You can search at all. But this information helped me alot.
https://forums.alliedmods.net/showthread.php?t=41251

hornet 07-01-2014 21:45

Re: Native Problem
 
Flick3rR please stop posting when you don't know the answer.

@Crizzatu

First ensure that the native is registered correctly:
PHP Code:

public plugin_natives()
{
    
register_native"get_game""native_get_game" ):


Next, you should note that strings canot be returned through natives as they can from usual stocks.
The string will be sent back and passed byref. So here's how it should look:
PHP Code:

public native_get_game(/*iPlugin, iParams*/)
{
    return 
set_string2gs_DaysListget_param)-], get_param) );


To get the name from the other plugin, you would do something like this:
PHP Code:

public SomeFunction()
{
    .
/*
        <^> For example let's get the name of day number 1.
    */
    
    
new szDay32 ];
    
get_game1szDaycharsmaxszDay ) );
    
    
/*
        <^> szDay now holds the day name.
    */
        


Make sure that you have the following inside your include file ( if you have one ), or otherwise in your plugin:

PHP Code:

native get_gameiIndexszName[], iLen ); 



All times are GMT -4. The time now is 21:17.

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