AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Client buy (https://forums.alliedmods.net/showthread.php?t=293163)

EFFx 01-24-2017 14:51

Client buy
 
Dudes, how can I store the weapon's price in an array? And how can I check if the item that you've bought isn't these:

PHP Code:

const INVALID_ITEMS_BOUGH =        ((1<<CSW_DEFUSER)|(1<<CSW_NVGS)|(1<<CSW_SHIELD)|(1<<CSW_PRIMAMMO)|(1<<CSW_SECAMMO)) 

I'm using client_buy forward by Connor.

PHP Code:

public client_buy(idiItem)
{
    if(!(
<< iItem INVALID_ITEMS_BOUGH))
    {
        
PlayerData[id][arItemsBought]++
        if(
PlayerData[id][arItemsBought] > 3)
        {
            new 
randomChance random_num(0,MAX_CHANCE)
            if(
randomChance == MAX_CHANCE)
            {
                
gUserEventName id
                get_user_name
(gUserEventName,PlayerData[id][PlayerName],charsmax(PlayerData[]))
                
eVents ev_ItemsBought
            
}
        }

        if(
PlayerData[id][arMoneyWornOut] >= 4500)
        {
            new 
randomChance random_num(0,MAX_CHANCE)
            if(
randomChance == MAX_CHANCE)
            {
                
gUserEventName id
                get_user_name
(gUserEventName,PlayerData[id][PlayerName],charsmax(PlayerData[]))
                
eVents ev_MoneyWornOut
            
}
        }
    }



Napoleon_be 01-24-2017 16:32

Re: Client buy
 
I think you gotta store all price values manually, else i think Orphue would be the only option available, which i know nothing of.

A possible check could be:

PHP Code:

if(!(iItem INVALID_ITEMS_BOUGH)) 


EFFx 01-24-2017 16:41

Re: Client buy
 
I've used print_console for see what iItem returns. And it return numbers, like 31, 37, 36...
But I don't know how to check the weapon's number with that interger.

EFFx 01-24-2017 17:07

Re: Client buy
 
Fixed by myself

PHP Code:

new const eItemValue[] =
{
    
9,
    
4,
    
25,
    
31,
    
32,
    
36,
    
37


PHP Code:

    for(new i;sizeof eItemValue;i++)
    {
        if(
eItemValue[i] == iItem)
        {
        }
    } 



All times are GMT -4. The time now is 20:41.

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