Xwad Posted February 12, 2015 Share Posted February 12, 2015 (edited) Hi i made a vehicle shop script for my server but i have 2 problems: when i buy the vehicle then the vehicle always falls on me and i die.. How can i make that when i buy the vehicle then the script takes me in the car? another problem is that the script dosent take the money when i buy the vehicle! here is a part of the script: function vehicleFBITruck( player ) if source == vehicleFBITruck then triggerServerEvent("vehFBITruck",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) if ( getPlayerMoney (source) >= 3000 ) then takePlayerMoney(source, 3000) else outputChatBox('You don\'t have enough money to buy this Vehicle.', source, 255, 0, 0 ) end end end end end) addEventHandler("onClientGUIClick",getRootElement(),vehicleFBITruck) Edited February 12, 2015 by Guest Link to comment
Professional Posted February 12, 2015 Share Posted February 12, 2015 Plez Use For Cods [lua] Link to comment
Professional Posted February 12, 2015 Share Posted February 12, 2015 is your cods function vehicleFBITruck( player ) if source == vehicleFBITruck then triggerServerEvent("vehFBITruck",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) if ( getPlayerMoney (source) >= 3000 ) then takePlayerMoney(source, 3000) else outputChatBox('You don\'t have enough money to buy this Vehicle.', source, 255, 0, 0 ) end end end end end) addEventHandler("onClientGUIClick",getRootElement(),vehicleFBITruck) Link to comment
Xwad Posted February 12, 2015 Author Share Posted February 12, 2015 ??? this is the full code s_vehicle.lua function vehicleBlips() vehBlipOne = createBlip(-2404.1486816406, -2201.865234375, 32.2,55) end addEventHandler("onResourceStart",getRootElement(),vehicleBlips) function vehicleRhino( player ) local x, y, z = getElementPosition ( source ) createVehicle ( 432, x, y, z + 5 ) end addEvent("vehRhino",true) addEventHandler("vehRhino",root,vehicleRhino) function vehicleFBITruck( player ) local x, y, z = getElementPosition ( source ) createVehicle ( 528, x, y, z + 5 ) end addEvent("vehFBITruck",true) addEventHandler("vehFBITruck",root,vehicleFBITruck) function vehicleFlatbed( player ) local x, y, z = getElementPosition ( source ) createVehicle ( 455, x, y, z + 5 ) end addEvent("vehFlatbed",true) addEventHandler("vehFlatbed",root,vehicleFlatbed) function vehiclePatriot( player ) local x, y, z = getElementPosition ( source ) createVehicle ( 470, x, y, z + 5 ) end addEvent("vehPatriot",true) addEventHandler("vehPatriot",root,vehiclePatriot) c_vehicle.lua --[[ This script was created by FlowZ and all credits go to FlowZ, if you need any help setting up this script head to readme.txt for more instruction. ]]-- local vehicleMarker = createMarker(-2404.1486816406, -2201.865234375, 32.2,"cylinder",1,255,255,255) function vehicleGUI() vehicleGUI = guiCreateWindow(277, 204, 269, 266, "Vehicle Shop", false) guiWindowSetSizable(vehicleGUI, false) vehicleRhino = guiCreateButton(9, 20, 250, 40, "Tiger Ausf. E", false, vehicleGUI) vehicleFBITruck = guiCreateButton(9, 69, 250, 40, "Sd.Kfz.222", false, vehicleGUI) vehicleFlatbed = guiCreateButton(9, 120, 250, 40, "Sd Kfz 251", false, vehicleGUI) vehiclePatriot = guiCreateButton(9, 170, 250, 40, "German staff car", false, vehicleGUI) vehicleClose = guiCreateButton(178, 218, 81, 27, "Close", false, vehicleGUI) if source == vehicleMarker then guiSetVisible(vehicleGUI, true) showCursor( true ) end end addEventHandler("onClientMarkerHit",getRootElement(),vehicleGUI) function vehicleClose() if source == vehicleClose then guiSetVisible(vehicleGUI,false) showCursor(false) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleClose) function vehicleRhino( player ) if source == vehicleRhino then triggerServerEvent("vehRhino", localPlayer) guiSetVisible(vehicleGUI,false) showCursor(false) outputChatBox("You have bought a Tiger Ausf. E tank.",source) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleRhino) function vehicleFBITruck( player ) if source == vehicleFBITruck then triggerServerEvent("vehFBITruck",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleFBITruck) function vehicleFlatbed( player ) if source == vehicleFlatbed then triggerServerEvent("vehFlatbed",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) outputChatBox("You have Bought a German Sd Kfz 251 vehicle.",source) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleFlatbed) function vehiclePatriot( player ) if source == vehiclePatriot then triggerServerEvent("vehPatriot",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) outputChatBox("You have bought a german staff car.",source) end end addEventHandler("onClientGUIClick",getRootElement(),vehiclePatriot) Link to comment
Xwad Posted February 12, 2015 Author Share Posted February 12, 2015 but why does it not take the money from the player when he buy it? and how can i make that when the player buy the vehicle then the vehicle spawns to another position? Link to comment
1LoL1 Posted February 12, 2015 Share Posted February 12, 2015 but why does it not take the money from the player when he buy it? and how can i make that when the player buy the vehicle then the vehicle spawns to another position? Use Link to comment
Xwad Posted February 12, 2015 Author Share Posted February 12, 2015 (edited) not working:/ But im Sure that i have do something worng in this part of the script function vehicleFBITruck( player ) if source == vehicleFBITruck then triggerServerEvent("vehFBITruck",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) if ( getPlayerMoney (source) >= 3000 ) then takePlayerMoney(source, 3000) else outputChatBox('You don't have enough money to buy this Vehicle.', source, 255, 0, 0 ) end end end end end) addEventHandler("onClientGUIClick",getRootElement(),vehicleFBITruck) Edited February 12, 2015 by Guest Link to comment
Enargy, Posted February 12, 2015 Share Posted February 12, 2015 not working:/ But im Sure that i have do something worng in this part of the script wtf? wrong code, you cannot use a mixed function. Link to comment
Enargy, Posted February 12, 2015 Share Posted February 12, 2015 ---SERVER-SIDE function vehicleFBITruck() if ( getPlayerMoney (source) >= 3000 ) then takePlayerMoney(source, 3000) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) else outputChatBox('You dont have enough money to buy this Vehicle.', source, 255, 0, 0 ) end end) addEvent("onVehicleBought", true) addEventHandler("onVehicleBought", getRootElement(), vehicleFBITruck) ---CLIENT-SIDE triggerServerEvent("onVehicleBought", localPlayer) the rest you must add it. Link to comment
Xwad Posted February 14, 2015 Author Share Posted February 14, 2015 i made the script but it does not work. The server sad : ERROR: Client (Xwad) triggered serverside event onVehicleBought, but event is not added serverside This is the 2 code: C_vehicle.lua local vehicleMarker = createMarker(-2404.1486816406, -2201.865234375, 32.2,"cylinder",1,255,255,255) function vehicleGUI() vehicleGUI = guiCreateWindow(277, 204, 269, 266, "Vehicle Shop", false) guiWindowSetSizable(vehicleGUI, false) vehicleFBITruck = guiCreateButton(9, 69, 250, 40, "Sd.Kfz.222", false, vehicleGUI) vehicleClose = guiCreateButton(178, 218, 81, 27, "Close", false, vehicleGUI) if source == vehicleMarker then guiSetVisible(vehicleGUI, true) showCursor( true ) end end addEventHandler("onClientMarkerHit",getRootElement(),vehicleGUI) function vehicleClose() if source == vehicleClose then guiSetVisible(vehicleGUI,false) showCursor(false) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleClose) function vehicleFBITruck( player ) if source == vehicleFBITruck then triggerServerEvent("onVehicleBought",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleFBITruck) s_vehicle function vehicleFBITruck() if ( getPlayerMoney (source) >= 3000 ) then takePlayerMoney(source, 3000) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) else outputChatBox('You dont have enough money to buy this Vehicle.', source, 255, 0, 0 ) end end) addEvent("onVehicleBought", true) addEventHandler("onVehicleBought", getRootElement(), vehicleFBITruck) Link to comment
Enargy, Posted February 15, 2015 Share Posted February 15, 2015 client.lua local vehicleMarker = createMarker(-2404.1486816406, -2201.865234375, 32.2,"cylinder",1,255,255,255) function vehicleGUI() vehicleGUI = guiCreateWindow(277, 204, 269, 266, "Vehicle Shop", false) guiWindowSetSizable(vehicleGUI, false) guiSetVisible(vehicleGUI,false) vehicleFBITruck = guiCreateButton(9, 69, 250, 40, "Sd.Kfz.222", false, vehicleGUI) vehicleClose = guiCreateButton(178, 218, 81, 27, "Close", false, vehicleGUI) end addEventHandler("onClientResourceStart",resourceRoot,vehicleGUI) function playerOnMarker() if isElementWithinMarker(localPlayer, vehicleMarker) then guiSetVisible(vehicleGUI, true) showCursor( true ) end end addEventHandler("onClientMarkerHit", vehicleMarker, playerOnMarker) function closeGUI() if source == vehicleClose then guiSetVisible(vehicleGUI,false) showCursor(false) end end addEventHandler("onClientGUIClick",getRootElement(),closeGUI) function vehicleBuy() if source == vehicleFBITruck then triggerServerEvent("onVehicleBought",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleBuy) Link to comment
Xwad Posted February 15, 2015 Author Share Posted February 15, 2015 Its not working:/ ERROR: Client (Xwad) triggered serverside event onVehicleBought, but event is not added serverside Link to comment
Xwad Posted February 15, 2015 Author Share Posted February 15, 2015 what is the problem? why does it not work? Link to comment
Xwad Posted February 15, 2015 Author Share Posted February 15, 2015 "Xwad" type="scrip" name="vehicle_shop" /> Link to comment
Dimmitry007 Posted February 17, 2015 Share Posted February 17, 2015 Are u sure that ur using That file is cilent side? Link to comment
Dimmitry007 Posted February 17, 2015 Share Posted February 17, 2015 What does debug script say? Link to comment
Xwad Posted February 17, 2015 Author Share Posted February 17, 2015 [2015-02-17 17:21:05] ERROR: Client (Xwad) triggered serverside event onVehicleBought, but event is not added serverside Link to comment
Enargy, Posted February 17, 2015 Share Posted February 17, 2015 (edited) there was a parenthesis more in the serverside script Edited February 17, 2015 by Guest Link to comment
Xwad Posted February 17, 2015 Author Share Posted February 17, 2015 local vehicleMarker = createMarker(-2404.1486816406, -2201.865234375, 32.2,"cylinder",1,255,255,255) function vehicleGUI() vehicleGUI = guiCreateWindow(277, 204, 269, 266, "Vehicle Shop", false) guiWindowSetSizable(vehicleGUI, false) guiSetVisible(vehicleGUI,false) vehicleFBITruck = guiCreateButton(9, 69, 250, 40, "Sd.Kfz.222", false, vehicleGUI) vehicleClose = guiCreateButton(178, 218, 81, 27, "Close", false, vehicleGUI) end addEventHandler("onClientResourceStart",resourceRoot,vehicleGUI) function playerOnMarker() if isElementWithinMarker(localPlayer, vehicleMarker) then guiSetVisible(vehicleGUI, true) showCursor( true ) end end addEventHandler("onClientMarkerHit", vehicleMarker, playerOnMarker) function closeGUI() if source == vehicleClose then guiSetVisible(vehicleGUI,false) showCursor(false) end end addEventHandler("onClientGUIClick",getRootElement(),closeGUI) function vehicleBuy() if source == vehicleFBITruck then triggerServerEvent("onVehicleBought",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleBuy) Link to comment
Enargy, Posted February 17, 2015 Share Posted February 17, 2015 clientside works perfectly server-side function vehicleFBITruck() if ( getPlayerMoney (source) >= 3000 ) then takePlayerMoney(source, 3000) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) else outputChatBox('You dont have enough money to buy this Vehicle.', source, 255, 0, 0 ) end end addEvent("onVehicleBought", true) addEventHandler("onVehicleBought", getRootElement(), vehicleFBITruck) Link to comment
Xwad Posted February 17, 2015 Author Share Posted February 17, 2015 Thanks now its working but i dont get the vehicle:( Link to comment
JR10 Posted February 17, 2015 Share Posted February 17, 2015 Maybe just maybe because your code only takes the money away? Is this the full code? 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