Raised This Month: $51 Target: $400
 12% 

Shop Menu Tutorial For CS 1.6


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
caked
Member
Join Date: Dec 2012
Old 03-02-2013 , 17:12   Shop Menu Tutorial For CS 1.6
Reply With Quote #1

I need a shop menu tutorial for CS 1.6. I am not sure how to do a shop menu if someone can give me an easy tutorial to start with. And also I couldn't find anything I typed, Shop Menu Tutorial For CS 1.6 and much more and couldnt find it. Im sorry if i wasted your time. I am sure there is a tutorial but I can't find it.

Thank You
caked is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 03-02-2013 , 17:59   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #2

Cash or Shop Credits?

Last edited by Blizzard_87; 03-02-2013 at 18:05.
Blizzard_87 is offline
caked
Member
Join Date: Dec 2012
Old 03-02-2013 , 18:06   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #3

Cash
caked is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 03-02-2013 , 18:40   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #4

just do a menu using the new menu system....

then put your shop items in there....

then in each item case...

add this....

PHP Code:
cs_set_user_money(id, <amount>);
and 
cs_get_user_money(id); 
for example:

PHP Code:

public some_money_thing(id)
{
         new 
money[33] = cs_get_user_money(id);

         
cs_set_user_money(idmoney[id] + <amount>);



then just incorporate this into the menu .... to take away the amount of money the item costs...

dont forget to add a check to see if they have enough money other wise you will get Negative money.
Blizzard_87 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-02-2013 , 19:05   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #5

Quote:
Originally Posted by Blizzard_87 View Post
just do a menu using the new menu system....

then put your shop items in there....

then in each item case...

add this....

PHP Code:
cs_set_user_money(id, <amount>);
and 
cs_get_user_money(id); 
for example:

PHP Code:

public some_money_thing(id)
{
         new 
money[33] = cs_get_user_money(id);

         
cs_set_user_money(idmoney[id] + <amount>);



then just incorporate this into the menu .... to take away the amount of money the item costs...

dont forget to add a check to see if they have enough money other wise you will get Negative money.
Your code is full of mistakes, would be better that you don't try to help unless you have a decent knowledge.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 03-02-2013 , 19:43   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
Your code is full of mistakes, would be better that you don't try to help unless you have a decent knowledge.
mistakes ? i get no errors or warnings in my code

EDIT: quick make of shop menu basic as per caked asked.

PHP Code:
/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "shop tut"
#define VERSION "1.0"
#define AUTHOR "Blizzard"

new cash[33];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /shop""cmdShop"0);
    
}


public 
cmdShop(id)
{

    new 
menu menu_create("\rShop Menu:""cmdShop_handler");
    
    
menu_additem(menu"\wHE Grenade""1"0);
    
menu_additem(menu"\wFlash Grenade""2"0);
    
menu_additem(menu"\wSmoke Grenade""3"0);
    
menu_additem(menu"\wShield""4"0);
    
menu_additem(menu"\wSpeed""5"0);
    
menu_additem(menu"\wGravity""6"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);

    
menu_display(idmenu0);

}

public 
cmdShop_handler(idmenuitem)
{

    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }


    new 
data[6], szName[64];
    new 
accesscallback;

    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    
cash[id] = cs_get_user_money(id);
    
    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought HE Nade");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_hegrenade");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }
        }
        case 
2:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Flash Bang");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_flashbang");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }
        }
        case 
3:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Smoke Nade");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_smokegrenade");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }
        }
        case 
4:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Shield");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_shield");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }    
        }
        case 
5:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Speed");
                
cs_set_user_money(idcash[id] - 300);
                
// Nothing Yet
            
}
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }            
        }
        case 
6:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Gravity");
                
cs_set_user_money(idcash[id] - 300);
                
set_user_gravity(id0.25);
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }            
        }
    }


    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;


Last edited by Blizzard_87; 03-02-2013 at 20:10.
Blizzard_87 is offline
Torge
Veteran Member
Join Date: Oct 2011
Old 03-02-2013 , 20:42   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #7

Quote:
Originally Posted by Blizzard_87 View Post
mistakes ? i get no errors or warnings in my code

EDIT: quick make of shop menu basic as per caked asked.

PHP Code:
/* Plugin generated by AMXX-Studio */

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

#define PLUGIN "shop tut"
#define VERSION "1.0"
#define AUTHOR "Blizzard"

new cash[33];

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /shop""cmdShop"0);
    
}


public 
cmdShop(id)
{

    new 
menu menu_create("\rShop Menu:""cmdShop_handler");
    
    
menu_additem(menu"\wHE Grenade""1"0);
    
menu_additem(menu"\wFlash Grenade""2"0);
    
menu_additem(menu"\wSmoke Grenade""3"0);
    
menu_additem(menu"\wShield""4"0);
    
menu_additem(menu"\wSpeed""5"0);
    
menu_additem(menu"\wGravity""6"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);

    
menu_display(idmenu0);

}

public 
cmdShop_handler(idmenuitem)
{

    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }


    new 
data[6], szName[64];
    new 
accesscallback;

    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);

    
cash[id] = cs_get_user_money(id);
    
    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought HE Nade");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_hegrenade");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }
        }
        case 
2:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Flash Bang");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_flashbang");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }
        }
        case 
3:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Smoke Nade");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_smokegrenade");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }
        }
        case 
4:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Shield");
                
cs_set_user_money(idcash[id] - 300);
                
give_item(id"weapon_shield");
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }    
        }
        case 
5:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Speed");
                
cs_set_user_money(idcash[id] - 300);
                
// Nothing Yet
            
}
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }            
        }
        case 
6:
        {
            if(
cash[id] > 300)
            {
                
client_print(idprint_chat"You Have Bought Gravity");
                
cs_set_user_money(idcash[id] - 300);
                
set_user_gravity(id0.25);
            }
            else {
                
client_print(idprint_chat"You Dont Have Enough Money");
            }            
        }
    }


    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;

He probably said that, cuz you created a array in a function..
Torge is offline
Blizzard_87
Veteran Member
Join Date: Oct 2012
Old 03-02-2013 , 20:45   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #8

Quote:
Originally Posted by Torge View Post
He probably said that, cuz you created a array in a function..
so this above code better? or still wrong... cos it works
Blizzard_87 is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 03-03-2013 , 01:59   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #9

Maybe you want to check out the Shop API from Exolent, its fully documrnted and easy to understand, just search for it.
__________________
Kia is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-03-2013 , 02:53   Re: Shop Menu Tutorial For CS 1.6
Reply With Quote #10

Quote:
Originally Posted by Blizzard_87 View Post
PHP Code:
cash[id] = cs_get_user_money(id);
    
    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
            if(
cash[id] > 300)
            { 
This is now a bit better than following code which was an error :



Quote:
Originally Posted by Blizzard_87 View Post
PHP Code:
public some_money_thing(id)
{
         new 
money[33] = cs_get_user_money(id);

         
cs_set_user_money(idmoney[id] + <amount>);


But there is still no point using an array for this, just do :

new money = cs_get_user_money(id)
if( money > cost )
{


Also, there is no point creating/destroying the menu each time when this menu is static.
Same for key you retrieve from info, just use item instead.


Little example with your 3 first items :
Not that if you implement speed, you have to store wheter player has extra speed or not and to detect when his speed his changed by the game so you can set him again his extra speed.

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>

#define PLUGIN "shop tut"
#define VERSION "1.0"
#define AUTHOR "Blizzard"

new g_shop_menu
new g_iBlinkAcct

new const Cannot_Carry_Anymore[] = "#Cstrike_TitlesTXT_Cannot_Carry_Anymore"

new g_szItems[][] = 
{
    
"HE Grenade",
    
"Flash Grenade",
    
"Smoke Grenade"
}

new 
g_iItemsPrices[] = 
{
    
400,
    
300,
    
400,
}

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say /shop""cmdShop")

    
g_iBlinkAcct get_user_msgid("BlinkAcct")

    
g_shop_menu menu_create("\yShop Menu\R$""handler_ShopMenu")

    new 
szItemName[32]
    for(new 
ii<sizeof(g_szItems) && i<sizeof(g_iItemsPrices); i++)
    {
        
formatex(szItemNamecharsmax(szItemName), "%s\y\R%d"g_szItems], g_iItemsPrices])
        
menu_additem(g_shop_menuszItemName)
    }
    
menu_setprop(g_shop_menuMPROP_NUMBER_COLOR"\w")
}

public 
cmdShop(id)
{
    
menu_display(idg_shop_menu)
}

public 
handler_ShopMenu(idmenuitem)
{
    if( 
item >= && is_user_alive(id) )
    {
        new 
new_money cs_get_user_money(id) - g_iItemsPrices[item]
        if( 
new_money )
        {
            
client_print(idprint_center"#Cstrike_TitlesTXT_Not_Enough_Money")
            
            
message_begin(MSG_ONE_UNRELIABLEg_iBlinkAcct, .player=id)
            {
                
write_byte(2)
            }
            
message_end()
        }

        switch( 
item )
        {
            case 
0:
            {
                if( 
user_has_weapon(idCSW_HEGRENADE) )
                {
                    
client_print(idprint_centerCannot_Carry_Anymore)
                }
                else
                {
                    
give_item(id"weapon_hegrenade")
                    
cs_set_user_money(idnew_money)
                }
            }
            case 
1:
            {
                if( 
cs_get_user_bpammo(idCSW_FLASHBANG) < )
                {
                    
give_item(id"weapon_flashbang")
                    
cs_set_user_money(idnew_money)
                }
                else
                {
                    
client_print(idprint_centerCannot_Carry_Anymore)
                }
            }
            case 
3:
            {
                if( 
user_has_weapon(idCSW_SMOKEGRENADE) )
                {
                    
client_print(idprint_centerCannot_Carry_Anymore)
                }
                else
                {
                    
give_item(id"weapon_smokegrenade")
                    
cs_set_user_money(idnew_money)
                }
            }
        }
    }

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-03-2013 at 03:16.
ConnorMcLeod is offline
Reply



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 11:31.


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