Hello!

I make an online game. There are enemies in the enemy table. If several players are playing at the same time, it turns out that several people hit the enemy at the moment of time and instead of 1 life, for example, 3 are taken away the record of the enemy is one and unique.

I take the parameters of the enemy from the base:

$resultenemy = mysqli_query($db, "SELECT name,current_health,max_health,photo,exp,min_strenght,max_strenght,drop3 FROM enemy WHERE id='".$enemyid."'"); while ($enemy= mysqli_fetch_array($resultenemy)) { $enemyname.=$enemy['name']; $current_healthenemy.=$enemy['current_health']; $max_healthenemy.=$enemy['max_health']; $photoenemy.=$enemy['photo']; $expenemy.=$enemy['exp']; $minstrenghtenemy.=$enemy['min_strenght']; $maxstrenghtenemy.=$enemy['max_strenght']; $dropenemy.=$enemy['drop3']; } 

Is it possible to somehow create a copy of the enemy with a unique id prefix and delete the line with the enemy after the battle when entering the battle of mysql?

  • It is possible, why not .... make a separate table and go .... - Alexander Semikashev
  • Each player beats his copy of the enemy, regardless? if so, then the enemy is an attribute of the player, and the table of enemies is a table of patterns, not instances. - Akina

0