-
Posts
1,150 -
Joined
-
Last visited
-
Days Won
4
Content Type
Profiles
Forums
Events
Everything posted by Script47
-
The main reason people use voting scripts/sites is to publicize their site and keep it competitive among other players. For you to keep it local defeats the whole purpose of the voting feature. If you do want to create what you said which is what I would call daily rewards, where the users goes on a page and claims a reward you could very easily do that. I don't really write random code for people on threads but meh, my opinion is MWG is going to close soon as it has lost a lot of valuable members so why not help people before it goes down. If you find errors, try fix them. I wrote this module in the forum message box, it is late and my eyes are stinging. I could make excuses all day. In users table: ALTER TABLE `users` ADD COLUMN Reward_Collected INT NOT NULL DEFAULT 0; In Day Cron: $db->query("UPDATE `users` SET Reward_Collected = 0 WHERE Reward_Collected = 1"); dailyReward.php include 'globals.php'; echo '<h3>Daily Rewards</h3>'; echo '<a href="dailyRewards.php?claim=true&ID="'{$ir['userid']}'">Claim Reward</a>'; // If it is an empty echo blame MWG and add a line break in between. If you don't know how to do a line break well then I give up and say learn HTML first. echo '<br/>'; // Check if user is trying to claim reward. if(isset($_GET['claim']) { if(!isset($_GET['ID']) || trim(empty($_GET['ID'])) ) { // Error message as ID field is not set. return; } else if(ctype_digit($_GET['ID']) == FALSE) { // Error as ID is not integer. return; } else if($ir['Reward_Collected'] == 1) { // Error reward has already been collected. } else { $ID = htmlspecialchars(trim($_GET['ID'])); // Random money amount from between 1-1000 $randomMoney = rand(1, 1000); $updateUser = $db->query("SQL QUERY HERE UPDATING Reward_Collected FROM 0 TO 1 AND ADDING ON MONEY WHERE USERID = $ID"); if($updateUser) { // Query successful return; } else { // Query failed return; } } } Script Explained Step One The SQL query we made creates a column where by default the value is 0 which in this case means user hasn't voted. This is pretty much the only check you have so if you didn't have this the script wouldn't work as intended. Step Two The cron fires each day and changes the new column which we inserted to 0 again at the end of the day (server time). This again is important as people would not be able to collect rewards as they would be stuck on 1 forever. The important part is the code including and after the WHERE. This doesn't update every single user so it is optimized, it only updates the users who have voted. Step Three The actual script which allows user to claim the reward, is very simple. echo '<a href="dailyRewards.php?claim=true&ID="'{$ir['userid']}'">Claim Reward</a>'; The above code has the extension on following on from the ? (question mark). claim=true Will be used to see if user has clicked the link, only if they click the link or type that URL in to the URL field will the PHP code below it run. We pass the users ID through ID="'{$ir['userid']}'" this can later be accessed by GETTING (hint) the ID which is why we use $_GET. You can add a lot of parameters and all you have to do is connect each one with & then the identifier (the variable name) then an = sign then the value of that variable. I mainly use this to stop me having to create lots of files etc, so lets take the register page as an example, some people would have a form which leads to another page, where as I would set the submit form/button with a name a check using PHP if that button is set then do all the other validating/querying. But wait!? Why not use $_POST? Because we are not posting any data via a form so we can't, we are passing variables through the URL which can then be reached by GETTING them. // Check if user is trying to claim reward. if(isset($_GET['claim']) { if(!isset($_GET['ID']) || trim(empty($_GET['ID'])) ) { // Error message as ID field is not set. return; } else if(ctype_digit($_GET['ID']) == FALSE) { // Error as ID is not integer. return; } else if($ir['Reward_Collected'] == 1) { // Error reward has already been collected. } else { $ID = htmlspecialchars(trim($_GET['ID'])); // Random money amount from between 1-1000 $randomMoney = rand(1, 1000); $updateUser = $db->query("SQL QUERY HERE UPDATING Reward_Collected FROM 0 TO 1 AND ADDING ON MONEY WHERE USERID = $ID"); if($updateUser) { // Query successful return; } else { // Query failed return; } } } The above is very simple and the comments should suffice and help you understand the code, the first if() statement checks if the link is pressed, there on we check if the ID is empty and if it is not an integer (number) and give errors if you we need to (which you'll need to add). We check if the field is 1 in Reward_Collected, which mean the sneaky buggers are trying to get more or have made an honest mistake. So we give them messages again which you'll have to add. Then if all that works out without errors, then we (you) will make the query which I purposely haven't provided (hey now, you've got to do some work at least!) but I have very clearly wrote in words what you have to do. Last if() statement checks if the query ran successfully or not and you again will need to write the messages as you feel. Challenge I have coded this, time for you to learn too. I doubt many people will do it, but this is for those who wish to learn and improve. Try adding the new features listed below. The amount of money you get increases each day you vote in a row. Allow more rewards for example, items, secondary currency of your choice. Make which one you get random too. Add a staff side where you can set how much money you get as the reward. If you have tried these and are struggling or would like to show off (yes, you're allowed to do it a little). Then don't hesitate to mail me, tweet me or contact me any other way.
-
Metal Gaming || Marine Commando || In Progress
Script47 replied to WildHosting's topic in Game Projects
Mainly an off topic question, how much of this did you code? Only asking this question because I hated C++ and dunno how one can code a game like this in it. xD -
Metal Gaming || Marine Commando || In Progress
Script47 replied to WildHosting's topic in Game Projects
I'm definitely interested on how this turns out, it is very different to the norm around here and looks awesome. Reminds me of CSS (Counter Strike: Source). What language is programmed in? Will it support Linux/Mac? -
Metal Gaming || Marine Commando || In Progress
Script47 replied to WildHosting's topic in Game Projects
This might sound critical but I just want the following questions cleared up. What makes this game different compared to others? Do you have any long term goals/aims? If yes, would you share? What sort of support will you provide for customers who are having technical difficulties? What sort of launch do you expect? Meaning do you expect it to be successful right away or gradually build up? If you do get popular the developer (you pick now) will he become part of a team if need be? Will he get left behind? Would he become lead developer? In short what does the future hold for this developer? What language is programmed in? Will it support Linux/Mac? -
Metal Gaming || Marine Commando || In Progress
Script47 replied to WildHosting's topic in Game Projects
Will you allow 3rd party mods? So will you allow people to modify and add stuff to the game? -
I'm not against jQuery, actually I like jQuery a lot, I just mean that I'm trying to keep the raw Javascript.
-
Metal Gaming || Marine Commando || In Progress
Script47 replied to WildHosting's topic in Game Projects
This looks sweet, will this be released on Steam? -
Yes, some of you may not be the biggest fans of it but Runescape is created using Java (among other languages). That is a very powerful game. But yes, it will take a while (years) to get a game like that up and ready - that is if you're learning it all from scratch.
-
What do you mean by you know what it means but don't know how to fix it? Surely if you know what the error is saying then you know where to look and how to fix it?
-
I want to try something new/different. I don't care what but I want something else to do. A new language? A new project? I need some time away from the day to day web development languages. Post any ideas you have or languages or any other stuff.
-
Aaaaaite new update. New Version: Some Version Number here! What this update includes? Key binds Improved attacking Experience Levels Tutorial http://maprpg.my-jsgames.tk/
-
Hahaha, yes I plan to hopefully. But the map is just 500 x 500 so it may get cramped. I'll see what I can do.
-
Thanks. Pfft, using jQuery when JavaScript could have done the job! :p Key binds will be added in next update. Adding graphics. :) Edit: Question, shall I make the grass smoother? [ATTACH=CONFIG]1572[/ATTACH]
-
That was the plan but it got too late lol so I went to bed. :p The moment you touch the red enemy you will initiate combat, which stops you from moving until either one you die. I should probably put that in the log.
-
Made this, was bored. Feedback welcome, still more to come. Map RPG Layout may be fuxed a little. xD
-
D'oh, you disappear for ages lol now you're leaving... :( </3 Good luck! :)
-
Good luck! Looks forward to seeing it, I remember you made ChatRPG (hopefully my memory isn't failing me).
-
Strange, I tried it and I never needed to! :eek:
-
NEW UPDATE, FULL RELEASE! Version: 1.0 http://survive.my-jsgames.tk/ This update includes:
-
Without registering means (if I'm not mistaken), go on site name your character for game purposes, maybe not even that and you're playing?
-
Yeah, MySQL is very important. Learn it.
-
True. How about these? Link Link Link Link JSFiddle
-
PM [MENTION=69001]Zettieee[/MENTION] or [MENTION=65100]W3Theory || Peter[/MENTION] both make excellent designs.
-
The title is quite clear, I was thinking of making one from scratch as I've got quite 'o bit of free time, but the main question is, is it going to be worth it? Is there still a market for text based games? If not what sort of things (web development wise) is there a market for?