This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

different Price .


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mr.Waffle
Senior Member
Join Date: Dec 2011
Old 01-01-2012 , 00:12   different Price .
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <ColorChat>

new Points[33];

new 
g1Cost;

public 
plugin_init() {
    
register_plugin("PLUGIN""0.1""AUTHOR")
    
    
g1Cost register_cvar"amx_g1Cost""35" )
    
    
register_clcmd("say shop""ShopMenu")
    
register_clcmd("say_team shop""ShopMenu")
    
register_clcmd("say /shop""ShopMenu")
    
register_clcmd("say_team /shop""ShopMenu")
}

public 
ShopMenu(id) {
    if(
cs_get_user_team(id) == CS_TEAM_T) {     
        new 
szText555 char ];    
        
formatexszTextcharsmaxszText ), "shop");

        new 
menu menu_createszText"Sub_ShopMenu" );
    
        
formatexszTextcharsmaxszText ), "option number #1 points: %d"get_pcvar_num(g1Cost));
        
menu_additemmenuszText"1");        
        
        
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
        
menu_displayidmenu);
    }    
    return 
PLUGIN_CONTINUE;
}

public 
Sub_ShopMenuidmenuitem )
{        
    if( 
item == MENU_EXIT ) {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );
    
    new 
key str_to_numdata );    
    switch( 
key ) {
        case 
1:
        {
            if( 
Points[id] < get_pcvar_num(g1Cost) ) {
                
ColorChat(idRED"You dont have enough Points");    
                return 
PLUGIN_HANDLED;
            }
            
//ColorChat(id,RED,"Y")
        
}        
    }
    return 
PLUGIN_HANDLED;        

hello ,
I made a simple shop plugin , now i want to know how can i do that if player bougt the item For the first time its will cost 35 points , and in the next time The same thing will cost him 45 .
thx.

Last edited by Mr.Waffle; 01-01-2012 at 00:12.
Mr.Waffle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-01-2012 , 00:43   Re: different Price .
Reply With Quote #2

You can do something like this:

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <ColorChat>

new Points[33];
new 
g_iCount[33]; // Counts the number of purchases for this the item for each player
new g_iCosts[] = {354555}; // Price of the first, second, and third purchase respectively

public plugin_init()
{
    
register_plugin("PLUGIN""0.1""AUTHOR")
    
    
register_clcmd("say shop""ShopMenu")
    
register_clcmd("say_team shop""ShopMenu")
    
register_clcmd("say /shop""ShopMenu")
    
register_clcmd("say_team /shop""ShopMenu")
}

public 
ShopMenu(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_T)
    {     
        new 
szText[555];    
        
formatexszTextcharsmaxszText ), "shop");

        new 
menu menu_createszText"Sub_ShopMenu" );
    
        
formatexszTextcharsmaxszText ), "option number #1 points: %d"g_iCosts[clamp(g_iCount[id], 0sizeof(g_iCosts) - 1)]);
        
menu_additemmenuszText"1");        
        
        
menu_setpropmenuMPROP_EXITMEXIT_ALL );
    
        
menu_displayidmenu);
    }    
    return 
PLUGIN_CONTINUE;
}

public 
Sub_ShopMenuidmenuitem )
{        
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );
    
    new 
key str_to_numdata );    
    switch( 
key )
    {
        case 
1:
        {
            if( 
Points[id] < g_iCosts[clamp(g_iCount[id], 0sizeof(g_iCosts) - 1)] )
            {
                
ColorChat(idRED"You dont have enough Points");    
                return 
PLUGIN_HANDLED;
            }
            
//ColorChat(id,RED,"Y")
            
g_iCount[id]++ // Increase the purchase count by one.
        
}        
    }
    return 
PLUGIN_HANDLED;        

__________________

Last edited by fysiks; 01-01-2012 at 00:45.
fysiks is offline
Mr.Waffle
Senior Member
Join Date: Dec 2011
Old 01-01-2012 , 06:52   Re: different Price .
Reply With Quote #3

thx , It works great .
I have another question , how can i do the shop gray like "\d" if you dont have enough points.
example:
i have 10 points , and the item on the shop cost 20 points so the line will be in gray . And then when I have 20 the line will be in color.
thx .

Last edited by Mr.Waffle; 01-01-2012 at 06:54.
Mr.Waffle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-01-2012 , 16:57   Re: different Price .
Reply With Quote #4

You need to use callbacks. There is a good post in the new menus tutorial by Exolent that shows how to use them. You would just check the player's points in the callback and return enabled if they can buy it or disabled if they can't.
__________________
fysiks is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-01-2012 , 20:57   Re: different Price .
Reply With Quote #5

@Mr. Waffle

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <ColorChat>

new Points[33];
new 
g_iCount[33]; // Counts the number of purchases for this the item for each player
new g_iCosts[] = {354555}; // Price of the first, second, and third purchase respectively

public plugin_init()
{
    
register_plugin("PLUGIN""0.1""AUTHOR")
    
    
register_clcmd("say shop""ShopMenu")
    
register_clcmd("say_team shop""ShopMenu")
    
register_clcmd("say /shop""ShopMenu")
    
register_clcmd("say_team /shop""ShopMenu")
}

public 
ShopMenu(id)
{
    if(
cs_get_user_team(id) == CS_TEAM_T)
    {     
        new 
szText[555];    
        
formatexszTextcharsmaxszText ), "shop");
        
        new 
menu menu_createszText"Sub_ShopMenu" );
        for(new 
0sizeof(g_iCosts); i++) 
        {
            
formatexszTextcharsmaxszText ), "option number #1 points: %d", (Points[id] >= g_iCosts[i]) ? "\r" "\d"g_iCosts[clamp(g_iCount[id], 0sizeof(g_iCosts) - 1)]);
            
menu_additemmenuszText"1");        
        
            
menu_setpropmenuMPROP_EXITMEXIT_ALL );
        }
        
        
menu_displayidmenu);
    }    
    return 
PLUGIN_CONTINUE;
}

public 
Sub_ShopMenuidmenuitem )
{        
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    new 
data], iName64 ], accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), iNamecharsmaxiName ), callback );
    
    new 
key str_to_numdata );    
    switch( 
key )
    {
        case 
1:
        {
            if( 
Points[id] < g_iCosts[clamp(g_iCount[id], 0sizeof(g_iCosts) - 1)] )
            {
                
ColorChat(idRED"You dont have enough Points");    
                return 
PLUGIN_HANDLED;
            }
            
//ColorChat(id,RED,"Y")
            
g_iCount[id]++ // Increase the purchase count by one.
        
}        
    }
    return 
PLUGIN_HANDLED;        

I'm not sure if it works, but it should work. Let me know if it doesn't.
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-01-2012 , 21:24   Re: different Price .
Reply With Quote #6

Quote:
Originally Posted by Napoleon_be View Post
@Mr. Waffle
I'm not sure if it works, but it should work. Let me know if it doesn't.
No, that is not correct. My suggestion above is all that is needed.
__________________
fysiks is offline
Mr.Waffle
Senior Member
Join Date: Dec 2011
Old 01-02-2012 , 00:00   Re: different Price .
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
You need to use callbacks. There is a good post in the new menus tutorial by Exolent that shows how to use them. You would just check the player's points in the callback and return enabled if they can buy it or disabled if they can't.
i cant find the post /= .
Mr.Waffle is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-02-2012 , 00:45   Re: different Price .
Reply With Quote #8

http://forums.alliedmods.net/showthr...790#post828790
__________________
fysiks 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 23:19.


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