Raised This Month: $32 Target: $400
 8% 

Solved native


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Theodore Bagwell
Member
Join Date: Jan 2021
Location: USA
Old 03-13-2021 , 02:35   native
#1

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


Last edited by asherkin; 03-13-2021 at 15:16. Reason: Restore to previous version.
Theodore Bagwell is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-13-2021 , 03:25   Re: native
#2

There is a tutorial for creating your own natives: [TUT] Dynamic / Fake Natives
__________________
fysiks is offline
Theodore Bagwell
Member
Join Date: Jan 2021
Location: USA
Old 03-13-2021 , 04:16   Re: native
#3

Quote:
Originally Posted by fysiks View Post
There is a tutorial for creating your own natives: [TUT] Dynamic / Fake Natives
Thank you

Last edited by Theodore Bagwell; 03-13-2021 at 14:07.
Theodore Bagwell is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 03-13-2021 , 08:33   Re: native
#4

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));     } }
__________________









Last edited by CrazY.; 03-13-2021 at 08:34.
CrazY. is offline
Theodore Bagwell
Member
Join Date: Jan 2021
Location: USA
Old 03-13-2021 , 09:26   Re: native
#5

Thanks but I really need a native
Theodore Bagwell is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 03-13-2021 , 11:29   Re: native
#6

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








CrazY. is offline
Closed Thread


Thread Tools
Display Modes

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 00:04.


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