Statements not working when executed within a skript loop #9

Closed
opened 2021-05-02 17:59:49 +00:00 by bloggy · 2 comments
bloggy commented 2021-05-02 17:59:49 +00:00 (Migrated from github.com)

I made a test skript:

command /testrun [<offlineplayer>]:
	trigger:
		loop 5 times:
			make console execute command "/test"

command /test [<offlineplayer>]:
	trigger:
		execute "SELECT points FROM `test` WHERE `id` = 1;" in {sql} and store the result in {_r::*}
		set {_points} to 0
		if {_r::points::1} is set:
			set {_points} to {_r::points::1}
		set {_id} to 1
		add 10 to {_points}
		execute "INSERT INTO `test` (`id`, `points`) VALUES (%{_id}%, %{_points}%) ON DUPLICATE KEY UPDATE `points` = %{_points}%" in {sql}
		broadcast "INSERT INTO `test` (`id`, `points`) VALUES (%{_id}%, %{_points}%) ON DUPLICATE KEY UPDATE `points` = %{_points}%"

Now I execute "/testrun"
It should add 5x 10 points to the points field in the mysql table, but the result is that it only adds 10 points once.

It sometimes(!!!) works when I change the "/testrun" command like this:

command /testrun [<offlineplayer>]:
	trigger:
		loop 5 times:
			wait 1 tick
			make console execute command "/test"

Then it sometimes adds 30 points and another time it adds 40 points .. but that is very strange behaviour and seems very buggy to me.

I made a test skript: ``` command /testrun [<offlineplayer>]: trigger: loop 5 times: make console execute command "/test" command /test [<offlineplayer>]: trigger: execute "SELECT points FROM `test` WHERE `id` = 1;" in {sql} and store the result in {_r::*} set {_points} to 0 if {_r::points::1} is set: set {_points} to {_r::points::1} set {_id} to 1 add 10 to {_points} execute "INSERT INTO `test` (`id`, `points`) VALUES (%{_id}%, %{_points}%) ON DUPLICATE KEY UPDATE `points` = %{_points}%" in {sql} broadcast "INSERT INTO `test` (`id`, `points`) VALUES (%{_id}%, %{_points}%) ON DUPLICATE KEY UPDATE `points` = %{_points}%" ``` Now I execute "/testrun" It should add 5x 10 points to the points field in the mysql table, but the result is that it only adds 10 points once. It sometimes(!!!) works when I change the "/testrun" command like this: ``` command /testrun [<offlineplayer>]: trigger: loop 5 times: wait 1 tick make console execute command "/test" ``` Then it sometimes adds 30 points and another time it adds 40 points .. but that is very strange behaviour and seems very buggy to me.
GovindasOM commented 2021-05-12 10:11:50 +00:00 (Migrated from github.com)

your sql query seems wrong, it should end with:

UPDATE `points` = `points`+%{_points}%
your sql query seems wrong, it should end with: ``` UPDATE `points` = `points`+%{_points}% ```
GovindasOM commented 2021-06-26 10:15:12 +00:00 (Migrated from github.com)

I am closing this issue, please e-open it when it happens again

I am closing this issue, please e-open it when it happens again
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Limework/skript-db#9
No description provided.