[RP] Gang Commands, Pages and SQL [SLEDMORE + XAVI]

Status
Not open for further replies.

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
Hey guys,

Well, When I owned ObboRP, Xavi wanted gang commands, So he did me a base to re-code and use for ObboRP..

So before we go, Here are the credits:


Xavi 50%
Sledmore 50%

What is in this release?

  • SQL
    Gang Pages
    Gang Commands


    Right firstly lets do the SQL:

    PHP:
    CREATE TABLE IF NOT EXISTS `gang_corps` (
      `id` int(15) NOT NULL AUTO_INCREMENT,
      `gang_name` varchar(50) NOT NULL,
      `owner` varchar(25) NOT NULL,
      `kills` int(7) NOT NULL DEFAULT '0',
      `jailbreaks` int(7) NOT NULL DEFAULT '0',
      `gang_id` int(15) NOT NULL,
      PRIMARY KEY (`id`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=150 ;

    Next step, Lets go to the users table, And add the following:

    Field | Type
    gang_id | int(11)
    gang_rank | int(11)
    pending | int(11)
    pending_id | int(11)​


    Now lets do our gang pages:​

    topstats.php (NOT FINISHED THE FIGURES).​

    PHP:
    <?php
    /*================================================================+\
    || # PHPRetro - An extendable virtual hotel site and management
    |+==================================================================
    || # Copyright (C) 2009 Yifan Lu. All rights reserved.
    || # http://www.yifanlu.com
    || # Parts Copyright (C) 2009 Meth0d. All rights reserved.
    || # http://www.meth0d.org
    || # All images, scripts, and layouts
    || # Copyright (C) 2009 Sulake Ltd. All rights reserved.
    |+==================================================================
    || # PHPRetro is provided "as is" and comes without
    || # warrenty of any kind. PHPRetro is free software!
    || # License: GNU Public License 3.0
    || # http://opensource.org/licenses/gpl-license.php
    \+================================================================*/
    
    $page['allow_guests'] = true;
    require_once('./includes/core.php');
    require_once('./includes/session.php');
    $data = new community_sql;
    $lang->addLocale("community.community");
    
    $page['id'] = "topstats";
    $page['name'] = "Top Stats";
    $page['bodyid'] = "home";
    $page['cat'] = "community";
    
    require_once('./templates/community_header.php');
    ?>
    
    <div id="container">
    	<div id="content" style="position: relative" class="clearfix">
        <div id="column1" class="column">
    <div class="habblet-container ">
    <?php
    $get_kills = mysql_query("SELECT * FROM gang_corps WHERE kills > -1 ORDER BY kills DESC LIMIT 10");
    $get_jailbreaks = mysql_query("SELECT * FROM gang_corps WHERE jailbreaks > -1 ORDER BY jailbreaks DESC LIMIT 10");
    ?>
    
    
    
    						<div class="cbb clearfix green">
    
    							<h2 class="title">Top Gang Stats</h2>
    						<div id="notfound-content" class="box-content">
    <table width="100%">
    <?php
    while(($kills = mysql_fetch_array($get_kills)) && ($jailbreaks = mysql_fetch_array($get_jailbreaks))) {
    $gangowner = mysql_query("SELECT figure FROM users WHERE id = '".$gang_owner."'");
      echo '<tr>
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$kills['owner'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px"><a href="gang?gang_id='.$kills['gang_id'].'">'.$kills['gang_name'].'</a><br />'.$kills['kills'].' Kills</td>
               
    		 
    		   
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$deaths['figure'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px"><a href="gang?gang_id='.$jailbreaks['gang_id'].'">'.$jailbreaks['gang_name'].'</a><br />'.$jailbreaks['jailbreaks'].' Jailbreaks</td>
                </tr>';
    }
    ?>
    
    </table>
    </div>
    					</div>
    					
    				</div>
    				
    				<div class="habblet-container ">
    <?php
    $get_kills = mysql_query("SELECT * FROM users WHERE rank > 0 ORDER BY kills DESC LIMIT 10");
    $get_deaths = mysql_query("SELECT * FROM users WHERE rank > 0 ORDER BY deaths DESC LIMIT 10");
    ?>
    						<div class="cbb clearfix green">
    
    							<h2 class="title">Most Kills / Most Deaths
    							</h2>
    						<div id="notfound-content" class="box-content">
    <table width="100%">
    <?php
    while(($richest = mysql_fetch_array($get_kills)) && ($deaths = mysql_fetch_array($get_deaths))) {
      echo '<tr>
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$richest['figure'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px">'.$richest['name'].'<br />'.$richest['kills'].' Kills</td>
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$deaths['figure'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px">'.$deaths['name'].'<br />'.$deaths['deaths'].' Deaths</td>
                </tr>';
    }
    ?>
    </table>
    </div>
    					</div>
    					
    				</div>
    
    <div class="habblet-container ">
    <?php
    $get_kills = mysql_query("SELECT * FROM users WHERE rank > 0 ORDER BY arrests DESC LIMIT 10");
    $get_deaths = mysql_query("SELECT * FROM users WHERE rank > 0 ORDER BY hits DESC LIMIT 10");
    ?>
    						<div class="cbb clearfix green">
    
    							<h2 class="title">Most Arrests / Most Punches
    							</h2>
    						<div id="notfound-content" class="box-content">
    <table width="100%">
    <?php
    while(($richest = mysql_fetch_array($get_kills)) && ($deaths = mysql_fetch_array($get_deaths))) {
      echo '<tr>
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$richest['figure'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px">'.$richest['name'].'<br />'.$richest['arrests'].' Arrests</td>
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$deaths['figure'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px">'.$deaths['name'].'<br />'.$deaths['hits'].' Punches</td>
                </tr>';
    }
    ?>
    </table>
    </div>
    					</div>
    				</div>
    
    </div>
    
    
    
    
    
    <div id="column2" class="column">
    <?php
    $get_richest = mysql_query("SELECT * FROM users WHERE rank < 6 ORDER BY credits + bank_account DESC LIMIT 10");
    ?>
    
    
    				<div class="habblet-container ">
    						<div class="cbb clearfix green">
    
    							<h2 class="title">Richest Users
    							</h2>
    						<div id="notfound-looking-for" class="box-content">
    <table width="170px">
    <?php
    while($richest = mysql_fetch_array($get_richest)) {
      $credits = $richest['credits'] + $richest['bank_account'];
      echo '<tr>
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$richest['figure'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px">'.$richest['name'].'<br />'.$credits.' Credits</td>
                </tr>';
    }
    ?>
    </table>
        </div>
    
    </div>
    					</div>
    
    
    <div id="column2" class="column">
    <?php
    $get_richest = mysql_query("SELECT * FROM users WHERE rank < 6 ORDER BY str DESC LIMIT 10");
    ?>
    
    				<div class="habblet-container ">
    						<div class="cbb clearfix green">
    
    							<h2 class="title">Strongest Users
    							</h2>
    						<div id="notfound-looking-for" class="box-content">
    <table width="170px">
    <?php
    while($richest = mysql_fetch_array($get_richest)) {
      echo '<tr>
                <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$richest['figure'].'&size=s&direction=2&head_direction=2&gesture=sml&size=m" align="left"></td>
                <td width="150px">'.$richest['name'].'<br />'.$richest['str'].' Strength</td>
                </tr>';
    }
    ?>
    </table>
        </div>
    
    </div></div></div></div>
    	
    
    
    
    
    
    
    <?php require_once('templates/community_footer.php'); ?>

    Gang page, To view the gangs members etc.. (NOT FINISHED).​

    PHP:
    <?php
    /*================================================================+\
    || # PHPRetro - An extendable virtual hotel site and management
    |+==================================================================
    || # Copyright (C) 2009 Yifan Lu. All rights reserved.
    || # http://www.yifanlu.com
    || # Parts Copyright (C) 2009 Meth0d. All rights reserved.
    || # http://www.meth0d.org
    || # All images, scripts, and layouts
    || # Copyright (C) 2009 Sulake Ltd. All rights reserved.
    |+==================================================================
    || # PHPRetro is provided "as is" and comes without
    || # warrenty of any kind. PHPRetro is free software!
    || # License: GNU Public License 3.0
    || # http://opensource.org/licenses/gpl-license.php
    \+================================================================*/
    
    $page['allow_guests'] = true;
    require_once('./includes/core.php');
    require_once('./includes/session.php');
    $lang->addLocale("credits.credits");
    
    $page['id'] = "gangs";
    $page['name'] = "Gang Pages";
    $page['bodyid'] = "home";
    $page['cat'] = "community";
    
    require_once('./templates/community_header.php');
    
    $getGangID = $input->FilterText($_GET['gang_id']);
    ?>
    
    
    <div id="container">
    	<div id="content" style="position: relative" class="clearfix">
        <div id="column1" class="column">
    
        <div class="habblet-container ">
    	
    <?php
      $getRankInfo = mysql_query("SELECT * FROM users WHERE gang_id = '".$getGangID."' && gang_rank = '1'");
      $rankInfo = mysql_fetch_array($getRankInfo);
      $getUserInfo = mysql_query("SELECT * FROM users WHERE gang_id = '".$rankInfo['id']."'");
    ?>
    
    <?php
      $getRankInfo1 = mysql_query("SELECT * FROM users WHERE gang_id = '".$getGangID."' && gang_rank = '2'");
      $rankInfo1 = mysql_fetch_array($getRankInfo1);
      $getUserInfo1 = mysql_query("SELECT * FROM users WHERE gang_id = '".$rankInfo1['id']."'");
    ?>
    	
      						<div class="cbb clearfix green">
    
    							<h2 class="title">Gang Leader</h2>
    <?php
    while($UserInfo1 = mysql_fetch_array($getUserInfo1)){
      echo '<tr>
      
      <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$UserInfo1['figure'].'&size=b&direction=2&head_direction=3&gesture=sml&size=m" align="left"><strong></td>
      <td width="150px"><a href="#">'.$UserInfo1['name'].'</a></strong>
      <br />'.$UserInfo1['mission'].'<br />
      <br />Kills: '.$UserInfo1['kills'].'
      <br />Arrests: '.$UserInfo1['arrests'].'<br /><br /><br /><br /><br /></td>
      
      
        <td width="20px"></td>
        <td width="150px"></td>
      
      
      </tr>';
    }
    ?>
    				                </div>
    				                
    				                <div class="cbb clearfix green">
    
    							<h2 class="title">Gang Members</h2>
    <?php
    while($UserInfo = mysql_fetch_array($getUserInfo)){
      echo '<tr>
      
      <td width="20px"><img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$UserInfo['figure'].'&size=b&direction=2&head_direction=3&gesture=sml&size=m" align="left"><strong></td>
      <td width="150px"><a href="#">'.$UserInfo['name'].'</a></strong>
      <br />'.$UserInfo['mission'].'<br />
      <br />Kills: '.$UserInfo['kills'].'
      <br />Arrests: '.$UserInfo['arrests'].'<br /><br /><br /><br /><br /></td>
      
      
        <td width="20px"></td>
        <td width="150px"></td>
      
      
      </tr>';
    }
    ?>
    				                </div>
    
    
    
    				</div>
    </div>
    
    <?php
    $getGang = mysql_query("SELECT * FROM gang_corps WHERE gang_id = '".$getGangID."'");
    $gangInfo = mysql_fetch_array($getGang);
    $getOwner = mysql_query("SELECT * FROM users WHERE id = '".$gangInfo['owner']."'");
    $owner = mysql_fetch_array($getOwner);
    ?>
    
    <div id="column2" class="column">
    
    						<div class="cbb clearfix green">
    							<h2 class="title">Gang Owner</h2>
    						<div id="purse-habblet">
    
    <div class="box-content">
    <?php
    echo '<img src="http://www.habbo.com/habbo-imaging/avatarimage?figure='.$owner['figure'].'&size=b&direction=2&head_direction=3&gesture=sml&size=m" align="left">
    <a href="#"><strong>'.$owner['name'].'</strong></a>
    <br />'.$owner['mission'].'<br /><br />
    <strong>Last visit</strong>:<br />'.$owner['lastvisit'];
    ?>
    </div>
    </div>
    
    
    					</div>
    					
    											<div class="cbb clearfix green">
    							<h2 class="title">Something is coming?</h2>
    						<div id="purse-habblet">
    
    <div class="box-content">
    
    </div>
    </div>
    
    
    					</div>
    				</div>
    
    
    <?php require_once('./templates/community_footer.php'); ?>

    Now lets do our gang commands:​

    Right, Just simply add all of theses commands (I know their messy but never expected to release them):

    Code:
    #region gangs
                        #region :ganginfo
                        case "ganginfo":
                            {
                                sendData("BK" +
                                "General Gang Commands\r" +
                                "\r" +
                                ":gangform <name>\r" +
                                ":ganginvite <user>\r" +
                                ":gangaccept\r" +
                                ":gangleave\r" +
                                ":gangdisband\r" +
                                "\r" +
                                "There will be more to come!");
                                break;
                            }
                        #endregion
    
                        #region :gangform <name>
                        case "gangform":
                            {
                                int myGang;
                                string name_taken;
                                string gang_name = stringManager.wrapParameters(args, 1);
                                using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                {
                                    myGang = dbClient.getInt("SELECT gang_id FROM users WHERE name = '" + _Username + "'");
                                    name_taken = dbClient.getString("SELECT gang_name FROM gang_corps");
                                    {
                                        if (gang_name == name_taken)
                                        {
                                            sendData("BK" + "This gang name has already been taken." + Convert.ToChar(2));
                                        }
                                        else
                                        {
                                            if (myGang > 0)
                                            {
                                                sendData("BK" + "You already own a gang, or are in a gang");
                                            }
                                            else
                                            {
                                                this.sendData("BK" + "You now own the " + gang_name +" gang!");
                                                dbClient.runQuery("INSERT INTO gang_corps (gang_id,gang_name,owner) VALUES ('" + userID + "','" + gang_name + "','" + userID + "')");
                                                dbClient.runQuery("UPDATE users SET gang_id = '" + userID + "' WHERE name = '" + _Username + "'");
                                                dbClient.runQuery("UPDATE users SET gang_rank = '2' WHERE name = '" + _Username + "'");
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        #endregion
    
                        #region :ganginvite <name>
                        case "ganginvite":
                            {
                                using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                {
                                    virtualUser User = userManager.getUser(args[1]);
                                    {
                                        if (_Username == User._Username)
                                        {
                                            this.sendData("BK" + "You cannot invite your self to your own gang!");
                                        }
                                        else
                                        {
                                            int myGangz;
                                            string gang_name;
                                            myGangz = dbClient.getInt("SELECT gang_id FROM users WHERE name = '" + _Username + "'");
                                            gang_name = dbClient.getString("SELECT gang_name FROM gang_corps WHERE gang_id = '" + myGangz + "'");
    
                                            int isAllowed = dbClient.getInt("SELECT gang_rank FROM users WHERE name = '" + _Username + "'");
                                            if (isAllowed == 2)
                                            {
                                                this.sendData("BK" + "You have sent a gang invite to " + User._Username + " to join " + gang_name + "!*");
                                                User.sendData("BK" + "You have been invited to join " + gang_name + "!");
                                                dbClient.runQuery("UPDATE users SET pending_id = '" + userID + "' WHERE name = '" + User._Username + "'");
                                                dbClient.runQuery("UPDATE users SET pending = '1' WHERE name = '" + User._Username + "'");
                                            }
                                            else
                                            {
                                                this.sendData("BK" + "You do not have the premission to invite someone to a gang!");
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        #endregion
    
                        #region :gangaccept
                        case "gangaccept":
                            {
                                using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                {
                                    int myPending;
                                    myPending = dbClient.getInt("SELECT pending FROM users WHERE name = '" + _Username + "'");
                                    if (myPending != 1)
                                    {
                                        this.sendData("BK" + "There are no current gang requests you can accept*");
                                    }
                                    else
                                    {
                                        int ownsgang = dbClient.getInt("SELECT gang_rank FROM users WHERE name = '" + _Username + "'");
                                        if (ownsgang == 2)
                                        {
                                            this.sendData("BK" + "You cannot join a gang when you currently own one, just type in :gangdisband to delete your current gang!");
                                        }
                                        else
                                        {
                                            int myGangz;
                                            string gang_name;
                                            myGangz = dbClient.getInt("SELECT pending_id FROM users WHERE name = '" + _Username + "'");
                                            gang_name = dbClient.getString("SELECT gang_name FROM gang_corps WHERE gang_id = '" + myGangz + "'");
    
                                            dbClient.runQuery("UPDATE users SET gang_id = '" + myGangz + "' WHERE name = '" + _Username + "'");
                                            dbClient.runQuery("UPDATE users SET gang_rank = '1' WHERE name = '" + _Username + "'");
    
                                            this.sendData("BK" + "You're now a member of the " + gang_name + " gang!*");
    
                                            dbClient.runQuery("UPDATE users SET pending_id = '0' WHERE name = '" + _Username + "'");
                                            dbClient.runQuery("UPDATE users SET pending = '0' WHERE name = '" + _Username + "'");
                                        }
                                    }
                                }
                                break;
                            }
                        #endregion
    
                        #region :gangleave
                        case "gangleave":
                            {
                                using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                {
                                    int myGangz;
                                    string gang_name;
                                    myGangz = dbClient.getInt("SELECT gang_id FROM users WHERE name = '" + _Username + "'");
                                    gang_name = dbClient.getString("SELECT gang_name FROM gang_corps WHERE gang_id = '" + myGangz + "'");
                                    {
                                        if (myGangz == 0)
                                        {
                                            this.sendData("BK" + "You are currently not in a gang");
                                        }
                                        else
                                        {
                                            int ownsgang = dbClient.getInt("SELECT gang_rank FROM users WHERE name = '" + _Username + "'");
                                            if (ownsgang == 2)
                                            {
                                                this.sendData("BK" + "You cannot leave a gang when you own one, You must do :gangdisband to leave it and end it.");
                                            }
                                            else if (ownsgang == 1)
                                            {
                                                this.sendData("BK" + "you have now left " + gang_name + "!");
    
                                                // clear shit
    
                                                dbClient.runQuery("UPDATE users SET gang_id = '0' WHERE name = '" + _Username + "'");
                                                dbClient.runQuery("UPDATE users SET gang_rank = '0' WHERE name = '" + _Username + "'");
    
                                                // incase lol
    
                                                dbClient.runQuery("UPDATE users SET pending_id = '0' WHERE name = '" + _Username + "'");
                                                dbClient.runQuery("UPDATE users SET pending = '0' WHERE name = '" + _Username + "'");
    
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        #endregion
    
                        #region :gangdisband
                        case "gangdisband":
                            {
                                using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                {
                                    int gangid;
                                    int myGangzid;
                                    string gang_name;
                                    myGangzid = dbClient.getInt("SELECT gang_id FROM users WHERE name = '" + _Username + "'");
                                    gang_name = dbClient.getString("SELECT gang_name FROM gang_corps WHERE gang_id = '" + myGangzid + "'");
                                    gangid = dbClient.getInt("SELECT gang_id FROM gang_corps WHERE gang_id = '" + myGangzid + "'");
                                    {
                                        int ownsgang = dbClient.getInt("SELECT gang_rank FROM users WHERE name = '" + _Username + "'");
                                        if (ownsgang == 2)
                                        {
                                            this.sendData("BK" + "You have now disbanded " + gang_name + "!");
    
                                            dbClient.runQuery("UPDATE users SET gang_id = '0', gang_rank = '0' WHERE gang_id = '" + myGangzid + "'");
                                            dbClient.runQuery("DELETE FROM gang_corps WHERE gang_id = '" + myGangzid + "'");
                                        }
                                        else
                                        {
                                            this.sendData("BK" + "You do not own a gang, So there is nothing to disband!");
                                        }
                                    }
                                }
                                break;
                            }
                        #endregion
    
                        #region :gangkick
                        case "gangkick":
                            {
                                virtualUser User = userManager.getUser(args[1]);
                                {
                                    using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                                    {
                                        int gangid;
                                        int myGangzid;
                                        string gang_name;
                                        myGangzid = dbClient.getInt("SELECT gang_id FROM users WHERE name = '" + _Username + "'");
                                        gang_name = dbClient.getString("SELECT gang_name FROM gang_corps WHERE gang_id = '" + myGangzid + "'");
                                        gangid = dbClient.getInt("SELECT gang_id FROM gang_corps WHERE gang_id = '" + myGangzid + "'");
                                        {
                                            int ownsgang = dbClient.getInt("SELECT gang_rank FROM users WHERE name = '" + _Username + "'");
                                            int userisinmygang = dbClient.getInt("SELECT gang_id FROM users WHERE name = '" + User._Username + "'");
                                            {
                                                if (ownsgang == 2)
                                                {
                                                    if (userisinmygang == 1)
                                                    {
                                                        this.sendData("BK" + "You have now kicked " + User._Username + " from your gang!");
                                                        User.sendData("BK" + "You have been kicked out of " + gang_name + "!");
                                                        dbClient.runQuery("UPDATE users SET gang_id = '0', gang_rank = '0' WHERE username = '" + User._Username + "'");
                                                    }
                                                }
                                                else if (userisinmygang == 0)
                                                {
                                                    this.sendData("BK" + "This user is not in your gang!");
                                                }
                                                else if (ownsgang == 1)
                                                {
                                                    this.sendData("BK" + "You do not have premission to use this command!");
                                                }
                                            }
                                        }
                                    }
                                }
                                break;
                            }
                        #endregion
     
                        #endregion

    If you like this, Feel free to show your appreciation and click the thanks/like button. - I understand half of this isn't complete but it will do.

    - Cheers!
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
Thanks for your comment :).
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
Glad you all like it xD. ;D.
 

Mastah

the funny thing is \r\n i did
Oct 25, 2010
739
41
wait where on the emu do i put the code, like virtualuser.cs then under

{
{
 

Sledmore

Chaturbate Livestreamer
Staff member
FindRetros Moderator
Jul 24, 2010
5,199
3,934
Read the code? + Why would it need that?
 
Status
Not open for further replies.

Users who are viewing this thread

Top