This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
donategold.php
51 lines (50 loc) · 2.56 KB
/
donategold.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
session_name("icsession");
session_start();
include('db.php');
include('varset.php');
$getchar = mysql_query("SELECT * FROM characters WHERE id='".$_SESSION['userid']."'")or die("Not logged in!");
$char = mysql_fetch_assoc($getchar);
$amount = $_POST['amount'];
if(isset($_POST['amount']) && $amount > "0" && $chargold > "0")
{
$getguild = mysql_query("SELECT * FROM guilds WHERE name='".$char['guild']."'");
$guild = mysql_fetch_assoc($getguild);
if($amount >= $chargold && $amount > "0" && $chargold > "0")
{
/*
This will set the designated donation to the amount of gold the player has on hand if
they have entered more than they posess
*/
$amount = $chargold;
}
$newgold = floor($chargold - $amount);
$newbank = floor($guild['bank'] + $amount);
$newtd = $char['totaldonations'] + $amount;
if($newbank > "1000000000000000000")
{
/*
This code will run if the player is trying to put the cap of 1Quint into the Guild Bank
This code will find the excess gold and automatically reimburse the player the difference
*/
$reimburse = $newbank - "1000000000000000000";
$newgold += $reimburse;
$newbank = "1000000000000000000";
}
$message = "donated ".number_format($amount)." gold to the guild! ".$char['username']." has contributed ".number_format($newtd)." gold to the guild in total.";
$message = "<font color=\'#DD00DD\'><strong>Guild:</strong></font> (<a href=\'javascript:toptell(\"".$char['username']."\");\'><font color=\'#DD00DD\' style=\'text-decoration:none\'>".$charname."</font></a>)<font color=\'#DD00DD\'> ".$message."</font><br />";
$getmembers = mysql_query("SELECT * FROM characters WHERE guild='".$charguild."'");
while($member = mysql_fetch_array($getmembers))
{
$query = mysql_query("INSERT INTO chatroom (`date`, `userlevel`, `username`, `to`, `message`) VALUES ('".$timestamp."', '4', 'PM', '".$member['username']."', '".$message."')");
}
$logMessage = "".$char['username']." donated ".number_format($amount)." gold to the guild!";
$letGuildKnow = mysql_query("INSERT INTO log (`name`, `message`) VALUES ('".$charguild."', '".$logMessage."')");
$removegold = mysql_query("UPDATE characters SET gold='".$newgold."', totaldonations='".$newtd."' WHERE id='".$_SESSION['userid']."'");
$donategold = mysql_query("UPDATE guilds SET bank='".$newbank."' WHERE name='".$char['guild']."'");
include('updatestats.php');
print("viewGuild();");
}else{
print('alert(\'You cannot donate you negative money!\');');
}
?>