Jump to content

Marker from client side


Recommended Posts

Hi guys!

Help me please:

Server side:

  
  
local  cab = createObject(xxx,0,0,0) 
local  auto = createVehicle(569,-1942.51733,167.78510,25.71094) 
  
  
attachElements(cab,auto,0,0,0) 
setVehicleLocked(auto,true) 
setTrainDerailable(auto, false) 
setTrainDirection(auto, true) 
createBlipAttachedTo(auto,0) 
  
function Gtrain () 
     SPEEDER = setTimer(SPEED,50,0) 
end 
--addEventHandler("onResourceStart", root, Gtrain) 
  
function SPEED () 
setTrainSpeed(auto, 0.25)  
end 
  
  

Client side:

  
  
marker = createMarker( 1548, -1670, 12.6, "cylinder", 2, 255, 255, 255, 150 ) 
  
        local screenW, screenH = guiGetScreenSize() 
        window = guiCreateWindow((screenW - 447) / 2, (screenH - 412) / 2, 447, 412, "Info", false) 
        guiSetVisible(window, false) 
        guiWindowSetSizable(window, false) 
        memo = guiCreateMemo(23, 32, 399, 292, "(text)", false, window) 
        guiMemoSetReadOnly(memo, true) 
        button = guiCreateButton(23, 334, 400, 64, "Close", false, window)     
  
    function close() 
         if (source == button) then 
         guiSetVisible(window,false) 
         showCursor(false) 
         end 
    end 
    addEventHandler("onClientGUIClick", button, close) 
     
    function showgui (hitElement) 
         if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
                  if not guiGetVisible(window) then 
                       guiSetVisible(window, true) 
                       showCursor(true) 
                  end 
         end 
    end 
    addEventHandler("onClientMarkerHit", marker, showgui) 
  
    function showguil (leaveElement) 
         if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
                  if guiGetVisible(window) then 
                       guiSetVisible(window, false) 
                       showCursor(false) 
                  end 
         end 
    end 
    addEventHandler("onClientMarkerLeave", marker, showguil) 
  
  

In the server side of a local variable "cab" creates an object (object model - xxx. Ignore it for simplicity). Further, this object is attached to the wagons. That's all right.

In client-side marker is created, which climbs stepping window. Since this is also okay.

I need to marker that is created on the client side too, somehow attached to the train. I have not tried that just do not know what to do. Please reply!

UPD: Do not offer to move all the code from the server side to the client and sorry for my bad english.

Link to comment

Solidsnake14,

Shorter and understandable wording:

I need to create transport and marker in the server-side, attach marker to the created transport and conclude window on the player occurring in the marker (this is important!)

What exactly I do not get:

Yes, I get to create the server-side marker and transport. Yes, I get to attach marker to the created transport, but it is impossible to conclude the windows only occurring in the marker player because getLocalPlayer only works on the client side and the window displays all.

Sorry for my bad english

Link to comment

Solidsnake14,

See this code and read the comments (updated).

Client-side:

  
        local screenW, screenH = guiGetScreenSize() 
        window = guiCreateWindow((screenW - 447) / 2, (screenH - 412) / 2, 447, 412, "Info", false) 
        guiSetVisible(window, false) 
        guiWindowSetSizable(window, false) 
        memo = guiCreateMemo(23, 32, 399, 292, "(text)", false, window) 
        guiMemoSetReadOnly(memo, true) 
        button = guiCreateButton(23, 334, 400, 64, "Close", false, window)     
  
    function close() 
         if (source == button) then 
         guiSetVisible(window,false) 
         showCursor(false) 
         end 
    end 
    addEventHandler("onClientGUIClick", button, close) 
     
    addEvent ( "Kust", true ) 
    function showgui () 
      if not guiGetVisible(window) then 
        guiSetVisible(window, true) 
        showCursor(true) 
      end 
    end 
    addEventHandler ( "Kust", root, showgui) 
  
    function showguil (leaveElement) 
         if getElementType(leaveElement) == "player" and (leaveElement == localPlayer) then 
                  if guiGetVisible(window) then 
                       guiSetVisible(window, false) 
                       showCursor(false) 
                  end 
         end 
    end 
    addEventHandler("onClientMarkerLeave", marker, showguil) 
  

Server-side:

  
local  cabe = createMarker( 0,0,0, "cylinder", 2, 255, 255, 255, 150 ) 
local  auto = createVehicle(569,-1942.51733,167.78510,25.71094) 
  
  
attachElements(cabe,auto,0,0,0,0,0,0) 
setVehicleLocked(auto,true) 
setTrainDerailable(auto, false) 
setTrainDirection(auto, true) 
createBlipAttachedTo(auto,0) 
  
function Gtrain () 
     SPEEDER = setTimer(SPEED,50,0) 
end 
--addEventHandler("onResourceStart", root, Gtrain) 
  
function SPEED () 
setTrainSpeed(auto, 0.25)  
end 
  
function onStepTrainMarker (hitElement) 
  if getElementType(hitElement) == "player" then 
    triggerClientEvent ( "Kust", root ) --!!!this event should be invoked only for the player that occurred with marker!!! 
    outputChatBox ( "1", hitElement) 
  end 
end 
addEventHandler("onMarkerHit", cabe, onStepTrainMarker)   
  
  

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...