Jump to content

[HELP]


Recommended Posts

How can I make a marker on the client side and spawn a car on the server side when a player enters it?*
I would like to create a Marker on the client side and if the player goes into it, a car will spawn on the server side
 
 
 
Oh Oh I just looked at shared function
 
 
 
Link to comment

local sx,sy = guiGetScreenSize();--1920,1080
local relx,rely = sx/1920,sy/1080;
-----------
IsCardShop = false
local money = getPlayerMoney(localPlayer)
local Cardlist = {
[1] = {411, "Jogosítvány", 1000},
[2] = {482, "Jogosítvány", 10000},
};
color = tocolor(41, 173, 21, 255)
-----------
function Panel()
       if IsCardShop == true then 
          dxDrawRectangle(sx*.35, sy*.35, sx*.30, sy*.05, tocolor(0, 0, 0, 200))--Fejléc    
            dxDrawText("Jogosítvány", sx*.50, sy*.035, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawRectangle(sx*.35, sy*.40, sx*.30, sy*.20, tocolor(30, 40, 50, 250))-- panel 
          dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, color1 or color)--gomb1
            dxDrawText("Megvétel", sx*.36, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
            dxDrawText("Legális 1000$", sx*.36, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawRectangle(sx*0.55, sy*0.47, sx*0.06, sy*0.05, color2 or color)--gomb1
            dxDrawText("Megvétel", sx*.66, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat          
          dxDrawText("Ilegális 10000$", sx*.66, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawText("Összeged: "..money.."$", sx*.52, sy*.40, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
-----------
function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    
    return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
end
-----------
if isMouseInPosition(sx*.40, sy*.47, sx*.06, sy*.05) then
  color1 = tocolor(34, 110, 23, 255)
  else
    color1 = color
end
-----------
if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then
    color2 = tocolor(34, 110, 23, 255)
    else
      color2 = color
end
end
end
-----------
function OpenWindow()
    IsCardShop = not IsCardShop
    if removeEventHandler("onClientRender", root, Panel) then
    removeEventHandler("onClientRender", root, Panel)
    showCursor(false)
else
    addEventHandler("onClientRender", root, Panel)
    showCursor(true)
end
end
----------
addEventHandler("onClientClick", root,
  function(button,state)
    if IsCardShop then
      if ( button == "left" and state == "down" ) then
        if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then
        takePlayerMoney (10000)
        IsCardShop = false
        outputChatBox("Menj be a Markerbe a vizsga elkezdéséhez")
        local playerMarker = createMarker(341.64114379883, -1351.6920166016, 14.5078125, "cylinder", 1, 10, 244, 23, 200)
        end
    end
end
end)
----------
function handlePlayerMarker(hitElement)
    local elementType = getElementType(hitElement)
    outputChatBox(" Itt tudod fel venni a szolgálatott /dutyonR")
    outputChatBox("Itt tudod le tenni a szolgálatott /dutyoffR")
end
addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
----------
local thePed = createPed(579, 336.8766784668, -1358.7130126953, 14.5078125, 280)

addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld)
    if (button == "right") and (state == "up") then
        if isElement(clickedWorld) and clickedWorld == thePed then
            IsCardShop = not IsCardShop
            removeEventHandler("onClientRender", root, Panel)
            if IsCardShop then
                addEventHandler("onClientRender", root, Panel)
            end
        end
    end
end)

bindKey("BACKSPACE","down",function() if IsCardShop == true then IsCardShop = false end end)    

unknown.png

Link to comment
-- Client Side
local sx,sy = guiGetScreenSize();--1920,1080
local relx,rely = sx/1920,sy/1080;
-----------
IsCardShop = false
local money = getPlayerMoney(localPlayer)
local Cardlist = {
[1] = {411, "Jogosítvány", 1000},
[2] = {482, "Jogosítvány", 10000},
};
color = tocolor(41, 173, 21, 255)
-----------
function Panel()
       if IsCardShop == true then 
          dxDrawRectangle(sx*.35, sy*.35, sx*.30, sy*.05, tocolor(0, 0, 0, 200))--Fejléc    
            dxDrawText("Jogosítvány", sx*.50, sy*.035, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawRectangle(sx*.35, sy*.40, sx*.30, sy*.20, tocolor(30, 40, 50, 250))-- panel 
          dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, color1 or color)--gomb1
            dxDrawText("Megvétel", sx*.36, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
            dxDrawText("Legális 1000$", sx*.36, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawRectangle(sx*0.55, sy*0.47, sx*0.06, sy*0.05, color2 or color)--gomb1
            dxDrawText("Megvétel", sx*.66, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat          
          dxDrawText("Ilegális 10000$", sx*.66, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawText("Összeged: "..money.."$", sx*.52, sy*.40, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
-----------
function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    
    return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
end
-----------
if isMouseInPosition(sx*.40, sy*.47, sx*.06, sy*.05) then
  color1 = tocolor(34, 110, 23, 255)
  else
    color1 = color
end
-----------
if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then
    color2 = tocolor(34, 110, 23, 255)
    else
      color2 = color
end
end
end
-----------
function OpenWindow()
    IsCardShop = not IsCardShop
    if removeEventHandler("onClientRender", root, Panel) then
    removeEventHandler("onClientRender", root, Panel)
    showCursor(false)
else
    addEventHandler("onClientRender", root, Panel)
    showCursor(true)
end
end
----------
addEventHandler("onClientClick", root,
  function(button,state)
    if IsCardShop then
      if ( button == "left" and state == "down" ) then
        if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then
        	triggerServerEvent("car", getLocalPlayer())
        IsCardShop = false
        outputChatBox("Menj be a Markerbe a vizsga elkezdéséhez")
        end
    end
end
end)
----------
local thePed = createPed(579, 336.8766784668, -1358.7130126953, 14.5078125, 280)

addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld)
    if (button == "right") and (state == "up") then
        if isElement(clickedWorld) and clickedWorld == thePed then
            IsCardShop = not IsCardShop
            removeEventHandler("onClientRender", root, Panel)
            if IsCardShop then
                addEventHandler("onClientRender", root, Panel)
            end
        end
    end
end)

bindKey("BACKSPACE","down",function() if IsCardShop == true then IsCardShop = false end end)

 

Link to comment
-- Server Side
addEventHandler("onPlayerQuit", root,
	function()
		if isElement(vehicle[source]) then
			destroyElement(vehicle[source])
			vehicle[source] = nil
	end
end)

vehicle = {}

addEvent("car", true)
addEventHandler("car", root,
	function()
		if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
		local x, y, z = getElementPosition(source)
		vehicle[source] = createVehicle(599, x, y, z) --599 is the vehicle's hands. Put any vehicle you want
		warpPedIntoVehicle(source, vehicle[source])
end)

try this

1 minute ago, Firespider said:
Can you help me in this?
 
 

try this

Link to comment
7 hours ago, Firespider said:
Why is playerMaker not detected?
 

 

 

unknown.png

unknown.png

addEvent("car", true)
addEventHandler("car", root,
    function()
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
        local x, y, z = getElementPosition(source)
        vehicle[source] = createVehicle(599, x, y, z) --599 is the vehicle's hands. Put any vehicle you want
        warpPedIntoVehicle(source, vehicle[source])
        playerMarker = createMarker(341.64114379883, -1351.6920166016, 14.5078125, "cylinder", 1, 10, 244, 23, 200)
        addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
end)

function handlePlayerMarker(hitElement)
    local elementType = getElementType(hitElement)
    outputChatBox(" Itt tudod fel venni a szolgálatott /dutyonR")
    outputChatBox("Itt tudod le tenni a szolgálatott /dutyoffR")
end

 

 

Link to comment
-- Server Side
addEventHandler("onPlayerQuit", root,
	function()
		if isElement(vehicle[source]) then
			destroyElement(vehicle[source])
			vehicle[source] = nil
	end
end)

vehicle = {}

addEvent("car", true)
addEventHandler("car", root,
    function()
        if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
        local x, y, z = getElementPosition(source)
        vehicle[source] = createVehicle(579, 341.7890625, -1373.0964355469, 14.366669654846, 0, 380, 470) --599 is the vehicle's hands. Put any vehicle you want
        warpPedIntoVehicle(source, vehicle[source])
        playerMarker = createMarker(313.41094970703, -1394.2287597656, 13.993467330933, "cylinder", 4, 255, 0, 0, 0)
        addEventHandler("onMarkerHit", playerMarker, handlePlayerMarker)
end)

function handlePlayerMarker(hitElement)
    local elementType = getElementType(hitElement)
    destroyElement(playerMarker)
end

 

Do you also need the client side?
 
 
 
Link to comment
--Client Side
local sx,sy = guiGetScreenSize();--1920,1080
local relx,rely = sx/1920,sy/1080;
-----------
IsCardShop = false
local money = getPlayerMoney(localPlayer)
local Cardlist = {
[1] = {411, "Jogosítvány", 1000},
[2] = {482, "Jogosítvány", 10000},
};
color = tocolor(41, 173, 21, 255)
-----------
function Panel()
       if IsCardShop == true then 
          dxDrawRectangle(sx*.35, sy*.35, sx*.30, sy*.05, tocolor(0, 0, 0, 200))--Fejléc    
            dxDrawText("Jogosítvány", sx*.50, sy*.035, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawRectangle(sx*.35, sy*.40, sx*.30, sy*.20, tocolor(30, 40, 50, 250))-- panel 
          dxDrawRectangle(sx*.40, sy*.47, sx*.06, sy*.05, color1 or color)--gomb1
            dxDrawText("Megvétel", sx*.36, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
            dxDrawText("Legális 1000$", sx*.36, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawRectangle(sx*0.55, sy*0.47, sx*0.06, sy*0.05, color2 or color)--gomb1
            dxDrawText("Megvétel", sx*.66, sy*.27, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat          
          dxDrawText("Ilegális 10000$", sx*.66, sy*.19, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
          dxDrawText("Összeged: "..money.."$", sx*.52, sy*.40, sx*.50, sy*.72, tocolor(200, 200, 200, 255), relx*2, rely*2, "default-bold", "center", "center", false, false, false)--Felirat
-----------
function isMouseInPosition ( x, y, width, height )
    if ( not isCursorShowing( ) ) then
        return false
    end
    local sx, sy = guiGetScreenSize ( )
    local cx, cy = getCursorPosition ( )
    local cx, cy = ( cx * sx ), ( cy * sy )
    
    return ( ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) )
end
----------    
if isMouseInPosition(sx*.40, sy*.47, sx*.06, sy*.05) then
  color1 = tocolor(88, 0, 0, 50)
  else
    color1 = color
end
-----------
if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then
    color2 = tocolor(88, 0, 0, 50)
    else
      color2 = color
end
end
end
---------- 
function OpenWindow()
    IsCardShop = not IsCardShop
    if removeEventHandler("onClientRender", root, Panel) then
    removeEventHandler("onClientRender", root, Panel)
    showCursor(false)
else
    addEventHandler("onClientRender", root, Panel)
    showCursor(true)
end
end
bindKey("F3", "down", OpenWindow)
----------
addEventHandler("onClientClick", root,
  function(button,state)
    if IsCardShop == true then
      if ( button == "left" and state == "down" ) then
        if isMouseInPosition(sx*0.55, sy*0.47, sx*0.06, sy*0.05) then
        local yourMoney = getPlayerMoney()
        if ( yourMoney >= 10000) then
          takePlayerMoney(10000)
          triggerServerEvent("car", getLocalPlayer())
        else
        outputChatBox("* You Don't Have Enough Money",255,0,0,true)
        --outputChatBox("Menj be a Markerbe a vizsga elkezdéséhez")
      end
    end
  end
end
end)
----------

local thePed = createPed(579, 336.8766784668, -1358.7130126953, 14.5078125, 280)

addEventHandler("onClientClick", root, function(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedWorld)
    if (button == "right") and (state == "up") then
        if isElement(clickedWorld) and clickedWorld == thePed then
            IsCardShop = not IsCardShop
            removeEventHandler("onClientRender", root, Panel)
            if IsCardShop then
                addEventHandler("onClientRender", root, Panel)
            end
        end
    end
end)

bindKey("BACKSPACE","down",function() if IsCardShop == true then IsCardShop = false end end)
--Server Side
vehicle = {}
--------
addEvent("car", true)
addEventHandler("car", root,
	function()
		if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
		local x, y, z = getElementPosition(source)
		vehicle[source] = createVehicle(599, x, y, z) --599 is the vehicle's hands. Put any vehicle you want
		warpPedIntoVehicle(source, vehicle[source])
end)

try this

20 minutes ago, Firespider said:
It just doesn't detect the playerMarker for some reason
 
 
 

You what do you want, I do not understand you Do you want a panel to open in Marker

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...