AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved native (https://forums.alliedmods.net/showthread.php?t=331270)

Theodore Bagwell 03-13-2021 02:35

native
 
how can i make a native like this?
PHP Code:

addmenu_hp(const name, const handlerteam

I want to add a menu to the / hp command with this native. Please give an example
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
regsiret_clcmd("say /hp""hpcdm")
}
public 
hpcmd(id)
{
    new 
szText[555 char]
    
formatex(szTextcharsmax(szText), "HP")
    new 
menu menu_create(szText"hp2")
    
    
formatex(szTextchatsmax(szText), "\w 300 HP")
    
menu_additem(szTextmenu"1"0)
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
    return 
PLUGIN_CONTINUE
}
public 
hp2(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );
    
    switch(
key)
    {
        case 
1:
        {
            
set_user_health(id300)
        }
    }
    return 
PLUGIN_HANDLED



fysiks 03-13-2021 03:25

Re: native
 
There is a tutorial for creating your own natives: [TUT] Dynamic / Fake Natives

Theodore Bagwell 03-13-2021 04:16

Re: native
 
Quote:

Originally Posted by fysiks (Post 2740269)
There is a tutorial for creating your own natives: [TUT] Dynamic / Fake Natives

Thank you

CrazY. 03-13-2021 08:33

Re: native
 
Do you really need a native for this? I think something similar to amx_plmenu_bantimes would be a better choice in your case. Take a look at plmenu.sma

Code:
new Array:g_bantimes;

Code:
g_bantimes = ArrayCreate(); // Load up the old default values ArrayPushCell(g_bantimes, 0); ArrayPushCell(g_bantimes, 5); ArrayPushCell(g_bantimes, 10); ArrayPushCell(g_bantimes, 15); ArrayPushCell(g_bantimes, 30); ArrayPushCell(g_bantimes, 45); ArrayPushCell(g_bantimes, 60); register_srvcmd("amx_plmenu_bantimes", "plmenu_setbantimes");

Code:
public plmenu_setbantimes() {     new buff[32];     new args = read_argc();     if (args <= 1)     {         server_print("usage: amx_plmenu_bantimes <time1> [time2] [time3] ...");         server_print("   use time of 0 for permanent.");         return;     }     ArrayClear(g_bantimes);     for (new i = 1; i < args; i++)     {         read_argv(i, buff, charsmax(buff));         ArrayPushCell(g_bantimes, str_to_num(buff));     } }

Theodore Bagwell 03-13-2021 09:26

Re: native
 
Thanks but I really need a native

CrazY. 03-13-2021 11:29

Re: native
 
That link fysiks provided instruct how to use natives. There is also an example plugin in amxmodx/testsuite called native_test.sma. Could you explain what is your doubt?


All times are GMT -4. The time now is 18:35.

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