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: 2639 dni
Posty: 65
Nick w MP: Dobrich

Piwa: 4

Respekt: 50

Ostrzeżeń: 60%
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.36121692.65399, -5.23441-0.9"cylinder"100095)

markerusun createMarker(-1605.83081676.78284, -5.24219-2.9"cylinder"4.000095)

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

addEvent("K10"true)
addEventHandler("K10"root, function()
if getElementData(source"przycisk1"truethen
outputChatBox("Pojazd ju? wyj?ty.")
else
setElementData(source"przycisk1"true)
local veh createVehicle(579,-1610.68682.25, -5.32360090)
setVehicleColor(veh000)
setElementData(veh"vehicle:police"true)
warpPlayerIntoVehicle(sourceveh)
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!",gracz25500true)
setElementData(localPlayer"przycisk1"false)
end
end
addEventHandler"onMarkerHit"markerusunvehusun )


Skrypt po stronie clienta:



mojeW,mojeH 1366768
sW,sH guiGetScreenSize()
w= (sW/mojeW), (sH/mojeH)

local screenWscreenH guiGetScreenSize()
panelpp false

function Panel()
dxDrawRectangle(screenW 0.3463screenH 0.2083screenW 0.3096screenH 0.5859tocolor(000150))
if not getElementData(localPlayer"przycisk1"truethen 
dxDrawRectangle(screenW 0.4209screenH 0.2824screenW 0.1600screenH 0.0400tocolor(14900165))
elseif getElementData(localPlayer"przycisk1"falsethen
dxDrawRectangle(screenW 0.4209screenH 0.2824screenW 0.1600screenH 0.0400tocolor(255255255165))
end
dxDrawText("K10"screenW 0.4209screenH 0.2824screenW 0.1600screenH 0.0400tocolor(255255255255), 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(buttonstate)
    if panelpp and button == "left" and state == "down" then
           if cursorPosition(screenW 0.4509screenH 0.7224screenW 0.1094screenH 0.0600then
removeEventHandler("onClientRender",root,Panel)
panelpp false
showCursor (false) 
         end
    end
end
addEventHandler("onClientClick"getRootElement(), ZamknijOkno)

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

function cursorPosition(xywh)
    if (not isCursorShowing()) then
        return false
    end
    local mxmy getCursorPosition()
    local fullxfully guiGetScreenSize()
    cursorxcursory mx*fullxmy*fully
    if cursorx and cursorx and cursory and cursory 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: 4429 dni
Posty: 3410

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: 2639 dni
Posty: 65
Nick w MP: Dobrich

Piwa: 4

Respekt: 50

Ostrzeżeń: 60%
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