Mizudori Posted January 10, 2015 Share Posted January 10, 2015 lua :39 : unexpected symbol near 'then' Typo, forgot if() addEventHandler("onPlayerWasted",root,function() local veh = getElementData(source, "mafiaVeh") if(veh)then if(isElement(veh))then destroyElement(veh) setElementData(source,"mafiaVeh",nil) end end end ) Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 Okay thanks to you guys who helped me. Changing topic to FIXED Link to comment
Moderators Citizen Posted January 11, 2015 Moderators Share Posted January 11, 2015 addEventHandler("onPlayerWasted",root,function() local veh = getElementData(source, "mafiaVeh") if(veh)then if(isElement(veh))then destroyElement(veh) setElementData(source,"mafiaVeh",nil) end end end ) Can be shortened by puting "if veh then" and "if isElement(veh) then" into a single if condition like this: addEventHandler("onPlayerWasted", root, function() local veh = getElementData(source, "mafiaVeh") if veh and isElement(veh) then destroyElement(veh) setElementData(source, "mafiaVeh", nil) end end) Link to comment
bosslorenz Posted January 11, 2015 Author Share Posted January 11, 2015 CLIENT SIDE-- local marker1 = createMarker( 1920.599609375, 1310.099609375, 8, "cylinder", 2, 0 ,0, 255, 155 ) GUIEditor = { button = {}, window = {}, memo = {} } function showGUI() GUIEditor.window[1] = guiCreateWindow(275, 76, 219, 461, "LV MAFIA VEHICLE SPAWNER", false) guiWindowSetSizable(GUIEditor.window[1], false) guiWindowSetMovable (GUIEditor.window[1], false) guiSetProperty(GUIEditor.window[1], "CaptionColour", "FF41FF00") GUIEditor.button[1] = guiCreateButton(9, 27, 200, 79, "STAFFORD", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[1], "default-bold-small") guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFFF0000") GUIEditor.button[2] = guiCreateButton(9, 114, 200, 76, "FREEWAY", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[2], "default-bold-small") guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FFFF0000") GUIEditor.button[3] = guiCreateButton(131, 415, 78, 36, "CLOSE", false, GUIEditor.window[1]) guiSetFont(GUIEditor.button[3], "default-bold-small") guiSetProperty(GUIEditor.button[3], "NormalTextColour", "FFFF0000") GUIEditor.memo[1] = guiCreateMemo(9, 216, 200, 169, "This is only available to team LV MAFIA. That means, only players who are in team LV MAFIA can spawn vehicles in this marker.\n\nWARNING : Spawning another vehicle will destroy the existing vehicle you spawned earlier.", false, GUIEditor.window[1]) guiMemoSetReadOnly(GUIEditor.memo[1], true) showCursor(true) end addEventHandler("onClientMarkerHit",marker1,showGUI) function spawn1() if ( source == GUIEditor.button[1] ) then triggerServerEvent("spawn1",localPlayer) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("onClientGUIClick", root, spawn1) function spawn2() if ( source == GUIEditor.button[2] ) then triggerServerEvent("spawn2",localPlayer) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("onClientGUIClick", root, spawn2) function closeGUI() if ( source == GUIEditor.button[3] ) then guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler ("onClientGUIClick", root, closeGUI) SERVER SIDE-- function vehicle1() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if teamName == "LV MAFIA" then local prevVeh = getElementData(client, "mafiaVeh") -- get the element stored in mafiaVeh for the player if prevVeh and isElement(prevVeh) then -- if it exist and if it's an element then destroyElement(prevVeh) -- destroy it end local veh = createVehicle( 580, 1927.6, 1309.8, 9.4, 0, 0, 270 ) -- creating the vehicle setElementData(client, "mafiaVeh", veh) -- storing the vehicle in "mafiaVeh" for the player end end addEvent("spawn1", true) addEventHandler("spawn1", root, vehicle1) function vehicle2() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if teamName == "LV MAFIA" then local prevVeh = getElementData(client, "mafiaVeh") if prevVeh and isElement(prevVeh) then destroyElement(prevVeh) end local veh = createVehicle( 463, 1927.6, 1309.8, 8.9, 0, 0, 270 ) setElementData(client, "mafiaVeh", veh) end end addEvent("spawn2", true) addEventHandler("spawn2", root, vehicle2) addEventHandler("onPlayerWasted",root,function() local veh = getElementData(source, "mafiaVeh") if(veh)then if(isElement(veh))then destroyElement(veh) setElementData(source,"mafiaVeh",nil) end end end ) addEventHandler("onPlayerQuit",root,function() local veh = getElementData(source, "mafiaVeh") if(veh)then if(isElement(veh))then destroyElement(veh) setElementData(source,"mafiaVeh",nil) end end end ) Why does the GUI shows to every one, just for example . 2 players and only 1 player step into the marker but the GUIwindow show to both of them? Anything wrong with the script? Link to comment
roaddog Posted January 11, 2015 Share Posted January 11, 2015 function showGUI(p) if (p == localPlayer) then -- Add this line to check if the element hits the marker is localPlayer. --insert your script here end end addEventHandler("onClientMarkerHit",marker1,showGUI) 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