Jump to content

Bikkebakke

Members
  • Posts

    40
  • Joined

  • Last visited

    Never

Everything posted by Bikkebakke

  1. Oh, okay thanks, I took a look at the exec() and how to set the privileges correctly, I hope we get it to work. I'll mark this as solved for now. Thanks again! *feels dumb*
  2. I need to make a webpage with a link/button (secured with a password) that (re)starts program(s) on the host computer. I have no idea where to start working on this and I failed to find any help by Googling so I'm now asking for help on forums. Basically the problem is, my friend is hosting a game server on a dedicated host, but for varying reasons the game server crashes every now and then (and usually it crashes just after my friend goes to sleep), so we have to wait untill my friend restarts the server. I recalled, one guy created a webpage where you could do the restarting without having to share the access to the host itself, so I recon I'll figure out how-to to help my friend but unfortunately searching for the solution wasn't as easy as I thought. Anyways, I hope someone could point me towards a solution so I could help my friend satisfy the addiction of a few hundred players by reducing the server downtime. Thanks in advance.
  3. Or could this be easier to do in Javascript/AJAX instead of PHP?
  4. I really doubt I need that advanced stuff, all I need to do is pick a part of text, the first method I tried was: <?php $contents = file_get_contents('http://www.example.com'); $term_search="Search_term"; $no_term=1000; $pos=strpos($contents, $term_search); $pos += strlen($term_search); $new_pos = substr($contents,$pos,$no_term); echo $new_pos; ?> But as of now I don't get the content from another location but from the very same file. So like, is there a way to find text from the same file? I.e. <html-stuff> <div that loads an page in it> <more html-stuff> <?php //$fetch = script to fetch the contents of the previously mentioned <div> echo $fetch; ?>
  5. Hello again, Freaks! I stumbled upon a rather tedious problem that I've been trying to solve for quite some time now. I play this browser-game which includes a lot of clicking so I made a menu (simple page that consists of two frames, one for the menu and one for the game itself) that holds links and forms to lessen the clicking on the actual game. Now I've been trying to find a way to echo my characters HP etc. from the games profile-page to the menu but I can't access my profile-page with file_get_contents();, because it's required to be logged in to see the page. So, after burying that idea I got a new one: Loading the profile page inside the menu frame as a hidden div that reloads every now and then, but I don't know how to find and echo the parts of text I want to, so if anyone could help me on how to echo a certain part of text on the same page the code is ran? Sorry if I was confusing, feel free to ask for more details if needed, - Bikkebakke
  6. Ah, finally figured it out. Incase anyone else faces the same problem: I decided to convert the date/time to minutes and store in a bigint field in database. To convert current time to minutes: floor(time()/60); To break it down: floor() <- rounds the value down time()/60 <- returns current time in seconds (seconds since 1970-something till present) and divides by 60 to convert the seconds to minutes. To echo seconds till the next full minute: echo date("s",60-time()); date() <- date function "s" <- tells the date function to display seconds 60-time() <- 60-current time (in seconds due to the "s"-part)
  7. Hi again, Freaks! I stumbled upon a tiny-weeny problem I couldn't figure out myself, tried googling and searching for a while untill I decided to ask here, so: How do you count how many seconds/minutes/hours etc. it's been since a certain date/time? To be more specific, this is what I need to do: [*]Fetch a datetime from database (YYYY-MM-DD hh:mm:ss) [*]Count the minute difference between that value and current time [*]Add the minutes to the database value (matches current date/time except for seconds) -> This way I can store the minute difference in a variable and use it in a script AND update the datetime value in database without losing any seconds in that minute counting (since I only need to count the full minutes) And I would also need to echo how many seconds left till next full minute. Any help is appreciated. ~Bikkebakke
  8. Got it working, a thousand thanks.
  9. Okay I got it working, except, what format should the file follow at the pages-directory? I.e. <a href="?id=1">Home</a> What does the "?id=1" refer to in the ./pages/ and how do I define it?
  10. Thanks for that, dooper3. Theres no .htaccess file on the server (forced to show hidden files too) so I'd assume I have to make one, is there anything else I need to include in the file than just the lines you quoted? Like, are the following lines required? AuthType AuthName AuthUserFile Require
  11. Hi freaks! It's been a while since I last asked for help I'm done with my first learning project and decided to start a new one with proper planning etc. I want to use dynamic urls but I was unable to find a good tutorial so I decided to ask here, so; Does anyone know a good tutorial which I could learn from or could someone give me a brief explanation on how to create such a system? The idea is to make a page with header, footer, menu and a (content) frame/div where I include() the page. Thanks in advance, Bikkebakke
  12. Theres going to be over 100 skills, the player decides the class and build and develop their characters and as they develop they unlock new and better skills to obtain, one player can never get every skill (and they don't need to because the way the character is built determines which skills are good and which most likely useless) @Nightslyr, a thousand thanks! I'll start working right now! Sorry for consuming your precious time. (And lol at my "How do the 'records' work?" question, I didn't know the rows are called records *feels dumb*) EDIT: The item buy script runs a mysql_query script, that goes something like: $insert_item = "INSERT into `users_items` (`item_id`,`user_id`) VALUES ('$item_bought','$playerid')"; mysql_query($insert_item); Am I on the right road here?
  13. Yea I follow, but there is going to be over a hundred skills, I just need a way to store the skill level for the char and I think it'd be too complicated to implement them that way. :/
  14. Ah, yes now I understand! I just don't recognize the english names as we use finnish clients when working with databases at school. (That's also why it took me half an hour to read trough the article ) I get the basic idea now, but I still can't figure how to set up the database. Am I correct if I assume I'm going to have 3 tables: users table, items table and an extra table that links the player(s) to the item(s)? How do the 'records' work? Sorry for all the hassle and tons of questions but this is the kind of thing you're going to have a hard time learning on your own.
  15. I finished reading the page you linked. If I didn't miss a vital point in the article, it wasn't really the problem here. I was going to create a seperate table with the skill data and link it with the user table but I don't want to add a field for every single item/skill to store the skill level or item amount each player has. But it seems it's the only solution I can think of, so I'll just go with that. :3
  16. Yea I really didn't, this is the very first thing I've ever coded, a kind of learning project. I'll take a look at the link you posted.
  17. Hello, there! I'm coding a browser-game and I'd need to add skills and items soon but I can't figure out how and where to store the character information when it comes to skills or items? It'd be awful if I had to add a seperate field in the user table for every single skill and item I'm going to implement as the field numbers could reach hundreds pretty easily. I figured I could code a script to write the information in a file when the player gets an item or learns a skill but does it get too complicated when the script has to add a certain piece text when a player learns a new skill BUT if the player further trains the skill he/she has already learned the script would have to modify the before written text to replace the skill level, damage modifier etc. effect? Or is there a better way to do this? Thanks in advance!
  18. Thanks for the answer, I altered the battle system already tho Instead of trying to stuff everything in the input value I just did this: <form action='battle_action.php' method='post'> <input type='radio' value='attack' name='action' checked='yes' /> <input type='radio' value='flee' name='action' /> <input type='submit' value='Submit'> And on the battle_action.php page: //Check which action was performed $action = "{$_POST['action']}"; And: switch ($action){ case "attack": echo "$playername throws a rock-hard punch at {$_SESSION['mname']}. <br>{$_SESSION['mname']} loses {$_SESSION['attack']} HP."; $_SESSION['mhp'] -= $_SESSION['attack']; break; case "flee": << Flee script here >> } break; } Oh I just wish I didn't waste hours for nothing. (Except the experience!)
  19. So, I'm building a browser-game and I made a new battle system today, where you choose your 'action' from radio inputs and then submit the value to another php file, where the action is then executed. But, I encountered a problem: I can slip the "attack message" in the value of the input, but I'd need to include the mysql_query in too, but I can't figure out how! Heres the input code: <input type='radio' value='<? echo $attackmsg; $_SESSION['update_damage_taken']; ?>' name='action' checked='yes' /> <input type='submit' value='Submit'> And heres the what the variables do: $attackmsg = "$playername throws a rock-hard punch at {$_SESSION['monstername']}. <br>{$_SESSION['monstername']} loses {$_SESSION['attackamount']} HP."; $_SESSION['update_damage_taken'] = "mysql_query('UPDATE users SET hp = {$playerhp} WHERE id = {$_SESSION['user_id']}')"; But the single quotes ( ' ) mess up the input. Is there any way to do this properly? Or if you got a better idea for a battle system, I'd be glad to hear it out! (As long as it supports multiple attack options) EDIT: Heres how it shows up in browser: But it still doesn't update the player hp in the database, so the mysql_query isn't working.
  20. Oh, wait thats not it Anyways, maybe you can clear out how can I use these? o_o
  21. Okay so thanks for the examples, but I don't really understand it other than seeing the functions so could you point out how I could take advantage of this in the script I'm trying to code? :-\ Could I like...instead of having the attack.php file use the document.getElementById (or something) to pull the php code that I need to run from the same file? And can I use the eval() to display the "Player attacks/Monster attacks"-text as a new text instead of overwriting the previous text? Sorry if this seems confusing but I AM confused (Also, anyone know if/how you can make database fields show negative values as 0 (zero)? // Make the minimum value zero so that the values would never go negative?)
  22. Please, show me examples if you can, and please explain whats happening in them too since I prolly won't understand as I'm not familiar with javascript.
  23. So, I'm building a browser-game and I got a battle system that runs a while loop when you click a button, but instead of running the while loop I'd want the button to run the script only once when clicked on so that I could add more types of "attacks" as buttons to choose from, but I'm not really sure how to do that. Right now I'm using an Ajax script to bring the attack script from a file called attack.php to a div when you click the button, I tried to make the button run an if else script when clicked but the problem is it loads the $-variables again so the 'monster' reloads too (reloads max hp etc.). Heres the ajax script: function doAttack() { // This function does the AJAX request http.open("GET", "attack.php", true); http.onreadystatechange = getHttpRes; http.send(null); } function getHttpRes() { if (http.readyState == 4) { res = http.responseText; // These following lines get the response and update the page document.getElementById('div1').innerHTML = res; } } And heres the button: <input type="button" value="Attack!" name="btn" onClick="doAttack();" > <br /><br /> <div id="div1"></div> I tried everything I could think of but I'm not that experienced in Ajax nor PHP. Any help is appreciated!
  24. So yea, I hope this is the right place to ask this: I'm working on a browser-game and I'd want to add a regen/recovery/recuperation system so that i.e. if you run out of money and can't afford to pay "hospital bill", your hp would regenerate overtime. Or if you already used all the "stamina", it would regenerate so you can go run more "errands" to make some cash. You see it everywhere but it's the kind of thing that's hard to search help for, other than asking from people that know, of course! So please, enlighten me and I'll be beholden for you forever! (Or at least untill I encounter the next problem.)
  25. Oh I was so lost. I figured it out tho', the scripts so long I won't even bother copypasting it. Either way, this simple task was way more complex than I thought.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.