Sziasztok!
Elkezdtem írni egy job-systemet, azonban elakadtam
Megcsináltam egy gombot, ami elvileg felveszi az adott munkát. /felmond parancsot is létrehoztam, azonban ez a hiba lépett fel:
Ha fel akarom venni a munkát, akkor azt irja ki , hogy már van munkám. /felmond parancsra kiirja hogy felmondtál, de továbbra sem tudom felvenni....
http://kepfeltoltes.hu/view/160911/mta-screen_2016-09-11_08-37-40_www.kepfeltoltes.hu_.pngSzerver oldal:
function felmond()
if getElementData(localPlayer, \"munka\") == 0 then
outputChatBox(\"nincs melód\")
else
outputChatBox(\"felmondtál\")
setElementData(localPlayer, \"munka\", 0)
end
end
addCommandHandler(\"felmond\",felmond)
Kliens:
local jobguiState = false
local jobgui = {}
local csavoka1 = createPed( 230, 2189.3671878, -2254.322265625, 13.48069190979 )
setPedRotation(csavoka1,90)
setElementFrozen(csavoka1, true)
setElementDimension(csavoka1, 0 )
setElementInterior(csavoka1 , 0 )
setElementData (csavoka1,\"nameEnabled\",true,true)
setElementData ( csavoka1, \"visiblePedName\", \"Munkáltató\" )
setElementData ( csavoka1, \"tagName\", \"NPC\")
setElementData ( csavoka1, \"nameEnabled\", true )
function showjobgui ()
if isElement ( jobgui ) then return end
showCursor(true)
local screenWidth, screenHeight = guiGetScreenSize()
local windowWidth, windowHeight = 400, 700
local x = (screenWidth/2) - (windowWidth/2)
local y = (screenHeight/2) - (windowHeight/2)
jobgui = guiCreateStaticImage (x, y, 400,700, \"jobgui.png\" , false)
ggomb1 = guiCreateLabel(292, 218, 95, 38, \"\", false, jobgui)
ggomb2 = guiCreateLabel(292, 259, 95, 38, \"\", false, jobgui)
addEventHandler(\"onClientGUIClick\", ggomb1, felvesz1, false)
addEventHandler(\"onClientGUIClick\", ggomb2, felvesz2, false)
addEventHandler ( \"onClientRender\", getRootElement(), fbutton1)
addEventHandler ( \"onClientRender\", getRootElement(), fbutton2)
end
addEvent(\"jobmegjelenites\", true)
addEventHandler(\"jobmegjelenites\", getRootElement(), showjobgui)
function onPedClick(button, state, absX, absY, wx, wy, wz, clickedelement)
if button == \"right\" and state == \"down\" and clickedelement then
local x, y, z = getElementPosition(localPlayer)
if (clickedelement == csavoka1) then
if getDistanceBetweenPoints3D(x, y, z, wx, wy, wz)<=3 then
showjobgui()
end
end
end
end
addEventHandler(\"onClientClick\", root, onPedClick)
function bezaras()
showCursor(false)
destroyElement(jobgui)
removeEventHandler ( \"onClientRender\", getRootElement(), fbutton1)
removeEventHandler ( \"onClientRender\", getRootElement(), fbutton2)
end
bindKey ( \"backspace\", \"down\", bezaras )
function fbutton1()
local s = {guiGetScreenSize()}
local elol = false
local x,y = guiGetScreenSize()
-- local veh = getPedOccupiedVehicle(localPlayer)
-- if not elol or veh then return end
elol = true
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(351),95,25,tocolor(187,9,9,120))--1
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(351),2,25,tocolor(200,9,9,200))-- Line3
dxDrawRectangle(x/2+90/2+(50) + 94,y/2-960/2+(351),2,25,tocolor(200,9,9,200))-- Line4
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(350),95,2,tocolor(200,9,9,200))-- Line
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(375),95,2,tocolor(200,9,9,200))-- Line2
-- Hover
if(isCursorShowing()) then
XY = {guiGetScreenSize()}
local cursorX, cursorY = getCursorPosition()
cursorX, cursorY = cursorX*XY[1], cursorY*XY[2]
if(dobozbaVan(x/2+90/2+(50),y/2-960/2+(351),95,25,cursorX,cursorY))then
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(351),95,25,tocolor(187,9,9,130))--1
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(350),95,2,tocolor(200,9,9,255))-- Line
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(375),95,2,tocolor(200,9,9,255))-- Line2
dxDrawRectangle(x/2+90/2+(50),y/2-960/2+(351),2,25,tocolor(200,9,9,255))-- Line3
dxDrawRectangle(x/2+90/2+(50) + 94,y/2-960/2+(351),2,25,tocolor(200,9,9,255))-- Line4
end
end
end
addEvent(\"fbutton1\", true)
function fbutton2()
local s = {guiGetScreenSize()}
local elol = false
local x,y = guiGetScreenSize()
-- local veh = getPedOccupiedVehicle(localPlayer)
-- if not elol or veh then return end
elol = true
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(351),95,25,tocolor(187,9,9,120))--1
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(351),2,25,tocolor(200,9,9,200))-- Line3
dxDrawRectangle(x/2+90/2+(50) + 94,y/2-878/2+(351),2,25,tocolor(200,9,9,200))-- Line4
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(350),95,2,tocolor(200,9,9,200))-- Line
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(375),95,2,tocolor(200,9,9,200))-- Line2
-- Hover
if(isCursorShowing()) then
XY = {guiGetScreenSize()}
local cursorX, cursorY = getCursorPosition()
cursorX, cursorY = cursorX*XY[1], cursorY*XY[2]
if(dobozbaVan(x/2+90/2+(50),y/2-878/2+(351),95,25,cursorX,cursorY))then
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(351),95,25,tocolor(187,9,9,130))--1
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(350),95,2,tocolor(200,9,9,255))-- Line
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(375),95,2,tocolor(200,9,9,255))-- Line2
dxDrawRectangle(x/2+90/2+(50),y/2-878/2+(351),2,25,tocolor(200,9,9,255))-- Line3
dxDrawRectangle(x/2+90/2+(50) + 94,y/2-878/2+(351),2,25,tocolor(200,9,9,255))-- Line4
end
end
end
addEvent(\"fbutton2\", true)
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 felvesz1()
if (getElementData(localPlayer,\"munka\") >= 1) then
outputChatBox(\"Már van melód\")
else
setElementData(localPlayer, \"munka\", 1 )
outputChatBox(\"felvéve\")
end
end
-- function felvesz2()
-- outputChatBox(\"favágó\")
-- end
Utóirat: Kezdő fejlesztő vagyok!