- Joined
- Sep 3, 2011
- Messages
- 150
- Reaction score
- 94
Hi there,
As many players and devs should notice, theres a issue with missing jadens when you use both, vote for jadens and hourly jadens.
Its caused by `usecashnow` table structure (MySQL).
It allows only one record per userid cause of unique key: PRIMARY(userid,zoneid,sn).
Example:
When your script just added hourly jadens for all online players, it stores records in this table until game server process it.
Procesing usualy takes 1-10 min.
So if player will vote when his hourly jaden record are still in this table it will cause mysql error:#1062 - Duplicate entry '1-1-1' for key 'PRIMARY'.
I prepared script that will allow you to vote, add jadens from GM panel, hourly jadens etc at same time so players wont loose any jadens.
First you need new table in MySQL:
Now scripts:
jaden/safecash.php
/auto5/safecash.sh
Add to crontab (/etc/crontab)
Now need to change all add jadens INSERTS in ur web scripts:
from for example:
to
You will edit jaden value by ur own of course.
Ill add hourly jaden script as a bonus here:
/auto60/jaden.sh:
Crontab for hourly jaden:
As many players and devs should notice, theres a issue with missing jadens when you use both, vote for jadens and hourly jadens.
Its caused by `usecashnow` table structure (MySQL).
It allows only one record per userid cause of unique key: PRIMARY(userid,zoneid,sn).
Example:
When your script just added hourly jadens for all online players, it stores records in this table until game server process it.
Procesing usualy takes 1-10 min.
So if player will vote when his hourly jaden record are still in this table it will cause mysql error:#1062 - Duplicate entry '1-1-1' for key 'PRIMARY'.
I prepared script that will allow you to vote, add jadens from GM panel, hourly jadens etc at same time so players wont loose any jadens.
First you need new table in MySQL:
Code:
CREATE TABLE IF NOT EXISTS `cashtable` (
`userid` int(11) NOT NULL,
`zoneid` int(11) NOT NULL,
`cash` int(11) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Now scripts:
jaden/safecash.php
Code:
<?php
$DBHost='localhost';
$DBUser='root';
$DBName='dynasty';
$DBPassword='password';
$conn = mysql_connect($DBHost, $DBUser, $DBPassword );
if (!$conn) {
echo "Database connection error. Details : " . mysql_error();
exit;
}
if (!mysql_select_db($DBName)) {
echo "The database doesn't exists. Details : " . mysql_error();
exit;
}
$time=date('Y-m-d H:i:s',$_SERVER['REQUEST_TIME']);
$result = mysql_query("SELECT `userid`,`zoneid`,`cash` FROM `cashtable`");
while($cash=mysql_fetch_row($result)){
$sn=mysql_num_rows(mysql_query("SELECT * FROM `usecashnow` WHERE `userid` = $cash[0] AND `zoneid`=$cash[1] LIMIT 1"));
if($sn==0){
MySQL_Query("INSERT INTO `usecashnow` (userid, zoneid, sn, aid, point, cash, status, creatime) VALUES ($cash[0], $cash[1], 0, 1, 0, $cash[2], 1, '$time')");
MySQL_Query("DELETE FROM `cashtable` WHERE `userid`=$cash[0] AND `zoneid`=$cash[1] AND `cash`=$cash[2] LIMIT 1");
echo $cash[0].'->'.$cash[2].'<br />';
}
else continue;
}
?>
/auto5/safecash.sh
Code:
#!/bin/sh
/opt/lampp/bin/php -f /jaden/safecash.php >> logfile2.txt 2>&1
Add to crontab (/etc/crontab)
Code:
*/5 * * * * root /auto5/safecash.sh
Now need to change all add jadens INSERTS in ur web scripts:
from for example:
Code:
MySQL_Query("INSERT INTO usecashnow (userid, zoneid, sn, aid, point, cash, status, creatime) VALUES ('$UID', 1, 0, 1, 0, 500, 1, '$TIME')");
Code:
MySQL_Query("INSERT INTO cashtable (userid, zoneid, cash) VALUES ($UID, 1, 500)");
Ill add hourly jaden script as a bonus here:
Code:
<?
$DBHost = "localhost";
$DBUser = "root";
$DBPassword = "password";
$DBName = "dynasty";
$Hcash=1000;
$Link = MySQL_Connect($DBHost, $DBUser, $DBPassword) or die ("Can't connect to MySQL");
MySQL_Select_Db($DBName, $Link) or die ("Database ".$DBName." does not exist.");
$OnlineAccountQuery = Mysql_Query("SELECT * FROM point WHERE zoneid > -1");
$OnlineAccountNum = Mysql_Num_Rows($OnlineAccountQuery);
$i=0;
WHILE($i < $OnlineAccountNum){
$OnlineAccountArray = Mysql_Fetch_Array($OnlineAccountQuery);
$UID = $OnlineAccountArray['uid'];
MySQL_Query("INSERT INTO cashtable (userid, zoneid, cash) VALUES ($UID, 1, $Hcash)");
echo"$UID DONE!<br>";
$i++;
}
?>
Code:
#!/bin/sh
/opt/lampp/bin/php -f /jaden/XFVS.php >> logfile.txt 2>&1
Crontab for hourly jaden:
Code:
0 * * * * root /auto60/jaden.sh
Last edited: