Szerző Téma: Car-shop  (Megtekintve 598 alkalommal)

Car-shop
« Dátum: 2016. november 03. - 15:04:57 »
0 Show voters
Sziasztok! Valamiért nem müködik a kódom, de a debug, nem ír már semmit, de ha belemegyek a markerbe akkor már nem történik semmi. Mi lehet a probléma?
 

local panelState = false
local markerPosition = 543.06183, -1292.82703, 17.24219
local asd = 0
--local kocsivegseb = getElementData(theVehicle,\"vegseb\")
local marker = createMarker(543.06183, -1292.82703, 17.24219, \"cylinder\",1.5, 255, 255, 255, 255)
kocsik = {}
kocsikara = {}
kocsik[1] = 602
kocsik[2] = 477
kocsikara[1] = 100000
kocsikara[2] = 100000
addEventHandler(\"onClientRender\", root,
    function()
          local aholtart = 1
       if panelState == true then
        dxDrawRectangle(1442, 323, 441, 571, tocolor(0, 0, 0, 200), false)
        dxDrawRectangle(1513, 830, 300, 54, tocolor(0, 0, 0, 230), false)
        dxDrawText(\"Vásárlás\", 1511, 829, 1813, 884, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawText(\"Kocsi fajtája\", 1489, 329, 1845, 360, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawRectangle(1454, 378, 282, 40, tocolor(0, 0, 0, 230), false)
        dxDrawText(\"Ára :\", 1454, 377, 1532, 418, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"left\", \"center\", false, false, false, false, false)
        dxDrawText(kocsikara[aholtart]..\" C$\", 1532, 378, 1736, 418, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawRectangle(1454, 428, 282, 39, tocolor(0, 0, 0, 230), false)
        dxDrawText(\"Végsebesség : Hamarosan\", 1454, 426, 1532, 467, tocolor(255, 255, 255, 255), 1.00, \"default-bold\", \"left\", \"center\", false, false, false, false, false)
        --dxDrawText(\"101023 MP/H\", 1532, 426, 1736, 466, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawRectangle(1452, 488, 51, 43, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(1513, 488, 51, 43, tocolor(0, 0, 0, 255), false)
        dxDrawRectangle(1574, 488, 51, 43, tocolor(28, 204, 61, 255), false)
        dxDrawRectangle(1635, 488, 51, 43, tocolor(28, 204, 61, 255), false)
        dxDrawRectangle(1635, 488, 51, 43, tocolor(42, 163, 189, 255), false)
        dxDrawRectangle(1696, 488, 51, 43, tocolor(21, 20, 97, 255), false)
        dxDrawRectangle(1757, 488, 51, 43, tocolor(116, 0, 0, 255), false)
        dxDrawRectangle(1818, 488, 51, 43, tocolor(211, 117, 25, 255), false)
        dxDrawRectangle(1452, 541, 51, 43, tocolor(233, 219, 2, 255), false)
        dxDrawRectangle(1513, 541, 51, 43, tocolor(202, 25, 209, 255), false)
        dxDrawRectangle(1574, 541, 51, 43, tocolor(98, 12, 153, 255), false)
        dxDrawRectangle(1635, 541, 51, 43, tocolor(77, 40, 20, 255), false)
        dxDrawRectangle(1696, 541, 51, 43, tocolor(49, 48, 47, 255), false)
        dxDrawText(\"Előre\", 1718, 784, 1883, 823, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawText(\"Hátra\", 1443, 784, 1608, 823, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        --[[dxDrawText(\"Fehér\", 1450, 487, 1503, 531, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Fekete\", 1513, 487, 1566, 531, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Züld\", 1572, 488, 1625, 532, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Világos Kík\", 1633, 487, 1686, 531, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Sötét Kík\", 1694, 488, 1747, 532, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Piros\", 1755, 487, 1808, 531, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Narancssárga\", 1816, 487, 1869, 531, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Citromsárga\", 1450, 540, 1503, 584, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Rózsaszín\", 1513, 540, 1566, 584, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Lila\", 1574, 540, 1627, 584, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Barna\", 1635, 540, 1688, 584, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)
        dxDrawText(\"Szürke\", 1696, 540, 1749, 584, tocolor(255, 255, 255, 255), 1.00, \"default\", \"left\", \"top\", false, false, false, false, false)]]
    end
    end
)
function changePanelState ()
if panelState == false and getElementPosition(localPlayer) == markerPosition then
showCursor(true)
createVehicle01()
panelState = true
setCameraMatrix(536.54602, -1298.54370, 32.54056,542.45947, -1296.78247, 32.54056)
      elseif panelState == true then
         showCursor(false)
         destroyElement(theVehicle)
         panelState = false
         setCameraTarget(localPlayer)
      end
end
addEventHandler(\"onClientMarkerHit\",marker,changePanelState)
function dobozbaVan(dX, dY, dSZ, dM, eX, eY)
    if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then
        return true
    else
        return false
    end
end
function elore (gomb, statusz, absX, absY)
        if statusz == \"down\" and gomb == \"left\" then
                if dobozbaVan(1718,784,1883,823, absX, absY) then
                        if aholtart == 2 then
                             aholtart = 1
                          elseif aholtart == 1 then
                             aholtart = 2
                          end
               end
        end
end
addEventHandler(\"onClientClick\", getRootElement(), elore)
function createVehicle01 ()
if asd == true then
destroyElement(theVehicle)
theVehicle = createVehicle(kocsik[aholtart],542.45947, -1296.78247, 32.54056)
elseif asd == false then
theVehicle = createVehicle(kocsik[aholtart],542.45947, -1296.78247, 32.54056)
end
end
function bindTheKeys ()
bindKey (\"backspace\", \"down\", changePanelState)
end
addEventHandler(\"onClientResourceStart\", getRootElement(),bindTheKeys)

Car-shop
« Válasz #1 Dátum: 2016. november 03. - 16:11:59 »
0 Show voters
getElementPosition(localPlayer) == markerPosition

 
Valószínűleg ez a sor. Mivel mikor belelépsz a markerbe annak van kiterjedése. És a markerPosition az a közepe te pedig amikor belépsz a markerbe nem a közepébe lépsz be egyből hanem kicsit mellé (lehet csak 0.0001-el) de így akkor se egyezik meg a kettő.
Az ki kellene venni. De alapból a markerPosition változó is rossz mert egy változónak nem adhatsz meg 3 értéket. Azt is töröld.
És helyette egy olyat csinálni, hogy
 
source == marker

Car-shop
« Válasz #2 Dátum: 2016. november 03. - 17:55:36 »
0 Show voters
Hova írjam azt a sort
E: Megvan, most a kocsit nem hívja le és 65 sorban a destroyElement NIL-t kap. (Amúgy ezt csak annak az embernek hívja/hívná le?)
E2:
Még mindig áll a kérdés.
E3:
Mostmár csak amikor kilépek belőle akkor kap NIL-t egy destroyElement a (mert meghívodik a createVehicle01) de amúgy nem ír semmit, de kocsit még mindig nem hív le :(
Mostani kód:
 

local screenW, screenH = guiGetScreenSize()
local aholtart = 1
local panelState = false
local markerPosition = 543.06183, -1292.82703, 17.24219
local asd = 0
local marker = createMarker(543.06183, -1292.82703, 17.24219, \"cylinder\",1.5, 255, 255, 255, 255)
kocsik = {}
kocsikara = {}
kocsikfajtaja = {}
kocsik[1] = 602
kocsik[2] = 477
kocsikara[1] = 100000
kocsikara[2] = 200000
kocsikfajtaja[1] = \"Alpha\"
kocsikfajtaja[2] = \"ZR-350\"
addEventHandler(\"onClientRender\", root,
    function()
       asdasd = aholtart
       if panelState == true then
        dxDrawRectangle(screenW * 0.7510, screenH * 0.2991, 441, 571, tocolor(0, 0, 0, 200), false)
        dxDrawText(\"Vásárlás\", 1598, 623, 1706, 652, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawText(\"kocsikfajtaja[asdasd]\", 1489, 329, 1845, 360, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawRectangle(screenW * 0.7573, screenH * 0.3500, 282, 40, tocolor(0, 0, 0, 230), false)
        dxDrawText(\"Ára :..kocsikara[asdasd]\", 1454, 377, 1532, 418, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"left\", \"center\", false, false, false, false, false)
        dxDrawRectangle(screenW * 0.7573, screenH * 0.3963, 282, 39, tocolor(0, 0, 0, 230), false)
        dxDrawText(\"Végsebesség : Hamarosan\", screenW * 0.7573, screenH * 0.3944, (screenW * 0.7573) + 78, ( screenH * 0.3944) + 41, tocolor(255, 255, 255, 255), 1.00, \"default-bold\", \"left\", \"center\", false, false, false, false, false)
        dxDrawRectangle(screenW * 0.7562, screenH * 0.4519, 51, 43, tocolor(255, 255, 255, 255), false)
        dxDrawRectangle(screenW * 0.7880, screenH * 0.4519, 51, 43, tocolor(0, 0, 0, 255), false)
        dxDrawRectangle(screenW * 0.8198, screenH * 0.4519, 51, 43, tocolor(28, 204, 61, 255), false)
        dxDrawRectangle(screenW * 0.8516, screenH * 0.4519, 51, 43, tocolor(42, 163, 189, 255), false)
        dxDrawRectangle(screenW * 0.8833, screenH * 0.4519, 51, 43, tocolor(21, 20, 97, 255), false)
        dxDrawRectangle(screenW * 0.9151, screenH * 0.4519, 51, 43, tocolor(116, 0, 0, 255), false)
        dxDrawRectangle(screenW * 0.9469, screenH * 0.4519, 51, 43, tocolor(211, 117, 25, 255), false)
        dxDrawRectangle(screenW * 0.7562, screenH * 0.5009, 51, 43, tocolor(233, 219, 2, 255), false)
        dxDrawRectangle(screenW * 0.7880, screenH * 0.5009, 51, 43, tocolor(202, 25, 209, 255), false)
        dxDrawRectangle(screenW * 0.8198, screenH * 0.5009, 51, 43, tocolor(98, 12, 153, 255), false)
        dxDrawRectangle(screenW * 0.8516, screenH * 0.5009, 51, 43, tocolor(77, 40, 20, 255), false)
        dxDrawRectangle(screenW * 0.8833, screenH * 0.5009, 51, 43, tocolor(49, 48, 47, 255), false)
        dxDrawText(\"Előre\", screenW * 0.9464, screenH * 0.7000, (screenW * 0.9464) + 66, ( screenH * 0.7000) + 35, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        dxDrawText(\"Hátra\", screenW * 0.7510, screenH * 0.7000, (screenW * 0.7510) + 68, ( screenH * 0.7000) + 34, tocolor(255, 255, 255, 255), 2.00, \"default-bold\", \"center\", \"center\", false, false, false, false, false)
        --[[dxDrawText(\"Fehér\",
        dxDrawText(\"Fekete\",
        dxDrawText(\"Züld\",
        dxDrawText(\"Világos Kík\",
        dxDrawText(\"Sötét Kík\",
        dxDrawText(\"Piros\",
        dxDrawText(\"Narancssárga\",
        dxDrawText(\"Citromsárga\",
        dxDrawText(\"Rózsaszín\",
        dxDrawText(\"Lila\",
        dxDrawText(\"Barna\",
        dxDrawText(\"Szürke\", ]]
    end
    end
)
function changePanelState ()
if panelState == false and source == marker then
showCursor(true)
createVehicle01()
panelState = true
setCameraMatrix(536.54602, -1298.54370, 32.54056,542.45947, -1296.78247, 32.54056)
      elseif panelState == true then
         showCursor(false)
         destroyElement(theVehicle)
         panelState = false
         setCameraTarget(localPlayer)
      end
end
addEventHandler(\"onClientMarkerHit\",marker,changePanelState)
function dobozbaVan(dX, dY, dSZ, dM, eX, eY)
    if(eX >= dX and eX <= dX+dSZ and eY >= dY and eY <= dY+dM) then
        return true
    else
        return false
    end
end
function elore (gomb, statusz, absX, absY)
        if statusz == \"down\" and gomb == \"left\" then
                if dobozbaVan(screenW * 0.9464, screenH * 0.7000, screenW * 0.9807, screenH * 0.7324, absX, absY) then
                        if aholtart == 2 then
                           outputChatBox(\"elore***** 2 vót 1 lett\")
                             aholtart = 1
                             createVehicle01()
                          elseif aholtart == 1 then
                             outputChatBox(\"elore***** 1 vót 2 lett\")
                             aholtart = 2
                             createVehicle01()
                        end
               elseif dobozbaVan(screenW * 0.7510, screenH * 0.7000, screenW * 0.7865, screenH * 0.7315, absX, absY) then
                        if aholtart == 2 then
                           outputChatBox(\"hatra***** 2 vót 1 lett\")
                             aholtart = 1
                             createVehicle01()
                          elseif aholtart == 1 then
                             outputChatBox(\"hatra***** 1 vót 2 lett\")
                             aholtart = 2
                             createVehicle01()
                       end
               end
        end
end
addEventHandler(\"onClientClick\", getRootElement(), elore)
function createVehicle01 ()
if asd == true then
destroyElement(theVehicle)
theVehicle = createVehicle(kocsik[asdasd],542.45947, -1296.78247, 32.54056)
elseif asd == false then
theVehicle = createVehicle(kocsik[asdasd],542.45947, -1296.78247, 32.54056)
end
end
function bindTheKeys ()
bindKey (\"backspace\", \"down\", changePanelState)
end
addEventHandler(\"onClientResourceStart\", getRootElement(),bindTheKeys)
« Utoljára szerkesztve: 2016. november 04. - 12:00:02 írta thegergo02 »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal