Monkuar
Members-
Posts
987 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Monkuar
-
Curious if I should move to Socket.io for this
Monkuar replied to Monkuar's topic in Application Design
Well I just actually got socket.io installed and now that I think of it, this mysql stuff seems worthless now. Looks like socket.io is only good for bandwidth (chat) data packets being sent in real time across the server. If MYSQL resources the same as the while loop in php as in longpolling to socket.io mysql module, what a complete and utter waste of time this has been, lol. Although, since I got it on working on windows, I would love to query the monsters table and let my users attack the mob faster/etc. I assume this could be faster with socket.io though, but wouldn't save performance? wouldn't it save a little bit because php isn't processing any of it? -
I am making a turned based rpg text game. But I get $.post within jquery for the attacking a mob sequence. Each time a user attacks a mob (everything is validated serverside) and processed via $.post and then I append that data to the my page (the output of what happens) I use like 2 extra queries just to simple check how much damage the user is doing and a UPDATE query to update the monsters loss of LIFE in the mysql. And maybe 1more query to grab monster data or whatnot. I am curious though, If I use socket.io with mysql.... a user could essentially kill mobs faster because it's all done in 1 connection and they dont have to wait for the 200ms delay via AJAX. But it wouldn't really save any performance would it since it's turned based already and the queries are < 3 needed per each attack? I'm just trying to make it faster for users to hunt and kill mobs w/o having to wait for stupid little ajax requests. Thoughts? I also do random captcha's every xx amount of battles and each time a user level's up so they cannot bot or macro. Not sure if this would effect socket.io [i might be going off a tad here] Edit: also I cannot get node.js/socket.io to work with WAMP on windows, such a pain the ass man. I can prob get it working on my linux/vps box but I HATE editing/working off of my localhost... Also, I dont understand this: http://www.gianlucaguarini.com/blog/push-notification-server-streaming-on-a-mysql-database/ They're literally putting the mysql into a loop.... This is the exact same crap as a While loop in php with longpolling is it not? How can this use any less resources I mean seriously, socket.io a joke or what?
-
Okay, I feel a lot more comfortable now about thinking of socket.io and winsocket. Thank you for such clear explanations Kicken, greatly appreciated. I know some of these questions are kind of "Herp derp" but I'm just literally laying it all out, I don't care what people think of me anymore. So now that I understand socket's a bit more. Let me see if I got it right: I refresh a page with socket.io and now I am officially connected to the server. If the server wants to output "hello world" I could tell the server to do it that via server admininstration right or a command. And it would in essense display it to all users connected? (Same for software that uses winsock) So being connected doesn't necessarily mean querying unless like you said, having a chat system with a database for storage or logging or whatnot. But a simple global chat system, could just be data that is being sent to all clients connected, but doesn't really need MYSQL Or UPDATES OR any QUERYING because it's just data being outputted to everyone. So it's more of a bandwidth usage issue in the long run? All that data of people's chat messages being sent across a active connection of 100-200 users would rape bandwidth more than mysql data/querying (since we dont need mysql unless for storage or w/e). This is also why whenever I log out of some MMO's, all my message history is gone. [but changing channels or going to character selection they stay there] using a temporary session solution most likely? But yeah 1 Thought... For a html 5 game where the server needs to spit out the coordinates of each user on the screen (X,Y, Z) using a 300 milisecond ajax request to update everything would be terrible as in-compared to just using socket.io right? So this technology socket.io is merely the same as winsock? Winsock has been around since what 1999? Why did it take them this long to release it for browser technology?
-
You need to cast proper variables on those id's and check for integer/etc. mysql_real_escape_string wont help you from XSS. Also you need to have a primary key that is SET TO AUtO INcREMNET in that database, lol. (for new postS)
-
When you say a persisten socket, does this mean the chat table is being queried like every second in essense?( For a chat room for example) or only when new data is available? Even if it does do it when new data is available a simple 10-20room chat room with all active users using socket.io wouldn't that just rape the server? How does MMO's do it with World/Trade chat? Thousands of active users just querying that table/refreshing it across all people, seems a bit overlord? Would this be why sometimes if u DC you lose data on ur character because it wasn't saved to Server? (Wouldn't this need to be updated like every second as well) for no data loss? How do these servers perform so good under these load, I dont get it :/ I'm am making a web based RPG, I got inventory system done with jquery/drag/drop/monster battle AI/loot functions to give loot based on char level/etc (when monster died) /etc/etc, but if I do PVP it will obviously be turned based, but not sure if I want to do comet/longpolling/simple 1-2sec ajax/socket.io.... I also looked into the server files for a Diablo 2 Private Server, they store all character data into a .d2cs file or something on the server, then that file get's written everytime a person finds a item or whatnot, (get's read and written from the client) which we don't got source code for, only David Brevik does. Also, does every windows programmed MMO/Multiplayer game have to use Winsock?
-
I'm curious how a client or game connects to mysql and updates it. In Path of Exile, u have a item that lets you change the amount of sockets a item has. For instance, everytime when a user uses the item (They could have over 2000) on the item.... is it in essence 1 MYSQL UPDATE EACH time? (1 query)? Or how exactly does it register through the server or sustain lower optimization or performance? i know this sounds dumb, but I've always wondered this stuff. If that is true, wouldn't those queries and all the active users just rape the servers? I've looked into socket.io / etc is that kind of like the same thing as Winsocket? (Wouldn't this be even MORE server intensive with an active connection?) Just curious, I know you guys think I am clueless and have no idea what im talking about, but please... Also, im curious on why people say socket.io is better? If you have a chat system using socket.io and 5 active users. It's constantly refreshing and querying from the chat table to display all the data right? Wouldn't a simple ajax poll every 2-3 seconds would be fine? O_o I know this wouldn't really work for MMO's because it would be laggy data, but then in essence is that socket.io grabbing all the data from the chat table (querying it) every second? Wouldn't that just destroy the server @_@
-
No it doesn't, because it just reads it as text. It spits out "5,2,1" instead of 1 rand of each. "5,2,1" is the same as array(5,2,1) but php thinks if you put in a variable array($temparray), $temparray = "5,2,1" it think's it's 1 word, it's not.
-
$monsterdata['droparray'] = "5,2,1"; $item_id_loot = array($monsterdata['droparray']); echo 'Drop Array: '.$item_id_loot[array_rand($item_id_loot)].' This DOESN't work.... but this does: $item_id_loot = array(5,2,1); echo 'Drop Array: '.$item_id_loot[array_rand($item_id_loot)].' Why? Wat the.. Is it because it's set to Varchar in column? (mysql) Lawl, another php bug zz will report
-
haha nice pun But seriously, my items and stuff are already in a row.. I'm just going to use the WHERE IN clause in my query, so I'm just generating these random id's to select what items they will get after the monster has died. These id's will be used in a where in CLAUSE (in mysql) to grab the item info/etc and insert their "NORMALIZED" data to their inventory/etc I'm going to have each mob have different loot, let's say Mob 2 will have a chance to get the items with the id of 2,3,5 so I just need to select a random of these to use in the where IN clause to grab all the data and insert it. (makes it very good for RNG based)
-
Okay, so my monsters table has a column called "droparray" for example: 7,2,5 7,2,5 are the id's of the items they could POSSIBLE get when they kill the monster [intuitive eh?] I need a way to just select a random number from those 3 numbers (or any amount) AND a way to let's say if 7 was a unique item, have it a less % chance. Any ideas?
-
Well, if u code for a living u could prob get the free classroom license lol Just say your a teacher
-
Yeah, I could see why this game was developed/coded around 99 and 2001. Probably before that too, the origin of this game was "RYL" Risk Your Life, developed by a company called "GamaSoft". Game is a very fast-paced game, so I always wondered how they stored their equipment and inventory stuff. I guess they did it the worst way possible. Since Im creating my own rpg game. for my inventory system, it's very simple. just grab all user's items by user_id = 4 (me) and have a position column, [ 1 - 36 ] would tell each slot the user dragged the item to. Then just put those in a multi demi lovato array, and spit them out [ No pun Demi Lovato <3 ] This is what I do with my game. My only issue is that, I am not using a websocket or socket.io bcz it's not working on windows so I cant really test with it. I'm simply doing onclick ajax calls via jquery. I might do some comet, long polling for PVP battles, but not sure. I need to finish all my serverside stuff done first. now im working a Loot allocation system, which is weird because I don't want to waste queries by checking if a user owns a Health Potion already, to just increase the quantity of it, or just insert it into a new row, then update it when they go to their inventory page. These decisions and looking into how these older games stored info, makes my experience very interesting while making my game, I'm glad I did not do it this binary way. But maybe that was the Norm back then? In any event, thanks all for the replies, I feel like I am at closure now, great info lol. I was always curious about how they stored their stuff. Looks confusing as crap imo. Unless we got source code of their C File to decode it all? But still wouldn't really matter, Im never doing it this way, rather I just add a new row.. lol Btw, I'll be looking into that pack function, seems pretty close to what they did within their c file. Ty Kicken! (Plus it makes me feel kinda cool to do it that way, but i bet optimizations as in-compared to other functions are terrible scaled) Edit: mac_gyver You actually joined on my bday, ironically u got the best answer solved for this topic, lol !
-
Yeah but I don't got time to edit/fiddle around some editing program, I just right click my files, notepad++ and go, no need to mess around with colorizing stuff. Notepad ++ is already colorized every language onclick from the language dropdown menu Plus PHPStorm is bloated :/ and costs $.. http://www.jetbrains.com/phpstorm/buy/index.jsp
-
PHPStorm is a joke unless you like unreadable rainbow colors. Notepad ++ is clean and has plenty of plugins to support it. Been using it since I was like 15
-
Even I am still here, don't leave out of just a frivolous ordeal, I've been hammered and verbally abused here as well. I aint leaving, lol. This place still has very smart PHPer's someone has to submit
-
Been looking at the mysql patterns for this very old game that was made in 1999-2001 called "Return Of Warrior" (Downloaded some private server files and checked how they stored the equipments and items for players) Looked into their mysql column for users equipment and it was a binary code: (0xB62600000000B7260000000000000000000000000000B5040000BF230000). And the user only had a 1h Sword with 2-5 damage on it, etc. (Weird?) How is this data read and stored? Would i need the source code in c++ to read it out? And for users inventory it looks like this: So i'm just wondering, what kind of storing method was this and wouldn't be terrible for scaling and pulling data? For my game, I have a simple user_equip_items and user_misc_items (for potions/scrolls/enhancments/etc) and equips for gear. And then just calling them from the table.... How would all this work via the way the binarycode does above? (I've always wondered this) Btw, the game is coded in c I believe. AND to make this Question PHP Relevant!.... How would we read and store this binary data in PHP? (Example, getting a 2-5 dmg 1h sword from that equip field data lol) The real question is, were the developers very smart doing it this way? Or stupid? (serious question btw)
-
SELECTING A random Value but with a Percentage.
Monkuar replied to Monkuar's topic in PHP Coding Help
Don't know if this is a very intuitive approach to this issue but it seems to work fine? //Unique Bosses/etc.... $randmobchance = mt_rand(0, 100); if ($randmobchance <= 5) //5% to Grab a Unique mob... { $spawnmobs = $db->query('SELECT * from nrpg_monsters WHERE level >= 1 AND zone = '.$zone_id.' AND grade="Unique" ORDER BY RAND() LIMIT 1') }else{ $spawnmobs = $db->query('SELECT * from nrpg_monsters WHERE level >= 1 AND zone = '.$zone_id.' AND grade!= "Unique" ORDER BY RAND() LIMIT 1') } -
Okay, I have a table called: "monsters" and it has 5 mobs. (rows) Only 1 is a Unique mob with a grade column set to "Unique". The following query will select a random mob (someone entered the dungeon for their specific zone (map)) SELECT * from nrpg_monsters WHERE level >= 1 AND zone = '.$zone_id.' ORDER BY RAND() LIMIT 1 But the problem is, By this logic query, the UNIQUE mob has the same chance to spawn as all the others, lol. How would I make, let's say the unique mob spawn < 10% with this query? his id is 5. The point im trying to make is, I use this info to insert it into a monster_active table, so users can actually kill their own mobs and level up/gain exp on my game.. I dont want users to have the same chance to spawn a unique mob as a Normal or Magic mob...
-
Wow, exactly what I was looking for. That code is very easy to read as well. (I always get lost in foreaches, but this is very simple for me, thank you) I'll be making the lvl 19 lower than 6% chance though just because I want +20 to be end-game material. Marked as solved, didn't know you guys were still active here thank you a lot.
-
Need a little help here for my game. Let's say you can upgrade items... I want users to upgrade to level 20. Let's say, +1 is 80% chance and to get it to +20 would be 2% chance. How would I go about this? I would also need variables to use, let's say crystals they need to use to increase the % of upgrading by XX %. Ty
-
Who are you? God? People can't express opinions? Well sorry for posting, have fun on your php framework, my gosh, you sound raged. Oh the irony.. Nice, PHP Guru calling other people stupid and morons, seems legit, you should be ashamed, I never once insulted u, but whatever, lol
-
Yes Jessica, well I guess it just depends on the person And how knowledgable they are in certain areas. I myself cannot really think or imagine how much more simpler PHP can get though. I am thinking these "frameworks" are just different code styles to make it seem like you feel more professional or "smarter" which just doesn't work for me. Also, as in someone that isn't 100% fluid in PHP Like my self, I hope you understand where I am coming from, from not wanting to learn new code Having to learn/adjust to even more new code, just would make my head explode.
-
$roll = rand(1, 100); $failureChance = 100 - $successrate; if ($roll > $failureChance) { // This is successful. } VS: $rand = mt_rand(1, 100); if ($rand > $successrate) // Success rate is your integer; 87 for 87% for example { // This is a failure. } Are they both essentially the same? Why the heck is that guy using the $falureChance variable? (Cite from http://www.codingforums.com/showthread.php?t=250281) Edit: also, which one is more professional/correct way?
-
actually found my solution http://forums.phpfreaks.com/topic/10156-percentage-chance-of-something-happening/ did a bit of searching xD edit: mod can close this, sorry