GibraltarLabrador Posted December 16, 2013 Share Posted December 16, 2013 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
Castillo Posted December 16, 2013 Share Posted December 16, 2013 When exactly do you want to attach it? Link to comment
GibraltarLabrador Posted December 16, 2013 Author Share Posted December 16, 2013 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
GibraltarLabrador Posted December 16, 2013 Author Share Posted December 16, 2013 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
Castillo Posted December 16, 2013 Share Posted December 16, 2013 triggerClientEvent ( "Kust", root ) Change that to: triggerClientEvent ( hitElement, "Kust", hitElement ) Link to comment
GibraltarLabrador Posted December 16, 2013 Author Share Posted December 16, 2013 Solidsnake14, I have no words! Thank you so much! Can you explain the logic of this action? Link to comment
Castillo Posted December 16, 2013 Share Posted December 16, 2013 triggerClientEvent has a sendTo argument, means that the event will be triggered for the element you put in there, if you don't fill it, it'll stay as default using "root" which is everything and everyone. Link to comment
Narrator Posted December 16, 2013 Share Posted December 16, 2013 Solidsnake14, Thank you very much! Link to comment
GibraltarLabrador Posted December 16, 2013 Author Share Posted December 16, 2013 I want to attach to the train marker. if there are no players in the marker train stops. how can I make it in the server side? if i will use the isElementWithinMarker what argument should be a player? Excuse me, I'm writing from the tablet. Link to comment
Castillo Posted December 17, 2013 Share Posted December 17, 2013 Use the following functions: getElementColShape -- Obtain the marker colshape. getElementsWithinColShape -- Get the players inside colshape. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now