Raised This Month: $ Target: $400
 0% 

[HELP] Random Item Chance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-10-2015 , 13:36   [HELP] Random Item Chance
Reply With Quote #1

So i took this from the supply box code, this is used to give a player a random item written in a file
I want to remove the code that is using the .ini file for listing the items, and add them manualy in the script
I also want to know how i can create chances for each item in this given function with the following method

PHP Code:
random_num(1,100)
{
case 
1..20: { item name }
case 
211:100 item name }

here is the function that needs to be edited
PHP Code:
public load_supplybox_item() 
{
    new 
filepath[64]
    
get_configsdir(filepathcharsmax(filepath))
    
format(filepathcharsmax(filepath), god_item_filefilepath)
    
    if (!
file_exists(filepath))    
    {
        new 
error_msg[100]
        
formatex(error_msgcharsmax(error_msg), "[zp_supply_box][Error] Item File Not Found")
        
set_fail_state(error_msg)
        return
    }
    
    new 
line[1024], key[64], value[960]
    new 
file fopen(filepath"rt")
    
    while (!
feof(file) && file)
    {
        
fgets(filelinecharsmax(line));
        
replace(linecharsmax(line), "^n""")
        
        if (!
line[0] || line[0] == ';')
            continue
        
        
strtok(linekeycharsmax(key), valuecharsmax(value), '=')
        
trim(key)
        
trim(value)
        
        if (
equali(key"SUPPLYBOX_ITEM")) 
        {
            while (
value[0] != && strtok(valuekeycharsmax(key), valuecharsmax(value), ',')) 
            {
                
trim(key)
                
trim(value)
                
ArrayPushString(supplybox_itemkey)
            }
        }
    }

Here is the Full Code
Spoiler
Depresie is offline
 



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 17:49.


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