GTA Közösség - A magyar GTA fórum

Multi Theft Auto (MTA) => MTA: Szerverfejlesztés => Segítségkérés => A témát indította: IBADBAY - 2016. április 28. - 20:08:07

Cím: Miért nem működik a gates ?
Írta: IBADBAY - 2016. április 28. - 20:08:07
Sziasztok alapból van a zéróban egy gates resource akartam a szerelőknem kicsálni egy gatét de nem engedi \"gates/bms.lua:15: attempt to compare boolean with numbers\" ezt a hibakódot kaptam mi lehet a baj ? válaszokat előre is köszönöm!
local bmse = createObject(980, 1773.8, -1113.8, 21.6, 0, 0, 270)
exports.pool:allocateElement(bmse)
local bmsk = createObject(980, 1773.69995, -1130.19995,18.6, 0, 0, 270)
exports.pool:allocateElement(bmsk)
local open = false
local which = 0
-- Gate code
function bms(thePlayer)
local x, y, z = getElementPosition(thePlayer)
local distance1 = getDistanceBetweenPoints3D(1773.8,-1113.8, 21.6)
local distance2 = getDistanceBetweenPoints3D(1773.69995, -1130.19995,18.6)
if (distance1<=10) and (open==false) then
if (exports.global:hasItem(thePlayer, 145) or exports.global:hasItem(thePlayer, 82)) then
   open = true
   which = 1
   outputChatBox(\"LSPD sorompó nyitva!\", thePlayer, 0, 255, 0)
   moveObject(bmse, 1000,1773.8,-1113.8, 20.2, 0, 0, 270)
   setTimer(bmsc, 5000, 1, thePlayer)
end
elseif (distance2<=10) and (open==false) then
if (exports.global:hasItem(thePlayer, 145)) then
   open = true
   which = 2
   outputChatBox(\"LSPD Barrier is now Open!\", thePlayer, 0, 255, 0)
   moveObject(bmsk, 1000, 1773.69995, -1130.19995, 17.3, 0, 0, 270)
   setTimer(bmsc, 5000, 1, thePlayer)
end
end
end
addCommandHandler(\"gate\", bms)
function bmsc(thePlayer)
setTimer(resetState7, 1000, 1)
if (which==1) then
which = 0
moveObject(bmse, 1000, 1773.8, -1113.8, 21.6, 0, 0, 270)
elseif (which==2) then
which = 0
moveObject(bmsk, 1000, 1773.69995, -1130.19995,18.6, 0, 0, 270)
end
end
function resetState7()
open = false
end
Cím: Miért nem működik a gates ?
Írta: kundlam - 2016. április 28. - 20:19:30
Notepad++ban  melyik sort mutatja a 15ik sornak?
Cím: Miért nem működik a gates ?
Írta: IBADBAY - 2016. április 28. - 20:49:13
ezt mutatja a 15.nek
   if (distance1<=10) and (open==false) then
Cím: Miért nem működik a gates ?
Írta: impreZZa - 2016. április 28. - 20:52:04
https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPoints3D
Cím: Miért nem működik a gates ?
Írta: kundlam - 2016. április 29. - 13:22:29
Hát én colShape-el oldanám meg, véleményem szerint sokkal egyszerűbb.
Létrehozás:
 
kapuelott = createColSphere ( float fX, float fY, float fZ, float fRadius )

 
Lekérdezés:
 
if (isElementWithinColShape(player, kapuelott)) then
Cím: Miért nem működik a gates ?
Írta: AlexSwamp - 2016. április 29. - 17:38:58
Idézetet írta: kundlam date=1461928949\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"60235\" data-ipsquote-contentclass=\"forums_Topic
Hát én colShape-el oldanám meg, véleményem szerint sokkal egyszerűbb.
Létrehozás:
 
kapuelott = createColSphere ( float fX, float fY, float fZ, float fRadius )

 
Lekérdezés:
 
if (isElementWithinColShape(player, kapuelott)) then

 

colsphape-el is kell megoldani, hiszen a getDistanceBetweenPoints3D-el oldalról is kitudja nyitni pl, és ha túl nagy a távolság, akkor egymásba is buggolnak a kapuk. :))
Cím: Miért nem működik a gates ?
Írta: kundlam - 2016. április 30. - 17:08:54
Idézetet írta: AlexSwamp date=1461944338\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"60235\" data-ipsquote-contentclass=\"forums_Topic


Hát én colShape-el oldanám meg, véleményem szerint sokkal egyszerűbb.
Létrehozás:
 
kapuelott = createColSphere ( float fX, float fY, float fZ, float fRadius )

 
Lekérdezés:
 
if (isElementWithinColShape(player, kapuelott)) then

 

colsphape-el is kell megoldani, hiszen a getDistanceBetweenPoints3D-el oldalról is kitudja nyitni pl, és ha túl nagy a távolság, akkor egymásba is buggolnak a kapuk. :))
 
[/quote]
Oh, köszönöm, ezt nem is tudtam:D Igaz mindig colShapet használtam, de legalább ezt is megtanultam:D
Cím: Miért nem működik a gates ?
Írta: AnthonyGates - 2016. április 30. - 17:29:17
Én úgy érzem működök, de köszi a kérdést!.
Cím: Miért nem működik a gates ?
Írta: patrik1958 - 2016. május 01. - 14:48:35
hali
   local distance1 = getDistanceBetweenPoints3D(1773.8,-1113.8, 21.6)
local distance2 = getDistanceBetweenPoints3D(1773.69995, -1130.19995,18.6)

 
Nálad így van de a végén az x, y,z-t ott kell hagynod szóval
 
   local distance1 = getDistanceBetweenPoints3D(1773.8,-1113.8, 21.6, x, y, z)
local distance2 = getDistanceBetweenPoints3D(1773.69995, -1130.19995,18.6,  x, y, z)