AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Would need some help. (https://forums.alliedmods.net/showthread.php?t=19493)

DarlD 10-18-2005 00:48

Would need some help.
 
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Buy Health"
#define VERSION "1.0"
#define AUTHOR "Meta"
new mBuyHealth // Menu
new mcbBuyHealth // Menu Callback



public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_menucmd(register_menuid("Buy Health"), keys, "ma_BuyHealth")
        new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
        register_event("Buy Health", "healthmenu", "be")
        /* Menu Buy Health */
        /* Use menu_display(id, mBuyHealth, 0) to show the menu to an user. */
        mBuyHealth = menu_create("Buy Health", "mh_BuyHealth")
        mcbBuyHealth = menu_makecallback("mcb_BuyHealth")
        menu_additem(mBuyHealth, "Buy 10HP - 100$", "ma_BuyHealth", ADMIN_USER, mcbBuyHealth)
        menu_additem(mBuyHealth, "Buy 20HP - 200$", "ma_BuyHealth", ADMIN_USER, mcbBuyHealth)
        menu_additem(mBuyHealth, "Buy 30HP - 300$", "ma_BuyHealth", ADMIN_USER, mcbBuyHealth)
        menu_additem(mBuyHealth, "Buy 40HP - 400$", "ma_BuyHealth", ADMIN_USER, mcbBuyHealth)
        menu_additem(mBuyHealth, "Buy 50HP - 500$", "ma_BuyHealth", ADMIN_USER, mcbBuyHealth)
        menu_additem(mBuyHealth, "Buy 100HP - 1000$", "ma_BuyHealth", ADMIN_USER, mcbBuyHealth)
        menu_additem(mBuyHealth, "Buy 5000HP - 16000$", "ma_BuyHealth", ADMIN_USER, mcbBuyHealth)
        /* Menu End */

        // Add your code here...
       
}


/* Menu Buy Health */

public mh_BuyHealth(id, menu, item) {
        /* This event is called when someone presses a key on this menu */
}

public ma_BuyHealth(id) {
        /* This event is called when an item was selected */
}

public mcb_BuyHealth(id, menu, item) {
        /* This is the callback-event, here you can set items enabled or disabled. */
        /* If you want to enable an item, use: return ITEM_ENABLED */
        /* If you want to disable an item, use: return ITEM_DISABLED */
}
public healthmenu() {
       
        new menu[192]
        new keys = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2
       
        show_menu(id, keys, menu)
    return PLUGIN_HANDLED
}


so basicly im trying to make a menu in order to buy health, right. i think i got all this programing thing ok but im not sure how to set it all up right, im still missing some key things and i know this code is probably total garbage :S but if anyone could show me where i made mistakes that would be really helpfull, thanks

broertje 10-18-2005 14:09

i got this,but how you give the person +...hp and not just set it to ...hp and how you do -....money:
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #define PLUGIN "Buy Health" #define VERSION "1.0" #define AUTHOR "Broertje" public plugin_init() {     register_plugin("Buy Health", "1.0", "Broertje")         register_clcmd("say /buyhealth", "sayHP", 0, "- Show Menu To buy Hp!!!")         register_menucmd(register_menuid("menu_ChooseType"),1023,"ChooseType"); } public sayHP(id) {          new menu[192]     new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)         format(menu, 191, "^n1. Buy 10HP - 100$^n2. Buy 20HP - 200$^n3. Buy 30HP - 300$^n4. Buy 40HP - 400$^n5. Buy 50HP - 500$^n6. Buy 100HP - 1000$")     show_menu(id, keys, menu, -1, "Buy Health:")       return PLUGIN_HANDLED } public giveStuff(id, key)     {         if (key==0)               {         set_user_health(id,+10)         cs_set_user_money(id,-100,1)     }     if (key==1) {         set_user_health(id,+20)         cs_set_user_money(id,-200,1)     }     if (key==2) {         set_user_health(id,+30)         cs_set_user_money(id,-300,1)     }     if (key==3) {         set_user_health(id,+40)         cs_set_user_money(id,-400,1)     }     if (key==4) {         set_user_health(id,+50)         cs_set_user_money(id,-500,1)     }     }     if (key==5) {         set_user_health(id,+100)         cs_set_user_money(id,-1000,1)     }

Xanimos 10-18-2005 14:22

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> //What was the point of this if you dont use it? //#define PLUGIN "Buy Health" //#define VERSION "1.0" //#define AUTHOR "Broertje" public plugin_init() {     register_plugin("Buy Health", "1.0", "Broertje")         register_clcmd("say /buyhealth", "sayHP", 0, "- Show Menu To buy Hp!!!")         register_menucmd(register_menuid("BUY_HEALTH"),1023,"giveStuff"); } public sayHP(id) {     new menu[192]     new keys = (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)         format(menu, 191, "\yBuy Health:^n\w^n1. Buy 10HP - 100$^n2. Buy 20HP - 200$^n3. Buy 30HP - 300$^n4. Buy 40HP - 400$^n5. Buy 50HP - 500$^n6. Buy 100HP - 1000$")     show_menu(id, keys, menu, -1, "BUY_HEALTH")       return PLUGIN_HANDLED } public giveStuff(id, key) {     switch(key)     {         case 0:         {             set_user_health(id,(get_user_health(id)+10))             cs_set_user_money(id,(cs_get_user_money(id)-100),1)         }         case 1:         {             set_user_health(id,(get_user_health(id)+20))             cs_set_user_money(id,(cs_get_user_money(id)-200),1)         }         case 2:         {             set_user_health(id,(get_user_health(id)+30))             cs_set_user_money(id,(cs_get_user_money(id)-300),1)         }         case 3:         {             set_user_health(id,(get_user_health(id)+40))             cs_set_user_money(id,(cs_get_user_money(id)-400),1)         }         case 4:         {             set_user_health(id,(get_user_health(id)+50))             cs_set_user_money(id,(cs_get_user_money(id)-500),1)         }         case 5:         {             set_user_health(id,(get_user_health(id)+100))             cs_set_user_money(id,(cs_get_user_money(id)-1000),1)         }     }     return PLUGIN_HANDLED;    }

Try this one.

broertje 10-18-2005 14:24

thx,EDIT* No Hp Is Getting Added

Xanimos 10-18-2005 14:27

Fixed in post above.

broertje 10-18-2005 14:30

still not working

MistaGee 10-18-2005 14:42

change the above to
Code:
public giveStuff(id, key)     {         server_print("Menu was shot!")     if (key==0)

to see a message on the server console whenever someone uses the menu. Lets you know that the function is called at all, I once have had this prob myself...

Greetz MGee

Xanimos 10-18-2005 14:45

Newest edit should work. I changed his functions around and fixed some errors in his code.

broertje 10-19-2005 09:58

Now It Works,Thx,hehe i'm getting better :roll:

DarlD 10-19-2005 10:08

it might work. but players can buy when they dont have the money!


All times are GMT -4. The time now is 23:52.

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