Register for your free account! | Forgot your password?

You last visited: Today at 13:23

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



[Web] Giftbox System

Discussion on [Web] Giftbox System within the Flyff PServer Guides & Releases forum part of the Flyff Private Server category.

Reply
 
Old   #1
 
xsrf's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 871
Received Thanks: 642
[Web] Giftbox System

Cuz i got some time and want to develop something, here you can download my new giftbox system.

Take a look at the "loot.php", there you have to customize the function for some result you want to get.

have fun with this, also there is a video how it works



Database: handler.php

PHP Code:
<?php 

class DB
{
    private 
$sql;
    private 
$result;
    private 
$exec;
    
    function 
__construct$database null )
    {
        
$this->sql = @new MySQLiDB_HOSTDB_USERDB_PASS$database == null DB_BASE $database );
        
$this->sql->autocommitfalse );
        if( 
$this->sql->connect_errno )
        {
            
//change
            
die( "Unable to connect with the database. Error: " $this->sql->connect_errno .  " - " .   $this->sql->connect_error);
        }
    }
    
    public function 
Escape$post )
    {
        foreach(
$post as $key => $value)
        {
            
$value htmlspecialchars$value );
            
$value htmlentities$value );
            
$value strip_tags$value );
            
$value $this->sql->escape_string$value );
        }
        return 
$post;
    }
    
    public function 
Send $qry )
    {
        
$this->result DB::Exec$qry );
        if( 
$this->sql->errno )
        {
            die( 
"Error: " $this->sql->errno .  " - " .   $this->sql->error);
        }
        return 
DB::Result();
    }
    
    public function 
Send2 $qry )
    {
        
$this->result DB::Exec$qry );
    }
    
    public function 
Commit()
    {
        if( 
$this->sql->errno )
        {
            
$this->sql->rollback();
            die( 
"Error: " $this->sql->errno .  " - " .   $this->sql->error);
        }
        
$this->sql->commit();
    }
    
    private function 
Exec$qry )
    {
        
$exec = @$this->sql->query$qry );
        return 
$exec;
    }
    
    private function 
Result()
    {
        if( 
$this->result != "1" )
        {
            
$arr = array();
            if (!
function_exists('mysqli_fetch_all')){
                
$arr['obj'] = [];
                while (
$row $this->result->fetch_assoc()) {
                    
$arr['obj'][] = $row;
                }
            }else {
                
$arr['obj'] = $this->result->fetch_all(MYSQLI_ASSOC);
            }
            
$arr['rows'] = $this->result->num_rows;
            return 
$arr;
        }
        else 
        {
            return 
3;
        }
    }
    
}
Giftbox: giftbox.class.php

PHP Code:
<?php 

define
("DB_HOST""localhost");
define("DB_USER""root");
define("DB_PASS""");
define("DB_BASE""systems");

require_once( 
__DIR__ "/../Database/MySQL/handler.php" );

class 
GIFTBOX
{
    
//To store SQL connection
    
private $sql;
    
    function 
__construct()
    {
        
//Create SQL connection
        
$this->sql = new DBDB_BASE );
    }
    
    
//To create new boxes
    //@param array $object
    
public function setGiftbox$object )
    {
        
//XSS & SQL Injection prevention
        
$object $this->sql->Escape$object );
        
        
$store $this->sql->Sendsprintf"select id from giftbox_boxes where name = '%s' limit 1"$object["name"] ) );
        
        if( 
$store["rows"] > )
        {
            return 
"This giftbox is already in use. Please choose another name.";
        }
        
        
$this->sql->Send2sprintf"insert into giftbox_boxes (`name`, `desc`) values ('%s', '%s')"$object["name"], $object["desc"] ) );
        
$this->sql->Commit();
        
        return 
"Giftbox has been created. Now you are able to add items to this box.";
    }
    
    
//To list all boxes
    
public function listGiftbox()
    {
        return 
$this->sql->Send"select * from giftbox_boxes" );
    }
    
    
//To add new items to ad box
    
public function setItem$object 
    {
        
//XSS & SQL Injection prevention
        
$object $this->sql->Escape$object );
        
$store $this->sql->Sendsprintf"select id from giftbox_items where itemid = %d and boxid = %d limit 1", (int)$object["id"], (int)$object["box"] ) );
        
        if( 
$store["rows"] > )
        {
            return 
"Can not add an item two times to the same box.";
        }
        
        
$this->sql->Send2sprintf"insert into giftbox_items (`itemid`, `itemname`, `rarity`, `boxid`) values (%d, '%s', %d, %d)", (int)$object["id"], $object["name"], (int)$object["rarity"], (int)$object["box"] ) );
        
$this->sql->Commit();
        
        return 
"Item has been added.";
    }
    
    
//To show a specific item
    
public function showGiftbox$object )
    {
        
//XSS & SQL Injection prevention
        
$object $this->sql->Escape$object );
        
        
$store = [];
        
        
$store["box"] = $this->sql->Sendsprintf"select * from giftbox_boxes where id = %d limit 1", (int)$object["id"] ) );
        
$store["items"] = $this->sql->Sendsprintf"select * from giftbox_items where boxid = %d", (int)$object["id"] ) );
        
        
        for( 
$i 0$i <= $store["items"]["rows"]-1$i++ )
        {
            switch( 
$store["items"]["obj"][$i]["rarity"] )
            {
                case 
1
                    
$store["items"]["obj"][$i]["rarity"] = '<font color="grey">Common</font>';
                    break;
                case 
2
                    
$store["items"]["obj"][$i]["rarity"] = '<font color="blue">Rare</font>';
                    break;
                case 
3
                    
$store["items"]["obj"][$i]["rarity"] = '<font color="green">Epic</font>';
                    break;
                case 
4
                    
$store["items"]["obj"][$i]["rarity"] = '<font color="orange">Legendary</font>';
                    break;
                case 
5
                    
$store["items"]["obj"][$i]["rarity"] = '<font color="red">Awful</font>';
                    break;
            }
        }
        
        return 
$store;
    }
    
    
//To open a giftbox for a present
    //@param int $id -> Box ID
    
public function lootGiftbox$id )
    {
        
$object $this->sql->Escape$id );
        
        
$store $this->sql->Sendsprintf"select id from giftbox_boxes where id = %d limit 1"$object[0] ) );
        
        if( 
$store["rows"] <= )
        {
            return 
"This giftbox does not exists.";
        }
        
        
$store $this->sql->Sendsprintf"select * from giftbox_items where boxid = %d"$object[0] ) );
        
        if( 
$store["rows"] <= )
        {
            return 
"This box contains less than 3 items. Please contact an administrator to add more items to make this box useable.";
        }

        
$item self::getCate$store );
        
        if( !
$item[0] )
        {
            return 
$item[1];
        }
        
        return 
$item[1];
    }
    
    public function 
getCate$object )
    {
        
        
$random rand(0100);
        
        if( 
$random 50 )
        {
            
$cate 1;
        }
        elseif( 
$random 75 )
        {
            
$cate 2;
        }
        elseif( 
$random 90 )
        {
            
$cate 3;
        }
        elseif( 
$random 100 )
        {
            
$cate 4;
        }
        if( 
$random === 100 )
        {
            
$cate 5;
        }
        
        for( 
$i 0$i <= $object["rows"]-1$i++ )
        {
            if( 
$object["obj"][$i]["rarity"] != $cate )
            {
                unset( 
$object["obj"][$i] );
            }
        }
        
        if( 
count($object["obj"]) < )
        {
            return [
false"Actually you can not open this box, as it is not completed yet. Try again later please."];
        }
        
        
sort($object["obj"]);
        
        
$random rand(0count($object["obj"])-1);
        
        
//ADD YOUR PERSONAL RESULT WHICH YOU NEED TO CUSTOMIZE THIS GIFTBOX SYSTEM
        //EXAMPLE ONLY
        //EXAMPLE ONLY
        //EXAMPLE ONLY
        
        
switch( $object["obj"][$random]["rarity"] )
        {
            case 
1
                
$present '<font color="grey">' $object["obj"][$random]["itemname"] . '</font>';
                break;
            case 
2
                
$present '<font color="blue">' $object["obj"][$random]["itemname"] . '</font>';
                break;
            case 
3
                
$present '<font color="green">' $object["obj"][$random]["itemname"] . '</font>';
                break;
            case 
4
                
$present '<font color="orange">' $object["obj"][$random]["itemname"] . '</font>';
                break;
            case 
5
                
$present '<font color="red">' $object["obj"][$random]["itemname"] . '</font>';
                break;
        }
        
        
//EXAMPLE ONLY
        //EXAMPLE ONLY
        //EXAMPLE ONLY
        //ADD YOUR PERSONAL RESULT WHICH YOU NEED TO CUSTOMIZE THIS GIFTBOX SYSTEM
        
        
return [true$present];
    }
    
}
Credits:

50 % - Xsrf (me) for writing the code

50 % - for having the idea and supporting me
Attached Files
File Type: rar GIFTBOX with DATABASE.rar (85.9 KB, 63 views)
xsrf is offline  
Thanks
5 Users
Old 01/22/2016, 23:17   #2
 
Yasunai's Avatar
 
elite*gold: 159
Join Date: Sep 2010
Posts: 3,001
Received Thanks: 598
Da ich ja bei der Entwicklung zusehen konnte, muss ich sagen, dass man meine Idee für das Zufallssystem in der kurzen Zeit nicht viel besser hätte umsetzen können. Well done!
Yasunai is offline  
Old 01/23/2016, 05:32   #3
 
xsrf's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 871
Received Thanks: 642
Ich vergaß zu erwähnen, dass dieses System aktuell auf MySQL basiert und somit noch auf MSSQL sowie eine der aktuellen Webseiten angepasst werden muss.

Dies bedeutet, dass die Querys sowie mein Handler durch euren ersetzt werden müssen.
xsrf is offline  
Reply


Similar Threads Similar Threads
Giftbox & sleeping Problem
05/29/2014 - Flyff Private Server - 1 Replies
hay, wie im Titel schon steht habe ich ein Problem. Also ich fange mal einfach ein ^^ also wenn ich auf CS (Maske / Cloak / Suit etc) DST_GIFTBOX mache wird das nur einmal gewährtet also oben sind z.B. 3 Icons da steht dann das die Drop rate erhöht wird so wenn man aber dann Monster killt, bekommt man nur Drops wie als wäre nur eines der Items aktiv sprich die Giftbox wird nicht 3x gerechnet, sondern nur 1x wie kann ich das Fixen/ändern. Problem 2. Wenn man jemanden in der PvP Sleept hat...
GiftBox problem
04/28/2014 - Flyff Private Server - 4 Replies
Hi Elitepvers, I am having an slight problem with the PropGiftBox.inc file What i did was making an new Giftbox GiftBox II_DEFINE_NAME { II_SYS_SYS_SCR_PIEPROT 10000 100 II_GEN_MAT_MOONSTONE 10000 50 }
[Release] Giftbox - Pixelbot
12/12/2013 - DarkOrbit - 15 Replies
New Thread: Here
Giftbox & Fortune Circle
02/19/2013 - Flyff - 0 Replies
Hey, Ich wollt ma Fragen wie die Partyskills die Droprate erhöhen also um wv %? Hooffe ihr könnt helfen. MFG
Trashed a giftbox... What would you do?
09/10/2010 - Battle of the Immortals - 8 Replies
Well i trashed the giftbox by mistake.. im around lvl 59 atm.. should i make a new char? Well the only thing keeping me of making a new char is that i got like 2 ids from people already, meaning profits of bonus etc will come once they hit hight lvls.. The thing is.. is it so important to have the gift box? are the gifts that good at higher lvls? Share with me your opinion, if having 2 ids is a reason to not make a new char and lvl it back to 59. PS: sometimes we need an extra...



All times are GMT +1. The time now is 13:24.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.