Top

PHP Slots game


PHP Code
+ 1 likes
Please Register to submit score.
Average Score  6.0
Scores Submitted  1
Date Added  Apr 23, 2008
Last Updated  Apr 23, 2008
Tags  game  jonesy  jonesy44  php  script  slots 

Introduction

Fairly useless slots game. hehe. can be used on any named webpage, the script will retrieve the name and re-direct blaaa. not much to it really. i was learning functions, and came up with it :P

Example: http://wfs.myartsonline.com/function/



Grab the Code

Comments

  (24)  RSS
mountaindew
Comments: 1,539
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 1:54 pm
Cool, but I think you should add a button/link that says \"Spin wheels\" or \"Play again\" or something, instead of refreshing the page.
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 2:02 pm
Updated: Using my wild paint skillz, i made an image :P uploading it now, if u wanna use. hehe. it\'s on the test web.

@Dew, doing it now :D (Done it :P)
Hawkee
Comments: 479
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 3:34 pm
The numbers don\'t line up properly for me. They\'re kinda all over the place. You should just do something like:
Code:
<div style=\"float: left;\">number 1</div>
<div style=\"float: left;\">number 2</div>
<div style=\"float: left;\">number 3</div>
<div style=\"clear: left;\"></div>

Maybe add some padding-right to each of the div\'s to space things out evenly.

Now if you really wanted to take this up a notch you could use AJAX and only refresh the reels upon spinning, not the entire page. In fact you should try this as an Opensocial snippet.
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 3:36 pm
i\'ve *never* used AJAX LoL!
i know there will be some errors with the spacing, i used &nbsp; xD lazy. but i\'ll pop some div\'s in and post when it\'s updated. i just fancied trying to make a few php games.

jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 3:50 pm
Is that better Hawkee?
mountaindew
Comments: 1,539
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 3:55 pm
Now the bottom of the slot image is cut off.
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 4:00 pm
that is the closest i can get using div\'s :s
Hawkee
Comments: 479
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 4:04 pm
Still some spacing issues, but it\'s much better. Maybe give each div padding-left: 20px. I don\'t know why you\'ve got 25 then 45, should all be the same. Then give your #slots div a height to match the background image\'s height.
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 4:28 pm
hmmkay. also. i\'ve added an sql db to record scores;

Code:
function slotsScores() {
  $pos = 1;
  $ip = ($_SERVER[\'HTTP_X_FORWARDED_FOR\'])
      ?  $_SERVER[\'HTTP_X_FORWARDED_FOR\']
      :  $_SERVER[\'REMOTE_ADDR\'];
  $sql = mysql_query(\"SELECT * FROM `slots` ORDER BY `cash` DESC\");
  while ($c = mysql_fetch_array($sql)) {
    if ($c[\"ip\"] == $ip) {
      echo \'<b>@ \';
    }
    echo $pos. \' - $\' .$c[\"cash\"]. \'</b><br>\';
    $pos = $pos + 1;
  }
}


however;

Quote:
Top Scores;

1 - $8100
2 - $4750
3 - $300
@ 4 - $10800


it orders correctly, apart from my score :s
Bouncer
Comments: 120
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 5:29 pm
Once you hit the 10,000 mark it starts you over at the bottom of the ranks list.
Bouncer
Comments: 120
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 5:42 pm
To expand a bit further on that, at 1,000 you go to the bottom, then again at 10,000 and I am betting again at 100,000. I know nothing of php and how to fix that, just decided to help test this out and give some advice.
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 5:52 pm
thanks, i see you\'ve been winning a bit too hehe ! ti\'s addictive. but my server maxxes out at 1,500 connections / hour. so it\'ll reset on the hour. your score is saved :P

im looking into sorting that problem. and when i do, i wil update the script on here. which now runs soeley on sql, rather than the sessions you see here.
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 5:53 pm
also, possible updates, to make it more realistic, a \"nudge\" button :P
Bouncer
Comments: 120
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 5:57 pm
Yeah, addicting it is, especially with other users to go up against :P Also a short time ago I got an error on the webpage it is on. A whole lot of warning going down the screen and it hasn\'t cleared up yet. It\'s been that way for about 10 minutes or more now. I don\'t know if you are resetting or not, but figured it was worth mentioning.
Bouncer
Comments: 120
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 5:58 pm
And when I finally decide to say something, it clears up, lol. Oh well, at least I can play again :P
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 6:19 pm
haha, go nuts. the message system isn\'t 100% working atm, i cant flush the headers which is an ass. anyways. have fun, and invite friends :P

haha

if it goes down again, just wait untill the new hour, it will reset itself, (it\'s a shoot server) so it cocks up xD
Bouncer
Comments: 120
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 8:18 pm
Another problem I just noticed. It saves your score, but if you ever disconnect from the page and go back, even if you use the same nick, you start over on your score. Your old one is still listed there, but you start a new one when you re-connect. :S
F*U*R*B*Y*
Comments: 551
 
PHP Snippet:  PHP Slots game
Posted on Apr 23, 2008 10:14 pm
i dunno how your doing the scores, in to the database, haven\'t really looked, but if you insert them as 1234567 and 134 then just do ORDER BY score DESC then when echo\'ing use, number_format($something[score]);

should solve the problem
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 24, 2008 1:43 am
Your IP has changed, Bouncer :-s
Perhaps a username and pass would be better ..

okay, i will try when i get back from school, furby :P
Bouncer
Comments: 120
 
PHP Snippet:  PHP Slots game
Posted on Apr 24, 2008 4:27 pm
Wasn\'t aware I had a dynamic IP jonesy44 but that would explain it wouldn\'t it, lol. Sorry about the confusion on my part then.
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 24, 2008 4:40 pm
haha, not at all. I\'m hopin to code an arcade style thing soon, so it will have a login system and all. :P

im looking into to seeing if i can actually grab a completely unique ident for a computer, like a mac address or something. im no genius as server side stuff, apart from i can do some php/sql xD
jonesy44
Comments: 907
 
PHP Snippet:  PHP Slots game
Posted on Apr 24, 2008 5:43 pm
***FIXED***

The ordering wasnt working as i set it as a varchar rather than int, it\'s now sorted :-)

So it should be ready to be updated on here by tomorow :-)
Hawkee
Comments: 479
 
PHP Snippet:  PHP Slots game
Posted on Aug 25, 2008 11:27 pm
Your example doesn't seem to be working anymore.
Hawkee
Comments: 479
 
PHP Snippet:  PHP Slots game
Posted on Aug 25, 2008 11:33 pm
This would be neat as an OpenSocial app. You can run it through our Hawkee container to come up with a high score rank with your friends. Here is an example, http://www.hawkee.com/snippet/4818/ - Just create an XML document containing your code and paste the URL into the Test Script box. You can even store the scores on our database.

Please Register or Login to start posting comments.
Bottom