Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[HELP] = Shop Gold adquired per hour played

Newbie Spellweaver
Joined
Jan 9, 2012
Messages
73
Reaction score
0
Hey guys :) I'm trying to make a script where players above level 50 receives 5 gshop gold per hour played, so there won't be anyone creating new characters in order to get gold for free , so I thought that it could be even better if the players above level 100 got 10 cubi per hour.. so,

Players Level 50+ = 5 cubi per hour
Players Level 100+ = 10 cubi per hour

Well.. now the script part which is kinda hard, I suppose I need to have a crontab running on the
Virtual Machine at an interval of time. (example : every 1 hour).

So I think I would need to have the script .sh which runs the whole thing, and the script .php (configuration).. I tried to make the .php but i'm not sure if it's right.. so guys, I beg u for help, im about 1 month trying to do it myself.. I even bought some .php books that helped me a bit , but not enough :{

script .php
PHP:
<?php
error_reporting(0);

include ('mymysqlsettings.php');

mysql_connect("$pwhost", "$pwuser", "$pwpass")or die("Connection failed");
mysql_select_db("$pwdb")or die("Database not exist");

$prepare_w = mysql_query("SELECT * FROM point WHERE zoneid IS NOT NULL") or die (mysql_error());
$top_num = 0;

$data = date("Y/m/d H:i:s");

$query_sn = mysql_query("SELECT sn FROM usecashnow");
$sn = mysql_num_rows($query_sn);
$sn = $sn * "-1";
if($sn <= 0) { $sn = $sn + "-1"; }

while($array = mysql_fetch_array($prepare_w)){

$id = $array["uid"];
$prepare_e = mysql_query("SELECT * FROM roles WHERE account_id = '$id' ORDER BY role_level DESC LIMIT 1") or die (mysql_error());
while($pegaLV = mysql_fetch_array($prepare_e)){
$level = $pegaLV['role_level'];
if($level >= 50){
$Amount = 500;
if($level >= 100){
$Amount = $Amount + "500";
$top_num = 0;
$top_num++;

$uweb = mysql_query("INSERT INTO usecashnow (userid, zoneid, sn, aid, point, cash, status, creatime) VALUES ('$id', '1', '$sn', '1', '0', '$Amount', '1', '$data')") or die (mysql_error());
$sn--;
}
}
}
}

echo "Total <?php
error_reporting(0);

include ('mymysqlsettings.php');

mysql_connect("$pwhost", "$pwuser", "$pwpass")or die("Connection failed");
mysql_select_db("$pwdb")or die("Database not exist");

$prepare_w = mysql_query("SELECT * FROM point WHERE zoneid IS NOT NULL") or die (mysql_error());
$top_num = 0;

$data = date("Y/m/d H:i:s");

$query_sn = mysql_query("SELECT sn FROM usecashnow");
$sn = mysql_num_rows($query_sn);
$sn = $sn * "-1";
if($sn <= 0) { $sn = $sn + "-1"; }

while($array = mysql_fetch_array($prepare_w)){

$id = $array["uid"];
$prepare_e = mysql_query("SELECT * FROM roles WHERE account_id = '$id' ORDER BY role_level DESC LIMIT 1") or die (mysql_error());
while($pegaLV = mysql_fetch_array($prepare_e)){
$level = $pegaLV['role_level'];
if($level >= 50){
$Amount = 500;
if($level >= 100){
$Amount = $Amount + "500";
$top_num = 0;
$top_num++;

$uweb = mysql_query("INSERT INTO usecashnow (userid, zoneid, sn, aid, point, cash, status, creatime) VALUES ('$id', '1', '$sn', '1', '0', '$Amount', '1', '$data')") or die (mysql_error());
$sn--;
}
}
}
}

echo "Total $top_num";
mysql_close($Link);
?>$top_num";
mysql_close($Link);
?>

Thanks in advance.
 
Newbie Spellweaver
Joined
Jan 9, 2012
Messages
73
Reaction score
0
@Pilad
I haven't done the mysqlsettings.php yet, but I suppose it's easy to make.

@343
Thanks dude, it really helped me, but not enough yet .


I think I will have to buy the script that works for 30 bucks.. I can't make it myself :((
 
Upvote 0
Junior Spellweaver
Joined
Apr 14, 2011
Messages
167
Reaction score
38
In any php scripts that I have seen, to add cubis it's :

MySQL_Query("call usecash('$id',1,0,1,0,$Amount * 100,1,@error)") or die ("MySQL Error!");

I hope this could possibly help you
 
Upvote 0
Nerd-IO
Loyal Member
Joined
Feb 13, 2009
Messages
3,303
Reaction score
651
I give you a sample script but it only check online accounts and give them 5cubi... It doesn't check roles level and so on.

/var/www/cubiperhours.php
PHP:
<?php
$db = mysql_connect( 'localhost', 'root', '' ) or die ('Connection to MYSQL server failed!');
mysql_select_db( 'pw', $db ) or die ('DB not found!');
$cubi = 500;
$result = mysql_query("SELECT * FROM users WHERE users.id IN(SELECT uid FROM point WHERE zoneid=1)");
while($row = mysql_fetch_assoc($result)){
    mysql_query("call usecash('".$row["ID"]."', '1', '0', '1', '0', '$cubi', '1', @error)");
};
mysql_close($db);
?>

/root/cron.pw/cubiperhours.sh
Code:
#!/bin/sh
wget http://127.0.0.1/cubiperhours.php
rm *php*

/etc/crontab
Code:
60 * * * * /root/cron.pw/cubiperhours.sh
 
Upvote 0
Newbie Spellweaver
Joined
Jan 9, 2012
Messages
73
Reaction score
0
wow, thanks a lot Romulan!! I got headache due to my 'overthinking' about that script, I will try to don't let players create more than 1 account per day in order to stop the creation of accounts and free cubis. xD
 
Upvote 0
Elite Diviner
Joined
Mar 12, 2009
Messages
472
Reaction score
59
how do you handle to stop people to create massive account for cubis? :D since IPv4 are limited and it would be shared on LAN, or you just limit 1 account creation /day :p xixixi yea yea "overthinking" is kind of the way to rude your server :D no offense just my opinion, i've been there and done there :D
 
Upvote 0
Newbie Spellweaver
Joined
Feb 23, 2010
Messages
48
Reaction score
2
That Automaticly Or Manual ?
its automatic. that's why he uses cron. >: |

OMG it seems like very complicated, good luck then
It's not. You just don't have any programming experience what so ever.
The "point" table in the database holds all the users that have logged in the game. "zoneid" is a field in point table. It's 1 when a user is online and 0 when not. The script is just iterating through each record in "point" table and sending gold to the user id associated with it.
point table:(may not beaccurate)
---------------------------------
|userid|zoneid|
---------------------------------
1201 |1 <-- online
217 |0
1192 |0
762 |1 <-- online
9123 |1 <-- online
 
Upvote 0
Newbie Spellweaver
Joined
Jan 27, 2009
Messages
23
Reaction score
0
And how would the cubi code for those living online, only to who is level 150 and god and evil cultivation 3?
 
Upvote 0
Back
Top