Jump to content
MakeWebGames

[mccode] Send Crystals


CraigF
 Share

Recommended Posts

I have been on DBS for about 5 days now and i have got a few mods off here, and i have never coded before, but today i have been looking at the codes, and editing a few, and i decided to test my new skill. so decided to make a "send crystals" mod. so here it is, tested and working!!! made by me using the "sendcash" mod from dabomstew!

make a new called "sendcrystals.php" and put the code as:

<?php

session_start();

require "global_func.php";

if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }

$userid=$_SESSION['userid'];

require "header.php";

$h = new headers;

$h->startheaders();

include "mysql.php";

global $c;

$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());

$ir=mysql_fetch_array($is);

check_level();

$fm=money_formatter($ir['money']);

$cm=money_formatter($ir['crystals'],'');

$lv=date('F j, Y, g:i a',$ir['laston']);

$h->userdata($ir,$lv,$fm,$cm);

$h->menuarea();

$_GET['ID'] = abs((int) $_GET['ID']);

$_POST['crystals'] = abs((int) $_POST['crystals']);

if(!((int)$_GET['ID']))

{

print "Invalid User ID";

}

else if($_GET['ID'] == $userid)

{

print "Haha, what does sending crystals to yourself do anyway?";

}

else

{

if((int) $_POST['crystals'])

{

if($_POST['crystals'] > $ir['crystals'])

{

print "You dont have that many crystals!";

}

else

{

mysql_query("UPDATE users SET crystals=crystals-{$_POST['crystals']} WHERE userid=$userid",$c);

mysql_query("UPDATE users SET crystals=crystals+{$_POST['crystals']} WHERE userid={$_GET['ID']}",$c);

print "You sent {$_POST['crystals']} crystals to ID {$_GET['ID']}.";

event_add($_GET['ID'],"You received \${$_POST['crystals']} from {$ir['username']}.",$c);

$it=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid={$_GET['ID']}",$c) or die(mysql_error());

$er=mysql_fetch_array($it);

mysql_query("INSERT INTO cashxferlogs VALUES ('', $userid, {$_GET['ID']}, {$_POST['money']}, unix_timestamp(), '{$ir['lastip']}', '{$er['lastip']}')",$c);

}

}

else

{

print "

Sending Crystals

You are sending crystals to ID: {$_GET['ID']}.

Amnt:

 

";

print "

Latest 5 Transfers

Time User From User To Amount

$q=mysql_query("SELECT cx.*,u1.username as sender, u2.username as sent FROM cashxferlogs cx LEFT JOIN users u1 ON cx.cxFROM=u1.userid LEFT JOIN users u2 ON cx.cxTO=u2.userid WHERE cx.cxFROM=$userid ORDER BY cx.cxTIME DESC LIMIT 5",$c) or die(mysql_error()."

"."SELECT cx.*,u1.username as sender, u2.username as sent FROM cashxferlogs cx LEFT JOIN users u1 ON cx.cxFROM=u1.userid LEFT JOIN users u2 ON cx.cxTO=u2.userid WHERE cx.cxFROM=$userid ORDER BY cx.cxTIME DESC LIMIT 5");

while($r=mysql_fetch_array($q))

{

if($r['cxFROMIP'] == $r['cxTOIP']) { $m="MULTI"; } else { $m=""; }

print "

" . date("F j, Y, g:i:s a",$r['cxTIME']) . "{$r['sender']} [{$r['cxFROM']}] {$r['sent']} [{$r['cxTO']}] \${$r['cxAMOUNT']} ";

}

print "

";

}

}

$h->endpage();

?>

Next - Open "viewuser.php"

and find:

(for me its line 128)

after you found that, paste below it:

save and upload them and your done!!!

Link to comment
Share on other sites

Re: Send Crystals FREE!!

sorry, NOOB QUESTION:

where do i put:

CREATE TABLE `cryxferlogs` (

`crID` int(11) NOT NULL auto_increment,

`crFROM` int(11) NOT NULL default '0',

`crTO` int(11) NOT NULL default '0',

`crAMOUNT` int(11) NOT NULL default '0',

`crTIME` int(11) NOT NULL default '0',

`crFROMIP` varchar(15) NOT NULL default '127.0.0.1',

`crTOIP` varchar(15) NOT NULL default '127.0.0.1',

`crCONTENT` longtext NOT NULL,

PRIMARY KEY (`crID`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

If i dont get told, i cant learn =D

Link to comment
Share on other sites

Re: Send Crystals FREE!!

Maybe that was a poor choice of words...

How about: If I don't ask questions, I might end up taking longer to find the answer.

http://www.mysql.com or http://www.mysql.org

http://www.phpmyadmin.net

To answer this piece of your question...

You need to use a MySQL client to create your tables. Your host should have provided you with some sort of tool to do it... phpMyAdmin being the most common. If not - you can find a nice *safe* directory and upload phpMyAdmin yourself, configure it to connect to your database and then voila!

Once you either get the command line (should you have shell to your host) or the phpMyAdmin up and running... you simply need to look around for how to execute a SQL command.

Link to comment
Share on other sites

Re: Send Crystals FREE!!

 

How about: If I don't ask questions, I might end up taking longer to find the answer.

that is more like the right words i should of said!

 

I see it more as a "If i cant be bothered to spend time struggling and learn, I get told"

I could be bothered but i had lots of work to do to try and i believe its easier for people to inform me because it doesnt cost them to help me!

lol thanks guys, I have PHPMYADMIN on my host =Di have entered it where the cashxferlogs are in it. but wen i send my crystals it doesnt go into the logs, same when i send cash!

Link to comment
Share on other sites

  • 3 months later...

Re: Send Crystals FREE!!

 

ty $hot! i know i did this but i used Dabonstews code first and then DaKing has done something not using my code but he still did something lol! =D this is a good community!

$hot and DaKing ???

None existant ?? lol

they used to be

Link to comment
Share on other sites

  • 1 year later...

Re: [mccode] Send Crystals

ok i added this and i get an error when im trying to look at the log in the admin panel

error: Fatal error: Call to undefined function view_cry_logs() in /home/life/public_html/admin.php on line 86

in admin.php

line: case 'crylogs': view_cry_logs(); break;

Link to comment
Share on other sites

Re: [mccode] Send Crystals

 

ok i added this and i get an error when im trying to look at the log in the admin panel

error: Fatal error: Call to undefined function view_cry_logs() in /home/life/public_html/admin.php on line 86

in admin.php

line: case 'crylogs': view_cry_logs(); break;

yes i have the same prob anyone got any ideas to why???

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...