Jump to content
php.lv forumi

Laika atskaite!


zintis8789

Recommended Posts

Tajā tēmā tika apskatītas divas metodes:

1) vienkāršākā - uz servera reizi X minūtēs tiek iedarbināts skripts, kas rupji runājot izpilda darbību:

UPDATE character_table SET character_health = MIN(100, character_health + 1) WHERE character_health < 100

 

2) Sarežģītākā: Nevis visu laiku pa tukšo izpildam UPDATE, bet gan tikai, kad notiek kaut kāda darbība izpildam:

UPDATE character_table SET character_health = MIN(100, character_health + DATE_DIFF(last_time_something_happened,now(),MINUTES)), last_time_something_happened = NOW() WHERE character_id = X

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...