bosslorenz Posted January 8, 2015 Share Posted January 8, 2015 (edited) local marker1 = createMarker( 1920.599609375, 1310.099609375, 8, "cylinder", 2, 0 ,0, 255, 155 ) GUIEditor = { button = {}, window = {}, memo = {} } addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.window[1] = guiCreateWindow(275, 76, 219, 461, "LV MAFIA VEHICLE SPAWNER", false) guiWindowSetSizable(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) end ) addEventHandler("onMarkerHit",marker1,showGUI) Why GUI is not showing up when I step on marker Edited January 10, 2015 by Guest Link to comment
Castillo Posted January 8, 2015 Share Posted January 8, 2015 Because "showGUI" function is not defined. You must remove the "onClientResourceStart" event handler, and the parentheses ")" at line 26. Also, you should check if the element that entered the marker is the local player, because remote players can trigger client side markers aswell. Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 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) 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) end addEventHandler("onMarkerHit",marker1,showGUI) LVspawner.lua:10: attempt to call global 'guiCreateWindow' (a nil value) Link to comment
Castillo Posted January 8, 2015 Share Posted January 8, 2015 You obviously set the script as server side in the meta.xml, GUI functions are client side only. Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 You obviously set the script as server side in the meta.xml, GUI functions are client side only. "play" type="map" version="1.0.0"> "TESTING.map" dimension="0"> "#maxplayers" value="[ 128 ]"> "#useLODs" value="[ false ]"> "#gamespeed" value="[ 1 ]"> "#minplayers" value="[ 0 ]"> "#gravity" value="[ 0.0080000003799796104 ]"> "#waveheight" value="[ 0 ]"> "#locked_time" value="[ true ]"> "#weather" value="[ 0 ]"> "#time" value="5:0"> Link to comment
Castillo Posted January 8, 2015 Share Posted January 8, 2015 In which script is the code that creates the GUI? Also, you must use the event "onClientMarkerHit", since "onMarkerHit" is server side. Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 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) 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 veh = createVehicle(580, 1927.5999755859, 1309.8000488281, 9.3999996185303, 0, 0, 270) guiSetVisible(GUIEditor.window[1],false) showCursor(false) end end addEventHandler("onClientGUIClick", root , spawn1) Its working now, it spawns car but player cant enter the vehicle. Link to comment
Castillo Posted January 8, 2015 Share Posted January 8, 2015 That's because you created the vehicle client side, if you do that, you won't be able to use it. You need to create the vehicle server side, to do that, you need to use triggers, meaning triggerServerEvent. Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 SERVER SIDE function vehicle1() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) createVehicle( 580, 1927.5999755859, 1309.8000488281, 9.3999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) 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 x,y,z = getElementPosition(source) createVehicle( 463, 1928.0999755859, 1313.0999755859, 8.8999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end addEvent("spawn2", true) addEventHandler("spawn2",root,vehicle2) 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) 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) Ive dont spawner now, but I want to destroy players vehicle if spawning another one and "onPlayerWasted", "onPlayerQuit" Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 SERVER SIDE function vehicle1() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) createVehicle( 580, 1927.5999755859, 1309.8000488281, 9.3999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) 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 x,y,z = getElementPosition(source) createVehicle( 463, 1928.0999755859, 1313.0999755859, 8.8999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end addEvent("spawn2", true) addEventHandler("spawn2",root,vehicle2) 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) 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) Ive dont spawner now, but I want to destroy players vehicle if spawning another one and "onPlayerWasted", "onPlayerQuit" Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 SERVER SIDE function vehicle1() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) createVehicle( 580, 1927.5999755859, 1309.8000488281, 9.3999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) 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 x,y,z = getElementPosition(source) createVehicle( 463, 1928.0999755859, 1313.0999755859, 8.8999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end addEvent("spawn2", true) addEventHandler("spawn2",root,vehicle2) 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) 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) Ive dont spawner now, but I want to destroy players vehicle if spawning another one and "onPlayerWasted", "onPlayerQuit" Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 local theVehicle = {} function vehicle1() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) if (getElementType(hitElement) == "player") and not isPedInVehicle(hitElement) then if isElement( theVehicle[hitElement] ) then destroyElement( theVehicle[hitElement] ) end theVehicle[hitElement] = createVehicle( 580, 1927.5999755859, 1309.8000488281, 9.3999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end end addEvent("spawn1", true) addEventHandler("spawn1",root,vehicle1) addEventHandler("onPlayerWasted",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) addEventHandler("onPlayerQuit",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) function vehicle2() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) if (getElementType(hitElement) == "player") and not isPedInVehicle(hitElement) then if isElement( theVehicle[hitElement] ) then destroyElement( theVehicle[hitElement] ) end theVehicle[hitElement] = createVehicle( 463, 1928.0999755859, 1313.0999755859, 8.8999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end end addEvent("spawn2", true) addEventHandler("spawn2",root,vehicle2) addEventHandler("onPlayerWasted",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) addEventHandler("onPlayerQuit",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) I added the destroyElement from my script to GUI script with spawn vehicle. And now, it doesnt spawn anymore vehicles... Link to comment
Moderators IIYAMA Posted January 8, 2015 Moderators Share Posted January 8, 2015 Line 51 and 58: if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end if theVehicle[source] then if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) end theVehicle[source] = nil end When vehicles get destroyed by another resource or they are included in a map, your system doesn't clean the table properly. Also your code is duplicated, it probably doesn't work because you have two times the same event handlers. Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 local theVehicle = {} function vehicle1() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) if (getElementType(hitElement) == "player") and not isPedInVehicle(hitElement) then if isElement( theVehicle[hitElement] ) then destroyElement( theVehicle[hitElement] ) end theVehicle[hitElement] = createVehicle( 580, 1927.5999755859, 1309.8000488281, 9.3999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end end addEvent("spawn1", true) addEventHandler("spawn1",root,vehicle1) addEventHandler("onPlayerWasted",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) addEventHandler("onPlayerQuit",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) function vehicle2() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) if (getElementType(hitElement) == "player") and not isPedInVehicle(hitElement) then if isElement( theVehicle[hitElement] ) then destroyElement( theVehicle[hitElement] ) end theVehicle[hitElement] = createVehicle( 463, 1928.0999755859, 1313.0999755859, 8.8999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end end addEvent("spawn2", true) addEventHandler("spawn2",root,vehicle2) addEventHandler("onPlayerWasted",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) addEventHandler("onPlayerQuit",root,function() if isElement( theVehicle[source]) then destroyElement(theVehicle[source]) theVehicle[source] = nil end end ) LVspawnerS.lua : 8: Bad argument @ 'getElementType' [Expected element at argument 1, got nil] @IIYAMA , still wont work #HAVING PROBLEM WITH THIS DESTROY SPAWN VEHICLE WHEN SPAWNING ANOTHER ONE, and also "onPlayerQuit" and "onPlayerWasted" #AND ALSO WONT SPAWN VEHICLE SAYS YOU ARE NOT IN TEAM LV. Even tho Im on TEAM LV Link to comment
Moderators IIYAMA Posted January 8, 2015 Moderators Share Posted January 8, 2015 Are you kidding me? How am I suppose to help you when you aren't correcting your code? I already said what you have to change, DO IT! LVspawnerS.lua : 8: Bad argument @ 'getElementType' [Expected element at argument 1, got nil] hitElement has never been defined in the entire code, you can't expect it to be something. Use the predefined variable > client < instead. Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 Dont know what to do anymore, can you just tell me the script guys? Link to comment
bosslorenz Posted January 8, 2015 Author Share Posted January 8, 2015 SERVER SIDE function vehicle1() local playerTeam = getPlayerTeam ( source ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if ( teamName == "LV MAFIA" ) then local x,y,z = getElementPosition(source) createVehicle( 580, 1927.5999755859, 1309.8000488281, 9.3999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) 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 x,y,z = getElementPosition(source) createVehicle( 463, 1928.0999755859, 1313.0999755859, 8.8999996185303, 0, 0, 270 ) else outputChatBox ("You cant spawn vehicle here, you`re not LV MAFIA player",player,200, 0, 100) end end addEvent("spawn2", true) addEventHandler("spawn2",root,vehicle2) 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) 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) Can anyone help me with the scripts for 1 vehicle per player only: destroy vehicle when spawning another one, and onPlayerQuit and onPlayerWasted Link to comment
Moderators Citizen Posted January 9, 2015 Moderators Share Posted January 9, 2015 You know how ternary works in lua and you know how to use them but you can't do that simple task ??? oO 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 else outputChatBox("You can't spawn a vehicle here, you're not a LV MAFIA member", client, 200, 0, 100) 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, 1928.1, 1313.1, 8.9, 0, 0, 270 ) setElementData(client, "mafiaVeh", veh) else outputChatBox("You can't spawn a vehicle here, you're not a LV MAFIA member", client, 200, 0, 100) end end addEvent("spawn2", true) addEventHandler("spawn2", root, vehicle2) Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 Thanks for that Citizen But can u tell me whats wrong with this script I put? 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 else outputChatBox("You can't spawn a vehicle here, you're not a LV MAFIA member", client, 200, 0, 100) 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, 1928.1, 1313.1, 8.9, 0, 0, 270 ) setElementData(client, "mafiaVeh", veh) else outputChatBox("You can't spawn a vehicle here, you're not a LV MAFIA member", client, 200, 0, 100) end end addEvent("spawn2", true) addEventHandler("spawn2", root, vehicle2) addEventHandler("onPlayerWasted",root,function() if isElement( prevVeh[source]) then destroyElement(prevVeh[source]) prevVeh[source] = nil end end ) Im adding onPlayerWasted but it tells attempt to call global Link to comment
Mizudori Posted January 10, 2015 Share Posted January 10, 2015 Can you show the error? Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 >>>>>>lua :37 : attempt to index global 'prevVeh' a nil value<<<<< Link to comment
Mizudori Posted January 10, 2015 Share Posted January 10, 2015 >>>>>>lua :37 : attempt to index global 'prevVeh' a nil value<<<<<< So onPlayerWasted event should destroy the vehicle if player is in it or what? Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 onPlayerWasted inside vehicle and onPlayerWasted outside vehicle.... Link to comment
Mizudori Posted January 10, 2015 Share Posted January 10, 2015 addEventHandler("onPlayerWasted",root,function() local veh = getElementData(source, "mafiaVeh") if(veh)then 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 lua :39 : unexpected symbol near 'then' 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