[RP][James] New License Command [James]

Status
Not open for further replies.

Al-Santoro

New Member
Jan 20, 2011
29
5
Introduction:
First, I haven't coded in months, so it's been a while; however, my coding skills did improve a bit. But anyways, I've made this command which is very useful and more RP like for you to show cops your license. You can use this license for either cars, gun permit, etc.. Anyways, it's a way to make your hotel more RP.

Installing it in your database:
- First, go to your 'users' table in your Phpmyadmin.
- Click on "Structure" at the top.
- Scroll all the way down, and click the edit button.
- In the Field collum, put in "license" don't add the quotation marks.
- In your int value, put in 1.
- In your default value input 0.
- Click on save.

The License Page:
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'] = "license";$page['name'] = "license users";$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 ">                        <div class="cbb clearfix green ">
                            <h2 class="title">Valid Gun License registered mobsters</h2>                        <div id="notfound-content" class="box-content"><table width="100%">Here are the legal citizens with the legal license of their gun permitt.<br /><br /><?php    $sql = "SELECT name,wanted,figure,sex,id FROM users WHERE license = 1 ORDER BY name DESC";    $result = mysql_query($sql) OR die(mysql_error());    if(mysql_num_rows($result)) {        while($row = mysql_fetch_assoc($result)) {
        $userid = $row['id'];                if($row['license'] == "1")        {        }{  $s_username = $row['name'];  $s_figure = 'http://www.habbo.co.uk/habbo-imaging/avatarimage?figure='.$row['figure'].'&size=b&direction=2&head_direction=3&gesture=sml&size=m';}echo "<p><img src='".$s_figure."' alt='".$s_username."' align='left' /><b><a href='home/".$s_username."'>".$s_username."</a></b><br /><br /><br /><br /><br /><br /><br /><br /></p>";        }
}else{      echo 'No one have a valid license.</a>';}
?>
</table></div>                    </div>                </div></div>
<div class="habblet-container ">
</div>




<div id="column2" class="column">                <div class="habblet-container ">                        <div class="cbb clearfix green ">
                            <h2 class="title">What's this page?                             </h2>                        <div id="notfound-looking-for" class="box-content"><table width="170px">This page shows who have a valid license. <br /><br />If you don't have one, you'll have to purchase it at the Weapon's shop, for them to give you a valid license. And note, this is NOT cheap.</table>    </div>
</div>                    </div></div>





<?php require_once('templates/community_footer.php'); ?>

Now for the command(s):
Code:
#region License System
case "license": // Code by James. [Al-Santoro].
{
    using(DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
    {
        int license;
        license = dbClient.getInt("SELECT license FROM users WHERE name = '" + _Username + "'");
        if (license == 0)
        {
            sendData("BK" + "Sorry, but your Gun License is invalid.");
        }
        else
        {


        sendroom.Saying(roomUser, "*Shows their valid gun's license*");


break;
}
}
#endregion

Here's the next command I've just made, and I know, it's kind of messy, I was rushing on it, and was using notepad, but it should still work.
Code:
#region License System Information
case "licenseinfo":
{
using(DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
{

    int license;
    license = dbClient.getInt("SELECT license FROM users WHERE name = '" + _Username + "'");
    if (license == 0)
        {
        sendData("BK" + "Seems like you don't have a license.");
            }
          else
            {
                sendData("BK" + "Your License is currently valid! You can show this to the police for proof.");


break;
}
}
#endregion
This will show the status of your license.

I'll soon edit the thread for the "Get License" command. Where users will be able to buy a license from a store and purchase the license. I'll start on the command after I finish some codes up for my MobLifeRP Emulator.

Credits:
- Myself for making the command & editing the Wanted Page to make it work for licenses.
- Rasta/Sledmore for making the Wanted Page. [ I've used that to make the license page ].

Also, if you want to show the License on whether if you have it or not on your me.php page..
First, go to me.php page in your htdocs.
Now, find something like this:
PHP:
<li id="feed-item-tutor-score">                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/info_icons.png); background-position: 0 -433px; background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Stamina</div></div><div align="right" style=" padding-top:4px" >                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['stamina']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/int.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Intelligence</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['intelligence']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/strength.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Strength</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['str']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/health.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Health</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['health']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/immunity.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Immunity</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['immunity']; ?></div>                           </li>

Now, replace it with this:
PHP:
<li id="feed-item-tutor-score">                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/info_icons.png); background-position: 0 -433px; background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Stamina</div></div><div align="right" style=" padding-top:4px" >                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['stamina']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/int.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Intelligence</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['intelligence']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/strength.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Strength</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['str']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/health.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Health</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['health']; ?></div>                        <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/immunity.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">Immunity</div></div><div align="right" style=" padding-top:4px">                        <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['immunity']; ?></div>                          <div style="float: left; background-image: url(web-gallery/v2/images/personal_info/int.png); background-repeat:no-repeat; padding-top:4px"><div style="padding-left:18px">License</div></div><div align="right" style=" padding-top:4px">                          <?php $mysql_query = mysql_query("SELECT * FROM users WHERE name = '$user->name'"); $fetch_array = mysql_fetch_array($mysql_query); ?><?php echo $fetch_array['license']; ?></div> </li>

And then, the License will show on your me.php page. Saying whether you have one or not. The values will be 0 = No license and 1 = License.
 

Al-Santoro

New Member
Jan 20, 2011
29
5
Thanks Vic. ;D I'll begin working on the other License commands since I have spare time.
 

Tr0ll.

Member
Nov 20, 2010
99
5
I really hope that the 90% of you RP Developers (10% = Me, Sleddy, Aaron, Shorty) learn some caching. You don't really need any queries in the command if you cache it first..
 

Al-Santoro

New Member
Jan 20, 2011
29
5
Well, I'm still learning more on coding and such, but I'll be sure to look into that.
 

t3xt

Member
Jul 16, 2011
47
1
It's alright, two things though...


1) I don't really get the purpose of the ;licenseinfo command.. unless it's just to check if you already have a license purchased? If so, I don't see the point of it as you could just add the PHP code above to me.php


2) I think it would have been better if instead of sending back "Sorry your license is invalid" you'd change it to
PHP:
sendroom.Shout(roomUser, "*Shows their license to the officer, but it appears to be invalid*");
 

Mango2735

The Sexy One.
Oct 13, 2010
288
3
The Fix Up Command For The License Function. I fixed it up so it won't give you errors.
PHP:
#region License System
                    case "license": // Code by James. [Al-Santoro].
                        {
                            int license;
                            using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
                            {
                                license = dbClient.getInt("SELECT license FROM users WHERE name = '" + _Username + "'");
                                if (license == 0)
                                {
                                    sendData("BK" + "Sorry, but your Gun License is invalid.");
                                }
                                else
                                {
                                    Room.sendSaying(roomUser, "*Shows Off Their License.*");
                                }
                                Room.sendSaying(roomUser, "*Shows Off Their License*");
                            }

                            break;
                        }
                    #endregion
 

Al-Santoro

New Member
Jan 20, 2011
29
5
Thanks Vic. The problem was, I was coding it in notepad, and it wasn't working correctly on C# format.
 
Status
Not open for further replies.

Users who are viewing this thread

Top