"Limit of coins" [PHPRetro/HoloCMS Addon]
I thought about something, I was like I get on these hotels and you realize these users go away with coins, getting millions and millions of coins, and you know... that slows the server down with a quickness, because coins are what's mostly bought in the hotels anyway, besides furniture. So I've coded a script, where if a user has exceeded the limit, then they will reduce back to whatever your limit is.
The code:
It's been revised and works.
PHP Code:
<?php
include('core.php');
$limit = 100000000;
if($myrow['credits'] > $limit)
{
echo "<script language=\"JavaScript\">\n;
alert('Your coins have exceeded the hotels limit, so you are being reduced to the limit.');\n;
</script>";
mysql_query("UPDATE users SET credits = ".$limit." WHERE id = '".$my_id."' LIMIT 1") or die(mysql_error());
} else {
echo "<script language=\"JavaScript\">\n;
alert('You are under the limit, so your coins will stay safe!');
</script>";
}
?>
Coded it for PHPRetro as well:
Since the stuff is different, it took a while.
Place it in me.php under this code:
Code:
<ul id="link-bar" class="clearfix">
<li class="change-looks"><a href="<?php echo PATH; ?>/profile"><?php echo $lang->loc['change.looks']; ?> »</a></li>
<li class="credits">
<a href="<?php echo PATH; ?>/credits"><?php echo $user->user("credits"); ?></a> <?php echo $lang->loc['credits']; ?><br>
PHP Code:
<?php
$limit = 20000;
if($user->user("credits") > $limit)
{
echo 'Your coins have exceeded the hotels limit, so you are being reduced to the limit, the limit is: ';
echo $limit;
mysql_query("UPDATE users SET credits = ".$limit." WHERE id = ".$user->id."");
} else {
echo 'You are under the limit, so your coins will stay safe!';
}
?>
For HoloCMS place under the same code in me.php as well.
Do NOT make another php file for it. It's much easier.
Re: [REL] HoloCMS Add-On "Limit of coins"
It looks really good.
Ima try this!
Re: [REL] HoloCMS Add-On "Limit of coins"
Thanks mate, you'll enjoy it, I'll think of some more ideas of add-ons and I'll make them.
Re: [REL] HoloCMS Add-On "Limit of coins"
If you can code it for PHPRetro itll be GREAT
Re: [REL] HoloCMS Add-On "Limit of coins"
Revised the code, it was some errors in it:
PHP Code:
<?php
include('core.php');
function limitingCoins()
{
$limit = 100000000;
if($myrow['credits'] > $limit)
{
echo "<script language=\"JavaScript\">\n;
alert('Your coins have exceeded the hotels limit, so you are being reduced to the limit.');\n;
</script>";
mysql_query("UPDATE users SET credits = ".$limit." WHERE id = '".$my_id."' LIMIT 1") or die(mysql_error());
} else {
echo "<script language=\"JavaScript\">\n;
alert('You are under the limit, so your coins will stay safe!');
</script>";
}
}
?>
Re: [REL] HoloCMS Add-On "Limit of coins"
Very Nice man, i think i would use it if i had a retro!
Posted via Mobile Device
Re: [REL] HoloCMS Add-On "Limit of coins"
Okay a couple of things.
Why don't you just code this into the core.php, instead of having an include - meh maybe thats just personal prefence.
PHP Code:
<?php
include('core.php');
function limitingCoins()
{
$limit = 100000000;
if($myrow['credits'] > $limit)
{
echo "<script language=\"JavaScript\">\n";
echo "alert("Your coins have exceeded the hotels limit, so you are being reduced to the limit.");\n";
echo "</script>";
mysql_query("UPDATE users SET credits = ".$limit." WHERE id = '".$my_id."' LIMIT 1") or die(mysql_error());
} else {
echo "<script language=\"JavaScript\">\n";
echo "alert("You are under the limit, so your coins will stay safe!");\n";
echo "</script>";
}
}
?>
Firstly the code wouldn't even run, becasue your not excatuing the function limitingCoins();
Secondly, you should remove the else statement becasue you imagine on EVERY single page you load your going to get some shitty alert saying that you have the right amount of credits. How gay eh?
I think you should make some amendments to you code.
Re: [REL] HoloCMS Add-On "Limit of coins"
Coded it for PHPRetro as well:
Since the stuff is different, it took a while.
Place it in me.php under this code:
Code:
<ul id="link-bar" class="clearfix">
<li class="change-looks"><a href="<?php echo PATH; ?>/profile"><?php echo $lang->loc['change.looks']; ?> »</a></li>
<li class="credits">
<a href="<?php echo PATH; ?>/credits"><?php echo $user->user("credits"); ?></a> <?php echo $lang->loc['credits']; ?><br>
PHP Code:
<?php
$limit = 20000;
if($user->user("credits") > $limit)
{
echo 'Your coins have exceeded the hotels limit, so you are being reduced to the limit, the limit is: ';
echo $limit;
mysql_query("UPDATE users SET credits = ".$limit." WHERE id = ".$user->id."");
} else {
echo 'You are under the limit, so your coins will stay safe!';
}
?>
P.S: I was already a step ahead of you, bro (iJames)
Re: [REL] HoloCMS Add-On "Limit of coins"
I think you should intergreate it better maybe in the 'nofication box.' Also, PhpRetro uses OOP for querys replace the mysql_query with $db->query();
I still think you should have the else statment. But hay you cant win them all.
Re: [REL] HoloCMS Add-On "Limit of coins"
Quote:
Originally Posted by
iJames
I think you should intergreate it better maybe in the 'nofication box.' Also, PhpRetro uses OOP for querys replace the mysql_query with $db->query();
I still think you should have the else statment. But hay you cant win them all.
You're right, but after all I coded this while I'm at work lol so I really didn't have time to just....... get on it and read every little detail.
Re: [REL] HoloCMS/PHPRetro Add-On "Limit of coins"
Tbh, it's a very simple if statement tbh. It's not much of a release.
See my Epic Shop would be what you call a release.
http://www.epichotel.co.uk/shop
HoloShop for a v39 retro & phpretro ^_^.
Re: [REL] HoloCMS/PHPRetro Add-On "Limit of coins"
Re: [REL] HoloCMS/PHPRetro Add-On "Limit of coins"
can you adit a screenshot `?
Re: [REL] HoloCMS/PHPRetro Add-On "Limit of coins"
Nice release Obvilion, ^^ put on your holocms/phpretro and you'll find out what it looks like (: cya
Peace,
sean111
Re: HoloCMS/PHPRetro Add-On "Limit of coins"
Thanks I've also coded it in C# and VB.NET
C#:
PHP Code:
#region coinlimit
int limit = 20000;
if (_Credits < limit)
{
sendData("BKYou now have " + _Credits + ", the limit is: " + limit + ", you are safe for now.");
}
else
{
if (_Credits > limit)
using (DatabaseClient dbClient = Eucalypt.dbManager.GetClient())
{
dbClient.runQuery("UPDATE users SET credits = " + limit + " WHERE id = " + userID + "");
sendData("You now have " + _Credits + ", your coins are now being reduced below the limit.");
}
}
#endregion
VB.NET:
PHP Code:
#Region "coinlimit"
Dim limit As Integer = 20000
If _Credits < limit Then
sendData("BKYou now have " & _Credits & ", the limit is: " & limit & ", you are safe for now.")
Else
If _Credits > limit Then
Using dbClient As DatabaseClient = Eucalypt.dbManager.GetClient()
dbClient.runQuery("UPDATE users SET credits = " & limit & " WHERE id = " & userID & "")
sendData("You now have " & _Credits & ", your coins are now being reduced below the limit.")
End Using
End If
End If
#End Region