Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-02-24, 12:07


NewStories







Wiek: 22
Na forum: 2780 dni
Posty: 65
Nick w MP: Dobrich

Piwa: 4

Respekt: 50

Witam, ostatnimi czasy postanowi?em, ?e stworze wirtualny parking. Jednak?e napotykam problem, poniewa? nie ustawia mi element daty po usunieciu pojazdu.
B??d w DB:
Kod:

s.lua:38: Bad argument @ 'setElementData' [Expected element at argument 1, got nil]


Jakie argumentu mam u?y??

Skrypt po stronie servera:

markerstworz = createMarker(-1587.36121, 692.65399, -5.23441-0.9, "cylinder", 1, 0, 0, 0, 95)

markerusun = createMarker(-1605.83081, 676.78284, -5.24219-2.9, "cylinder", 4.0, 0, 0, 0, 95)

function marker_gui(el,md)
triggerClientEvent(el, "GUIPP", resourceRoot)
end
addEventHandler( "onMarkerHit", markerstworz, marker_gui)

addEvent("K10", true)
addEventHandler("K10", root, function()
if getElementData(source, "przycisk1", true) then
outputChatBox("Pojazd ju? wyj?ty.")
else
setElementData(source, "przycisk1", true)
local veh = createVehicle(579,-1610.68, 682.25, -5.32, 360, 0, 90)
setVehicleColor(veh, 0, 0, 0)
setElementData(veh, "vehicle:police", true)
warpPlayerIntoVehicle(source, veh)
end
end)

function zmien(plr)
outputChatBox("zmieniles")
setElementData(plr, "przycisk1", false)
end 
addCommandHandler("zmien", zmien)
 
function vehusun(he)
if getElementType(he) == "vehicle" then 
gracz = getVehicleController(he)
elseif getElementType(he) == "player" then
gracz = he
end
if getElementData(he, "vehicle:police") then
destroyElement(he or getPedOccupiedVehicle(he))
outputChatBox("#3399ff[Parking] #66ccffPojazd zosta? schowany do Wirtualnego Parkingu!",gracz, 255, 0, 0, true)
setElementData(localPlayer, "przycisk1", false)
end
end
addEventHandler( "onMarkerHit", markerusun, vehusun )


Skrypt po stronie clienta:



mojeW,mojeH = 1366, 768
sW,sH = guiGetScreenSize()
w, h = (sW/mojeW), (sH/mojeH)

local screenW, screenH = guiGetScreenSize()
panelpp = false

function Panel()
dxDrawRectangle(screenW * 0.3463, screenH * 0.2083, screenW * 0.3096, screenH * 0.5859, tocolor(0, 0, 0, 150))
if not getElementData(localPlayer, "przycisk1", true) then 
dxDrawRectangle(screenW * 0.4209, screenH * 0.2824, screenW * 0.1600, screenH * 0.0400, tocolor(149, 0, 0, 165))
elseif getElementData(localPlayer, "przycisk1", false) then
dxDrawRectangle(screenW * 0.4209, screenH * 0.2824, screenW * 0.1600, screenH * 0.0400, tocolor(255, 255, 255, 165))
end
dxDrawText("K10", screenW * 0.4209, screenH * 0.2824, screenW * 0.1600, screenH * 0.0400, tocolor(255, 255, 255, 255), 2.0, "clear")
local r,g,b=interpolateBetween(255,255,255,20,250,0,(getTickCount()-tick)/1100,"SineCurve")
end

addEvent("GUIPP", true)
addEventHandler("GUIPP", resourceRoot, function()
if panelpp == false then
addEventHandler("onClientRender",root,Panel)
showCursor (true)  
tick = getTickCount()
panelpp = true
end
end)

function ZamknijOkno(button, state)
    if panelpp and button == "left" and state == "down" then
           if cursorPosition(screenW * 0.4509, screenH * 0.7224, screenW * 0.1094, screenH * 0.0600) then
removeEventHandler("onClientRender",root,Panel)
panelpp = false
showCursor (false) 
         end
    end
end
addEventHandler("onClientClick", getRootElement(), ZamknijOkno)

function K10(button, state)
if panelpp and button == "left" and state == "down" then
        if cursorPosition(screenW * 0.4209, screenH * 0.2824, screenW * 0.1600, screenH * 0.0400) then
        if getElementData(localPlayer, "przycisk1", true) then
        outputChatBox("Ju? wyj?to pojazd o kryptonimie K10", 255, 255, 255, true)
        else
        triggerServerEvent ("K10", localPlayer)
        removeEventHandler("onClientRender",root,Panel)
        panelpp = false
        showCursor (false)
end
end
end
end
addEventHandler("onClientClick", getRootElement(), K10)

function cursorPosition(x, y, w, h)
    if (not isCursorShowing()) then
        return false
    end
    local mx, my = getCursorPosition()
    local fullx, fully = guiGetScreenSize()
    cursorx, cursory = mx*fullx, my*fully
    if cursorx > x and cursorx < x + w and cursory > y and cursory < y + h then
        return true
    else
        return false
    end
end


Podpis
Dobrich/9971
Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-24, 12:09


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Po serwerze nie ma zmiennej globalnej localPlayer. Wy?ej masz gracz oraz he, u?yj jednego z nich.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-24, 12:11


NewStories







Wiek: 22
Na forum: 2780 dni
Posty: 65
Nick w MP: Dobrich

Piwa: 4

Respekt: 50

Do zamkni?cia, problem rozwi?zany.

Postaw piwo autorowi tego posta
 

 
Tagi: parking :: wirtualny
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Parking wirtualny Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku