AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   FirstPlugin [hp] (https://forums.alliedmods.net/showthread.php?t=100826)

BigMac 08-18-2009 10:42

FirstPlugin [hp]
 
I can not get the menu to open up there no errors and no log errors can anyone help me so i can see the menu in game Thank you your help!!

PHP Code:

[CODE][HTML]#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <cstrike>
#include <fakemeta>

#define PLUGIN "Health"
#define VERSION "1.0"
#define AUTHOR "Pastout"

new gKeysHealthMenu;
new 
gszHealthMenu[256];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /lucky""show(HealthMenu");
    
createMenus();
    
register_menucmd(register_menuid("HealthMenu"), gKeysHealthMenu"handleHealthMenu");
    
register_cvar("healamount""10.0");
    
register_event("TextMsg""eventRoundRestart""a""2&#Game_C""2&#Game_w");
}

enum
{
    
N1N2N3N4N5N6N7N8N9N0
};

enum
{
    
B1 << N1B2 << N2B3 << N3B4 << N4B5 << N5,
    
B6 << N6B7 << N7B8 << N8B9 << N9B0 << N0,
};

createMenus()
{
    
    
//create main menu
    
new size sizeof(gszHealthMenu);
    
add(gszHealthMenusize"\yHealth Menu^n^n");
    
add(gszHealthMenusize"\r1. \wHP 10^n");
    
add(gszHealthMenusize"\r2. \wHP 20^n");
    
add(gszHealthMenusize"\r3. \wHP 30^n");
    
add(gszHealthMenusize"\r4. \wHP 40^n");
    
add(gszHealthMenusize"\r5. \wHP 50^n");
    
add(gszHealthMenusize"\r6. \wHP 60^n");
    
add(gszHealthMenusize"\r7. \wHP 70^n");
    
add(gszHealthMenusize"\r8. \wHP 80^n");
    
add(gszHealthMenusize"\r9. \wHP 90^n");
    
add(gszHealthMenusize"\r0. \wClose");
    
gKeysHealthMenu B1 B2 B3 B4 B5 B6 B7 B8 B9 B0;
}

public 
showHealthMenu(id)
{
    new 
col[3];
    new 
szMenu[256];
    new 
szHealth[8];
    
    
//format the main menu
    
format(szMenu256gszHealthMenucolszHealthcolszHealthcolszHealthcolszHealthcolszHealth);
    
    
//show the main menu to the player
    
show_menu(idgKeysHealthMenuszMenu, -1"HealthMenu");
    
    return 
PLUGIN_HANDLED;
}

public 
handleHealthMenu(idnum)
{
    switch (
num)
    {
        case 
N1: { Health10(id); }
        case 
N2: { Health20(id); }
        case 
N3: { Health30(id); }
        case 
N4: { Health40(id); }
        case 
N5: { Health50(id); }
        case 
N6: { Health60(id); }
        case 
N7: { Health70(id); }
        case 
N8: { Health80(id); }
        case 
N9: { Health90(id); }
        case 
N0: { return; }
    }
}

Health10(id)
{
    new 
hp get_user_healthid );
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
    
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health20(id)
{
    new 
hp get_user_healthid );
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health30(id)
{
    new 
hp get_user_health(id);
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health40(id)
{
    new 
hp get_user_health(id);
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health50(id)
{
    new 
hp get_user_health(id);
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health60(id)
{
    new 
hp get_user_health(id);
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health70(id)
{
    new 
hp get_user_health(id);
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health80(id)
{
    new 
hp get_user_health(id);
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}

Health90(id)
{
    new 
hp get_user_health(id);
    new 
amount floatround(get_cvar_float("healamount"), floatround_floor);
    new 
sum = (hp amount);
        
    if (
sum 100)
    {
        
set_user_health(idsum);
    }
    else
    {
        
set_user_health(id100);
    }
}[/
HTML][/CODE


Jon 08-18-2009 10:49

Re: FirstPlugin [hp]
 
PHP Code:

    //format the main menu 
    
format(szMenu256gszHealthMenucolszHealthcolszHealthcolszHealthcolszHealthcolszHealth); 
 
    
//show the main menu to the player 
    
show_menu(idgKeysHealthMenuszMenu, -1"HealthMenu"); 

->

PHP Code:

show_menu(idgKeysHealthMenugszHealthMenu -1"HealthMenu"); 

Also, all of your healx(id) funcs will all give the player +10 hp.

xPaw 08-18-2009 10:50

Re: FirstPlugin [hp]
 
Try this.

PHP Code:

#include <amxmodx>
#include <fun>

new gKeysHealthMenu;
new 
gszHealthMenu256 ];

public 
plugin_init( ) {
    
register_clcmd"say /lucky""showHealthMenu" );
    
    
// create menu
    
add(gszHealthMenusizeofgszHealthMenu ), "\yHealth Menu^n^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r1. \wHP 10^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r2. \wHP 20^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r3. \wHP 30^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r4. \wHP 40^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r5. \wHP 50^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r6. \wHP 60^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r7. \wHP 70^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r8. \wHP 80^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r9. \wHP 90^n^n");
    
add(gszHealthMenusizeofgszHealthMenu ), "\r0. \wClose");
    
gKeysHealthMenu MENU_KEY_1 MENU_KEY_2 MENU_KEY_3 MENU_KEY_4 MENU_KEY_5 |
            
MENU_KEY_6 MENU_KEY_7 MENU_KEY_8 MENU_KEY_9 MENU_KEY_0;
    
    
register_menucmdregister_menuid"HealthMenu" ), gKeysHealthMenu"handleHealthMenu" );
}

public 
showHealthMenuid ) {
    if( 
is_user_aliveid ) )
        
show_menuidgKeysHealthMenugszHealthMenu, -1"HealthMenu" );
    
    return 
PLUGIN_HANDLED;
}

public 
handleHealthMenuidiNum ) {
    if( !
is_user_aliveid ) )
        return 
PLUGIN_HANDLED;
    
    if( 
iNum == )
        return 
PLUGIN_HANDLED;
    
    new 
iGiveHp 10 + ( iNum 10 );
    
    
set_user_healthidclampiGiveHp0100 ) );
    
    return 
PLUGIN_HANDLED;



BigMac 08-18-2009 13:13

Re: FirstPlugin [hp]
 
Thanks xPaw works

deadman909 08-18-2009 13:41

Re: FirstPlugin [hp]
 
BigMac what does This Plugin Do Exactly looks kind of Fun. Can you give me a Description of what it does

BigMac 08-18-2009 14:30

Re: FirstPlugin [hp]
 
The Plugin /lucky is where a user could win hp the higher the hp the less chance the user could get it and they can only use it onces per round and or a cvar where they could type /lucky again if they killed someone or another cvar where they kill a person then it ables them to get 10 extra hp , then if they kill another they get 20 hp.etc

My first plugin:)


All times are GMT -4. The time now is 15:09.

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