Sziasztok Kedves Fórumozók, Fejlesztők, Mapperek, Spricterek és további emberek. Lenne egy problémám egy mta_gate nevezetű sprict-el megmutatom a sprict-et de előbb itt van egy két kép hogy mi is lenne a problémám, remélem tudtok segíteni nagyon hálás lennék érte.
KÉP:
COD:
Lua
local connection = exports.mta_connection:getConnection()
function loadAllGate()
gates = {}
local queryHandler = dbQuery(connection, \"SELECT * FROM gates\")
local result, numAffectedRows, errorMsg = dbPoll(queryHandler, -1)
if numAffectedRows > 0 then
for key, row in ipairs(result) do
local gateId = tonumber(row[\"id\"])
gates[key] = {}
gates[key][\"sqlId\"] = gateId
gates[key][\"modelId\"] = tonumber(row[\"modelId\"])
gates[key][\"lockState\"] = true
gates[key][\"defaultState\"] = fromJSON(row[\"defaultState\"])
gates[key][\"changeState\"] = fromJSON(row[\"changeState\"])
gates[key][\"createRotation\"] = fromJSON(row[\"createRotation\"])
gates[key][\"IndDim\"] = fromJSON(row[\"IndDim\"])
gates[key][\"gate\"] = createObject(gates[key][\"modelId\"], gates[key][\"defaultState\"][1], gates[key][\"defaultState\"][2], gates[key][\"defaultState\"][3], gates[key][\"defaultState\"][4], gates[key][\"defaultState\"][5], gates[key][\"defaultState\"][6])
setElementRotation(gates[key][\"gate\"], gates[key][\"createRotation\"][1], gates[key][\"createRotation\"][2], gates[key][\"createRotation\"][3])
setElementInterior(gates[key][\"gate\"], gates[key][\"IndDim\"][1])
setElementDimension(gates[key][\"gate\"], gates[key][\"IndDim\"][2])
end
end
outputDebugString(#gates .. \" gate(s) loaded\")
end
addEventHandler(\"onResourceStart\", resourceRoot, loadAllGate)
addCommandHandler(\"creategate\", function (player, cmd, modellID, changex, changey, changez)
if player then
if modellID and changex and changey and changez then
if getElementData(player, \"acc:admin\") >= 8 then
local x, y, z = getElementPosition(player)
local rotx, roty, rotz = getElementRotation(player)
local int = getElementInterior(player)
local dim = getElementDimension(player)
dbExec(connection, \"INSERT INTO gates SET defaultState = ?, createRotation = ?, changeState = ?, modelId = ?, IndDim = ? \", toJSON({x, y, z}), toJSON({rotx, roty, rotz}), toJSON({tonumber(changex), tonumber(changey), tonumber(changez)}), modellID, toJSON({int, dim}))
outputChatBox(\"#19B5FE\'Sikeres\' #ffffff Létrehozás\", player, 255, 255, 255, true)
end
else
outputChatBox(\"#19B5FE[Használat] #ffffff/\".. cmd ..\" #00ced1[Modell ID] [Mozgás_X] [Mozgás_Y] [Mozgás_Z]\", player, 255, 255, 255, true)
end
end
end)
addCommandHandler(\"gate\", function(player)
local gate = getClosestGate(player)
if gate then
if (not exports[\"mta_item\"]:hasItemS(player, 36, tonumber(gate)) or false) and getElementData(player, \"acc:admin\") <= 5 then
outputChatBox(\"#dc143c[Hiba]:#ffffff Nincs kulcsod a kapuhoz.\", player, 255, 255, 255, true)
return
end
if getElementData(gates[gate][\"gate\"], \"inUse\") then
return
end
setElementData(gates[gate][\"gate\"], \"inUse\", true)
if gates[gate][\"lockState\"] then
moveObject(gates[gate][\"gate\"], 1500, gates[gate][\"changeState\"][1], gates[gate][\"changeState\"][2], gates[gate][\"changeState\"][3], gates[gate][\"changeState\"][4], gates[gate][\"changeState\"][5], gates[gate][\"changeState\"][6], \"OutQuad\")
setElementInterior(gates[gate][\"gate\"], gates[gate][\"IndDim\"][1])
setElementDimension(gates[gate][\"gate\"], gates[gate][\"IndDim\"][2])
else
moveObject(gates[gate][\"gate\"], 1500, gates[gate][\"defaultState\"][1], gates[gate][\"defaultState\"][2], gates[gate][\"defaultState\"][3], gates[gate][\"defaultState\"][4], gates[gate][\"defaultState\"][5], gates[gate][\"defaultState\"][6], \"OutQuad\")
setElementInterior(gates[gate][\"gate\"], gates[gate][\"IndDim\"][1])
setElementDimension(gates[gate][\"gate\"], gates[gate][\"IndDim\"][2])
end
gates[gate][\"lockState\"] = not gates[gate][\"lockState\"]
setTimer(function()
setElementData(gates[gate][\"gate\"], \"inUse\", false)
end, 1500, 1)
end
end)
addCommandHandler(\"nearbygate\", function(player)
local gate = getClosestGate(player)
if gate then
outputChatBox(\"#19B5FE[SERVER NÉV] #ffffffLegközelebbi kapu: #19B5FE\"..gate, player, 0, 0, 0, true)
else
outputChatBox(\"#19B5FE[SERVER NÉV] #ffffffNincs a közeledben kapu.\", player, 0, 0, 0, true)
end
end)
function getClosestGate(p1)
local x, y, z = getElementPosition(p1)
local dis = 99999
local dis2 = 0
local gate = false
for key, value in ipairs(gates) do
local x2, y2, z2 = getElementPosition(gates[key][\"gate\"])
dis2 = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2)
if tonumber(dis2) < tonumber(dis) and tonumber(dis2) <= 9 then
dis = dis2
gate = key
end
end
return gate
end
meta:
<meta>
<script src=\"server.lua\" />
</meta>