AlliedModders

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

Sanjay Singh 01-13-2020 03:41

natives
 
how to can I forward variable data to another plugin using native?

I want to forward
PHP Code:

lastmap
lastmod
[0]
currentmod 

so i can use it like in other plugin
PHP Code:

getcurrentmod() 
getcurrentmap()
getlastmod() 


HamletEagle 01-13-2020 04:15

Re: natives
 
Start by reading the tutorial about natives made by Hawk.

Sanjay Singh 01-13-2020 04:49

Re: natives
 
Quote:

Originally Posted by HamletEagle (Post 2680015)
Start by reading the tutorial about natives made by Hawk.

I tried creating natives but in this case when i use native and my other plugin it shows
PHP Code:

error argument mismatch 


HamletEagle 01-13-2020 06:23

Re: natives
 
Did it occur to you that you should post what you tried so we can see what is wrong and fix it?

Sanjay Singh 01-13-2020 07:59

Re: natives
 
PHP Code:

public plugin_natives()
{
    
register_library("multimod");
    
register_native("mm_get_currentmod""native_mm_get_currentmod");
    
register_native("mm_get_currentmap""native_mm_get_currentmap");
    
register_native("mm_get_lastmod""native_mm_get_lastmod");
    
register_native("mm_get_lastmap""native_mm_get_lastmap");


public 
native_mm_get_currentmod()
{
    return 
g_currentmod;
}

public 
native_mm_get_currentmap()
{
    return 
g_currentmap;
}

public 
native_mm_get_lastmod()
{
    return 
g_lastmods[0];
}

public 
native_mm_get_lastmap()
{
    return 
g_lastmap;


include
PHP Code:

#pragma reqlib "multimod"

native mm_get_currentmod();
native mm_get_currentmap();
native mm_get_lastmod();
native mm_get_lastmap(); 

SubPlugin
PHP Code:

#include <multimod>

client_print_color(id0"Current Mod: %s"mm_get_currentmod()); 


HamletEagle 01-13-2020 09:21

Re: natives
 
Post the definitions for g_currentmod, g_currentmap, g_lastmods, g_lastmap. I suspect all of this are strings(arrays) and you can't pass them around like you are trying to.

You should use set_array to achieve that functionality.

OciXCrom 01-13-2020 14:26

Re: natives
 
Also, I'm pretty sure "#pragma reqlib" is no longer required. You should instead do the same as the default AMXX .inc files:

Code:
#if defined _multimod_included     #endinput #endif #define _multimod_included

This will prevent the file from getting included multiple times, even though it's not likely to happen.

Natsheh 01-14-2020 00:42

Re: natives
 
If you are sharing integers or float AKA double values variables. you can share them with xvar natives by declaring the variables with public.

Here is a tutorial on how to achieve that.


All times are GMT -4. The time now is 11:47.

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