Monkuar Posted December 3, 2014 Share Posted December 3, 2014 (edited) Since I got my websocket PHP server running nicely with my MYSQL, I can now have some fun Attack speed is very simple, but I need your help with the unixtimestamp. For example, There is a field name called "last_attack" and each time a user attacks a mob and a skill was performed; it will be updated with: time(); Then I disable the attack button for 2 seconds client side, but I also check that value against time() serverside as well. Now let's say the user's attack speed is 1.30% I want to make that Attack Speed check, to check it dynamically. It should now check only if the attack was less than 1.7 seconds ago instead of 2 seconds. How do I split up the unixtimestamp to work with percents? Edited December 3, 2014 by Monkuar Quote Link to comment Share on other sites More sharing options...
Barand Posted December 3, 2014 Share Posted December 3, 2014 What version of MySQL? https://blogs.oracle.com/MySqlOnWindows/entry/milliseconds_value_support_on_datetime Quote Link to comment Share on other sites More sharing options...
Monkuar Posted December 3, 2014 Author Share Posted December 3, 2014 (edited) What version of MySQL? https://blogs.oracle.com/MySqlOnWindows/entry/milliseconds_value_support_on_datetime MYSQLI. But I can grab the unixtimestamp and check it with PHP code though. I'm just using mysql to securely store the last_attack field. Wait, would I have to use http://php.net/manual/en/function.microtime.php instead? Why does the PHP document say microseconds? "microtime() returns the current Unix timestamp with microseconds. This function is only available on operating systems that support the gettimeofday() system call." Is microseconds the same as milliseconds I assume? Edit: Wait, nevermind micro is 1 millionth of a second. I'm herp derping hard. Edited December 3, 2014 by Monkuar Quote Link to comment Share on other sites More sharing options...
Solution kicken Posted December 3, 2014 Solution Share Posted December 3, 2014 Yes, you will have to use something with more resolution than time(). Unix timestamps / time() cannot identify periods of less than 1 second, so you'd have either 1 second or 2 seconds, 1.7 seconds is not possible using timestamps. microtime() would work, or if you're mysql server's version is new enough using native datetime type and functions will give you fractional seconds as well. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.