Jump to content

Why do I get these errors?


Recommended Posts

I have this script and it worked before but after a server restart, it doesn't..
It's a script for opening gates.
The full code: https://pastebin.com/Y6SPktEU

Then I get these erros whenever I try to open a gate with the script's command, which is /gate.
 

[21:55:57] WARNING: mta_gates/server.Lua:99: Bad argument @ 'getDistanceBetweenPoints3D' [Expected vector3 at argument 4, got none]
[21:55:57] ERROR: mta_gates/server.Lua:101: attempt to compare nil with number

How do I fix this?

Link to comment

The first error (Expected vector3 at argument 4, got none)
Line 99:

dis2 = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)

so variable x2 equals to none. You got x2, y2 and z2 variables right here:

local x2, y2, z2 = getElementPosition(gates[key]["gate"])

So the problem is in your gates table

A little advice:
On the previous step you're making a loop:

for key, value in ipairs(gates) do

and you can replace gates[key]["gate"] with value.gate or value["gate"] and get the same result

The second error is caused by previous one as the dis2 variable has no value.

  • Thanks 1
Link to comment
On 26/07/2019 at 11:06, JeViCo said:

The first error (Expected vector3 at argument 4, got none)
Line 99:


dis2 = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)

so variable x2 equals to none. You got x2, y2 and z2 variables right here:


local x2, y2, z2 = getElementPosition(gates[key]["gate"])

So the problem is in your gates table

A little advice:
On the previous step you're making a loop:


for key, value in ipairs(gates) do

and you can replace gates[key]["gate"] with value.gate or value["gate"] and get the same result

The second error is caused by previous one as the dis2 variable has no value.

Thank you for your reply, you have given me a way better explanation of what's going on in the script, than the guys at server hosting in customer service.
But the thing is I don't own this script, and I don't know a thing about Lua scripting, sooo...
I understand what you wrote, and you say the problem is in mysql?
Here's a picture of a gate in MySQL. Image

Isn't "default state" x y z as in dis and "changed state" x2 y2 z2 as in dis2?
How do I fix it?

Edited by FishBurger987
Added + info
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...