AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Solved Limit (https://forums.alliedmods.net/showthread.php?t=329126)

ho83 12-09-2020 19:24

Limit
 
Hi i like this menu can use:
Quote:

1.item1 can use 2 time in round
2.item2 can use 3time in round
Code:
PHP Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fun>
#include <hamsandwich>

#define PLUGIN " Shop"
#define VERSION "1.0"
#define AUTHOR "mmd" 

#define ADMIN_JBVIP ADMIN_LEVEL_F

new const PREFIX[] = { "!g[!tShop!g]!n" };

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
register_clcmd("say /shop""Vipshop");
}

public 
Vipshop(id)
{
    if(!(
get_user_flags(id) & ADMIN_JBVIP))
    {
        
client_printc(id"!tYou dont Have access")
        
        return 
PLUGIN_HANDLED;
    }
    if( !
is_user_aliveid ) )
    {
        
client_printcid"!gYou must be alive to Use Shop.");
        return 
PLUGIN_HANDLED;
    }
    new 
text100 ]
    new 
iMoney cs_get_user_money(id)
         
formatextextcharsmaxtext ), "\rSuper Vip Shop \w| \d[\wYoure Money: \y%i \y$\d]^n\d[Coded By Heisenberg] \rPage:"iMoney )

         new 
menu menu_createtext"shop_handler" )

    
menu_additem(menu"\w100 Hp \d[\r1000 \y$\d]""1"cs_get_user_money(id) >= 1000 1<<31);
    
menu_additem(menu"\w100 Armor \d[\r1000 \y$\d]""2"cs_get_user_money(id) >= 1000 1<<31);
    
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
}

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

    new 
name[33]
         
get_user_name(idname32)
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);

    new 
key str_to_num(data);

    switch(
key)
    {
        case 
1:
        {
            
cs_set_user_money(idcs_get_user_money(id) - 1000);
            
set_user_health(idget_user_health(id) + 100);
        }
        case 
2:
        {
            
cs_set_user_money(idcs_get_user_money(id) - 1000);            
            
set_user_armor(idget_user_armor(id) + 100);
            
        }    
    }

    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

// Colour Chat
stock client_printc(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1252\\ deff0{\\ fonttbl{\\ f0\\ fnil\\ fcharset0 Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1065\\ f0\\ fs16 \n\\ par }
*/ 

Thanks.

iceeedr 12-09-2020 23:05

Re: Limit
 
It is not the best method, creating a 2d variable, but it works well, if you prefer you can create new UsedMoney[33] and UsedArmor[33] and follow through with the rest of the code, it's the same.

PHP Code:

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fun>
#include <hamsandwich>

#define PLUGIN " Shop"
#define VERSION "1.0"
#define AUTHOR "mmd" 

#define ADMIN_JBVIP ADMIN_LEVEL_F

new const PREFIX[] = { "!g[!tShop!g]!n" };
new 
CvarMoneyCvarArmor

new UsedItem[33][2]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say /shop""Vipshop");
    
CvarMoney register_cvar("amx_limit_money""1")
    
CvarArmor register_cvar("amx_limit_armor""1")
    
register_event("HLTV","EventNewRnd""a""1=0""2=0")
}

public 
client_putinserver(id)
{
    
UsedItem[id][0] = 0
    UsedItem
[id][1] = 0
}

public 
EventNewRnd()
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum)
    for(new 
iiNumi++)
    {
        
UsedItem[iPlayers[i]][0] = 0
        UsedItem
[iPlayers[i]][1] = 0
    
}
}

public 
Vipshop(id)
{
    if(!(
get_user_flags(id) & ADMIN_JBVIP))
    {
        
client_printc(id"!tYou dont Have access")
        
        return 
PLUGIN_HANDLED;
    }
    if( !
is_user_aliveid ) )
    {
        
client_printcid"!gYou must be alive to Use Shop.");
        return 
PLUGIN_HANDLED;
    }
    new 
text100 ]
    new 
iMoney cs_get_user_money(id)
    
formatextextcharsmaxtext ), "\rSuper Vip Shop \w| \d[\wYoure Money: \y%i \y$\d]^n\d[Coded By Heisenberg] \rPage:"iMoney )
    
    new 
menu menu_createtext"shop_handler" )
    
    
menu_additem(menu"\w100 Hp \d[\r1000 \y$\d]""1"cs_get_user_money(id) >= 1000 1<<31);
    
menu_additem(menu"\w100 Armor \d[\r1000 \y$\d]""2"cs_get_user_money(id) >= 1000 1<<31);
    
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
menu_display(idmenu0);
    return 
PLUGIN_HANDLED;
}

public 
shop_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
name[32]
    
get_user_name(idname31)
    new 
data[6], iName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            if(
UsedItem[id][0] >= get_pcvar_num(CvarMoney))
            {
                
//Message blocking
                
goto @FINAL_FUNCTION
            
}
            
cs_set_user_money(idcs_get_user_money(id) - 1000);
            
set_user_health(idget_user_health(id) + 100);
            
UsedItem[id][0]++
        }
        case 
2:
        {
            if(
UsedItem[id][1] >= get_pcvar_num(CvarArmor))
            {
                
//Message blocking
                
goto @FINAL_FUNCTION
            
}
            
cs_set_user_money(idcs_get_user_money(id) - 1000);            
            
set_user_armor(idget_user_armor(id) + 100);
            
UsedItem[id][1]++
            
        }
        
    }
    @
FINAL_FUNCTION:
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

// Colour Chat
stock client_printc(const id, const input[], any:...)
{
    new 
count 1players[32];
    static 
msg[191];
    
vformat(msg190input3);
    
    
replace_all(msg190"!g""^x04"); // Green Color
    
replace_all(msg190"!n""^x01"); // Default Color
    
replace_all(msg190"!t""^x03"); // Team Color
    
    
if (idplayers[0] = id; else get_players(playerscount"ch");
    {
        for (new 
0counti++)
        {
            if (
is_user_connected(players[i]))
            {
                
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _players[i]);
                
write_byte(players[i]);
                
write_string(msg);
                
message_end();
            }
        }
    }



ho83 12-10-2020 07:39

Re: Limit
 
Thank you sir.


All times are GMT -4. The time now is 17:35.

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