Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP: execute an action after a given time
    primarykey
    data
    text
    <p>Good morning/afternoon/evening, Internet. I am currently developing a wap game and have encountered a problem: applying long-term effects on other players. Let me explain.</p> <p>If a user uses an 'instant' ability, it is just a normal command link that does <code>executeAbility()</code>; If a user casts a spell, the script does the following: </p> <pre><code>setPlayerState('casting'); sleep($cast_time); executeAbility(); </code></pre> <p>This is but a simple part, though. Now if we go to some more advanced techiques, like putting a curse on a player, I get lost. I've already considered the following possibility:</p> <pre><code>$time=$_SERVER['REQUEST_TIME']; $time_when_the_curse_finishes=$time+$curseDuration; updateEnemyCurses($curseID,$endTime); if ($time&lt;$endTime) removeCurse(); </code></pre> <p>This might look pretty and all, but it doesn't take two things into consideration: if the user logged off and logged back in in 2 hours, he would spend the whole two hours cursed <em>and</em> this method cannot support <em>effect every x seconds for y seconds</em> kind of curses. For example:</p> <p>Curse One. You take 1 damage every 2 seconds for 10 seconds.</p> <p>To summarise, I simply require a tip or two how I could make the line above possible. The curse itself would need to have its time checked globally (not with page reloads) and be able to complete queries (in this case damage ticks) every x seconds until it is removed in 10 seconds.</p> <p>I am thankful in advance for any tips offered here!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload