abu5lf Posted April 13, 2012 Share Posted April 13, 2012 (edited) server side : addEvent("destroy",true) addEventHandler("destroy",root, function( theVehicle ) if destroyElement ( theVehicle ) then local cx = math.random(15461,34641) givePlayerMoney ( source, cx ) outputChatBox ( "* destroy theVehicle ".. cx .."", source, 255, 0, 0 ) else outputChatBox ( "* Enter theVehicle ", source, 255, 0, 0 ) end end end ) client side : GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(417,300,467,219,"destroy",false) GUIEditor_Button[1] = guiCreateButton(37,119,148,54,"destroy",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(268,117,148,54,"x",false,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1], false) function hide(button, state, absoluteX, absoluteY) if ( source == GUIEditor_Button[2] ) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) guiSetInputEnabled(false) end end addEventHandler ("onClientGUIClick", getRootElement(),hide) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == GUIEditor_Button[1] ) then triggerServerEvent("destroy",getLocalPlayer()) end end ) It's not working to destroy the vehicle . Edited December 25, 2012 by Guest Link to comment
myonlake Posted April 13, 2012 Share Posted April 13, 2012 (edited) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(417, 300, 467, 219, "destroy", false) GUIEditor_Button[1] = guiCreateButton(37, 119, 148, 54, "destroy", false, GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(268, 117, 148, 54, "x", false, GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1], false) addEventHandler("onClientGUIClick", root, function(button, state, absoluteX, absoluteY) if (source == GUIEditor_Button[2]) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) guiSetInputEnabled(false) end end, false ) addEventHandler("onClientGUIClick", root, function(button, state, absoluteX, absoluteY) if (source == GUIEditor_Button[1]) then triggerServerEvent("destroy", localPlayer) end end, false ) addEvent("destroy",true) addEventHandler("destroy", root, function() local vehicle = getPedOccupiedVehicle(source) if vehicle and destroyElement(vehicle) then local cash = math.random(15461, 34641) givePlayerMoney(source, cash) outputChatBox("* Destroyed your vehicle for $" .. cash, source, 255, 0, 0) else outputChatBox("* Enter a vehicle first.", source, 255, 0, 0) end end ) Edited April 13, 2012 by Guest Link to comment
Al3grab Posted April 13, 2012 Share Posted April 13, 2012 EDIT: sorry didn't sow your post myonlake. Sever addEvent("destroy",true) addEventHandler("destroy",root, function( theVehicle ) if ( isElement(theVehicle) ) then destroyElement ( theVehicle ) local cx = math.random(15461,34641) givePlayerMoney ( source, tonumber(cx) ) outputChatBox ( "* destroy theVehicle ".. tonumber(cx) .."", source, 255, 0, 0 ) else outputChatBox ( "* Enter theVehicle ", source, 255, 0, 0 ) end end ) Client GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(417,300,467,219,"destroy",false) GUIEditor_Button[1] = guiCreateButton(37,119,148,54,"destroy",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(268,117,148,54,"x",false,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1], false) function hide(button, state, absoluteX, absoluteY) if ( source == GUIEditor_Button[2] ) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) guiSetInputEnabled(false) end end addEventHandler ("onClientGUIClick", getRootElement(),hide) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == GUIEditor_Button[1] ) then pCar = getPedOccupiedVehicle(getLocalPlayer()) triggerServerEvent("destroy",getLocalPlayer(),pCar) end end ) Link to comment
myonlake Posted April 13, 2012 Share Posted April 13, 2012 getPedOccupiedVehicle() is automaticly a vehicle element, you're making a check if the occupiedVehicle is a vehicle element, which is unnecessary, also, trigger arguments are not recommend, so that's why you are able to make occupiedVehicle server-side. And no problem, we kind of have the same script. Link to comment
Al3grab Posted April 13, 2012 Share Posted April 13, 2012 i used that to check if he have a car because i didn't check it on client-side Link to comment
myonlake Posted April 13, 2012 Share Posted April 13, 2012 Yeah but you checked it it's a vehicle, you can just remove the getElementType and leave isElement there Or then just leave: if vehicle then Because it checks if the player is in a vehicle at the time the function is to be executed. Link to comment
Al3grab Posted April 13, 2012 Share Posted April 13, 2012 i put 'getElementType' to make sure it's a car , and it doesn't really matter Link to comment
myonlake Posted April 13, 2012 Share Posted April 13, 2012 Al3grab said: i put 'getElementType' to make sure it's a car , and it doesn't really matter Yes but getPedOccupiedVehicle() would not work if it wasn't a car, it would just output an error if he's not in a car. getPedOccupiedVehicle fetches the current VEHICLE so getElementType is unneeded Link to comment
abu5lf Posted April 13, 2012 Author Share Posted April 13, 2012 GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(417,300,467,219,"destroy",false) GUIEditor_Button[1] = guiCreateButton(37,119,148,54,"destroy",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(268,117,148,54,"x",false,GUIEditor_Window[1]) guiSetVisible(GUIEditor_Window[1], false) function hide(button, state, absoluteX, absoluteY) if ( source == GUIEditor_Button[2] ) then guiSetVisible(GUIEditor_Window[1], false) showCursor(false) guiSetInputEnabled(false) end end addEventHandler ("onClientGUIClick", getRootElement(),hide) addEventHandler ("onClientGUIClick", getRootElement(), function(button, state, absoluteX, absoluteY) if ( source == GUIEditor_Button[1] ) then pCar = getPedOccupiedVehicle(getLocalPlayer()) triggerServerEvent("destroy",getLocalPlayer(),pCar) end end ) function oppenz() if guiGetVisible ( GUIEditor_Window[1] ) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor(false) guiSetInputEnabled(false) else guiSetVisible ( GUIEditor_Window[1], true ) showCursor(true) guiSetInputEnabled(true) end end bindKey("F6","down",oppenz) addEvent("destroy",true) addEventHandler("destroy",root, function( theVehicle ) if ( isElement(theVehicle) and getElementType(theVehicle) == "vehicle" ) then destroyElement ( theVehicle ) local cx = math.random(15461,34641) givePlayerMoney ( source, tonumber(cx) ) outputChatBox ( "* destroy theVehicle ".. tonumber(cx) .."", source, 255, 0, 0 ) else outputChatBox ( "* Enter theVehicle ", source, 255, 0, 0 ) end end ) function hatmoter(source) local x,y,z = getElementPosition(source) theVehicle = createVehicle(500, x, y, z) warpPedIntoVehicle ( source, theVehicle ) end addCommandHandler ( "c", hatmoter ) It destroys vehicles freeroam I do not want it2 Link to comment
Al3grab Posted April 13, 2012 Share Posted April 13, 2012 addEvent("destroy",true) addEventHandler("destroy",root, function( ) if ( isElement(hatCars[source]) and getElementType(hatCars[source]) == "vehicle" ) then destroyElement ( hatCars[source] ) local cx = math.random(15461,34641) givePlayerMoney ( source, tonumber(cx) ) outputChatBox ( "* destroy theVehicle ".. tonumber(cx) .."", source, 255, 0, 0 ) else outputChatBox ( "* Enter theVehicle ", source, 255, 0, 0 ) end end ) hatCars = {} function hatmoter(player) if not hatCars[player] then local x,y,z = getElementPosition(player) hatCars[player] = createVehicle(500, x, y, z) warpPedIntoVehicle ( source, hatCars[player]) else outputChatBox("you already have one") end end addCommandHandler ( "c", hatmoter ) addEventHandler("onPlayerQuit",root,function() hatCars[source] = nil end ) Server Link to comment
abu5lf Posted April 13, 2012 Author Share Posted April 13, 2012 addEvent("destroy",true) addEventHandler("destroy",root, function( ) if ( isElement(hatCars[source]) and getElementType(hatCars[source]) == "vehicle" ) then destroyElement ( hatCars[source] ) local cx = math.random(15461,34641) givePlayerMoney ( source, tonumber(cx) ) outputChatBox ( "* destroy theVehicle ".. tonumber(cx) .."", source, 255, 0, 0 ) else outputChatBox ( "* Enter theVehicle ", source, 255, 0, 0 ) end end ) hatCars = {} function hatmoter(player) if not hatCars[player] then local x,y,z = getElementPosition(player) hatCars[player] = createVehicle(500, x, y, z) warpPedIntoVehicle ( source, hatCars[player]) else outputChatBox("you already have one") end end addCommandHandler ( "c", hatmoter ) addEventHandler("onPlayerQuit",root,function() hatCars[source] = nil end ) Server I'm sorry that it is working Thank you Link to comment
Al3grab Posted April 13, 2012 Share Posted April 13, 2012 addEvent("destroy",true) addEventHandler("destroy",root, function( ) if ( isElement(hatCars[source]) and getElementType(hatCars[source]) == "vehicle" ) then destroyElement ( hatCars[source] ) local cx = math.random(15461,34641) givePlayerMoney ( source, tonumber(cx) ) outputChatBox ( "* destroy theVehicle ".. tonumber(cx) .."", source, 255, 0, 0 ) else outputChatBox ( "* Enter theVehicle ", source, 255, 0, 0 ) end end ) hatCars = {} function hatmoter(player) if not hatCars[player] then local x,y,z = getElementPosition(player) hatCars[player] = createVehicle(500, x, y, z) warpPedIntoVehicle ( source, hatCars[player]) else outputChatBox("you already have one") end end addCommandHandler ( "c", hatmoter ) addEventHandler("onPlayerQuit",root,function() hatCars[source] = nil end ) Server I'm sorry that it is working Thank you Any time 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