Xwad Posted March 13, 2015 Share Posted March 13, 2015 Hi i want to make a vehicle shop. Its working the only problem is that when i buy a car then he alwys give 5 fbi car:/ client side script 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, 19, 250, 40, "Sd.Kfz.222", false, vehicleGUI) vehiclePatriot = guiCreateButton(9, 69, 250, 40, "VW type 82", false, vehicleGUI) vehicleFlatbed = guiCreateButton(9, 119, 250, 40, "Sd.Kfz.251", false, vehicleGUI) vehicleRihno = guiCreateButton(9, 168, 250, 40, "Tiger Ausf. E", 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) function vehicleBuy() if source == vehicleFlatbed then triggerServerEvent("onVehicleBought",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleBuy) function vehicleBuy3() if source == vehiclePatriot then triggerServerEvent("onVehicleBought",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleBuy3) function vehicleRhino() if source == vehicleRhino then triggerServerEvent("onVehicleBought",localPlayer) guiSetVisible(vehicleGUI,false) showCursor( false ) end end addEventHandler("onClientGUIClick",getRootElement(),vehicleRhino) server side script function vehicleFBITruck() if ( getPlayerMoney (source) >= 800 ) then takePlayerMoney(source, 800) outputChatBox("You have bought Sd.Kfz.222 vehicle.",source) local x,y,z = getElementPosition(source) local veh = createVehicle(528,x,y,z+5) warpPedIntoVehicle(source, veh) else outputChatBox('You dont have enough money to buy this Vehicle. 800$ ', source, 255, 0, 0 ) end end addEvent("onVehicleBought", true) addEventHandler("onVehicleBought", getRootElement(), vehicleFBITruck) function vehicleFlatbed() if ( getPlayerMoney (source) >= 1000 ) then takePlayerMoney(source, 1000) outputChatBox("You have bought Sd.Kfz.251 vehicle.",source) local x,y,z = getElementPosition(source) local veh = createVehicle(455,x,y,z+5) warpPedIntoVehicle(source, veh) else outputChatBox('You dont have enough money to buy this Vehicle. 1000$', source, 255, 0, 0 ) end end addEvent("onVehicleBought", true) addEventHandler("onVehicleBought", getRootElement(), vehicleFBITruck) function vehiclePatriot() if ( getPlayerMoney (source) >= 500 ) then takePlayerMoney(source, 500) outputChatBox("You have bought VW type 82 vehicle.",source) local x,y,z = getElementPosition(source) local veh = createVehicle(470,x,y,z+5) warpPedIntoVehicle(source, veh) else outputChatBox('You dont have enough money to buy this Vehicle. 500$', source, 255, 0, 0 ) end end addEvent("onVehicleBought", true) addEventHandler("onVehicleBought", getRootElement(), vehicleFBITruck) function vehicleRhino() if ( getPlayerMoney (source) >= 5000 ) then takePlayerMoney(source, 5000) outputChatBox("You have bought Tiger Ausf. E vehicle.",source) local x,y,z = getElementPosition(source) local veh = createVehicle(432,x,y,z+5) warpPedIntoVehicle(source, veh) else outputChatBox('You dont have enough money to buy this Vehicle. 5000$', source, 255, 0, 0 ) end end addEvent("onVehicleBought", true) addEventHandler("onVehicleBought", getRootElement(), vehicleFBITruck) Link to comment
Xwad Posted March 13, 2015 Author Share Posted March 13, 2015 i found the problem!!!!! Link to comment
Xwad Posted September 26, 2015 Author Share Posted September 26, 2015 Its not warpibng me in the vehicle only creating it pls help. it says its a badargumentum function BuyWeaponOnServer(weapon_name, thePlayer) player_money = getPlayerMoney(source) player_account = getPlayerAccount(source) local price_car = "1200" local price_truck = "2200" local price_halftrack = "3500" local price_tiger = "8000" if(weapon_name == "car") then if(player_money >= tonumber(price_car )) then takePlayerMoney(source, tonumber(price_car )) car = createVehicle ( 470, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( car ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "truck") then if(player_money >= tonumber(price_truck)) then takePlayerMoney(source, tonumber(price_truck)) truck = createVehicle ( 433, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( truck ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "halftrack") then if(player_money >= tonumber(price_halftrack)) then takePlayerMoney(source, tonumber(price_halftrack)) halftrack = createVehicle ( 552, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( halftrack ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "tiger") then if(player_money >= tonumber(price_tiger)) then takePlayerMoney(source, tonumber(price_tiger)) tiger = createVehicle ( 432, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( tiger ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end end end addEvent("buy_vehicle", true) addEventHandler("buy_vehicle", getRootElement(), BuyWeaponOnServer) Link to comment
xeon17 Posted September 26, 2015 Share Posted September 26, 2015 warpPedIntoVehicle have two arguments, the first one is missing in your code. The first argument is the player which you wish to warp inside the vehicle. In your case, the player argument is source. Link to comment
Xwad Posted September 26, 2015 Author Share Posted September 26, 2015 I edited it but its still not working:/ function BuyWeaponOnServer(weapon_name, thePlayer, theVehicle) player_money = getPlayerMoney(source) player_account = getPlayerAccount(source) local price_car = "1200" local price_truck = "2200" local price_halftrack = "3500" local price_tiger = "8000" if(weapon_name == "car") then local x,y,z = getElementPosition( thePlayer ) if(player_money >= tonumber(price_car )) then takePlayerMoney(source, tonumber(price_car )) car = createVehicle ( 470, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( thePlayer, car ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "truck") then local x,y,z = getElementPosition( thePlayer ) if(player_money >= tonumber(price_truck)) then takePlayerMoney(source, tonumber(price_truck)) truck = createVehicle ( 433, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( thePlayer, truck ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "halftrack") then local x,y,z = getElementPosition( thePlayer ) if(player_money >= tonumber(price_halftrack)) then takePlayerMoney(source, tonumber(price_halftrack)) halftrack = createVehicle ( 552, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( thePlayer, halftrack ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "tiger") then local x,y,z = getElementPosition( thePlayer ) if(player_money >= tonumber(price_tiger)) then takePlayerMoney(source, tonumber(price_tiger)) tiger = createVehicle ( 432, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( thePlayer, tiger ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end end end addEvent("buy_vehicle", true) addEventHandler("buy_vehicle", getRootElement(), BuyWeaponOnServer) Link to comment
xeon17 Posted September 26, 2015 Share Posted September 26, 2015 function BuyWeaponOnServer(weapon_name, thePlayer, theVehicle) player_money = getPlayerMoney(source) player_account = getPlayerAccount(source) local price_car = "1200" local price_truck = "2200" local price_halftrack = "3500" local price_tiger = "8000" if(weapon_name == "car") then local x,y,z = getElementPosition(source) if(player_money >= tonumber(price_car )) then takePlayerMoney(source, tonumber(price_car )) car = createVehicle ( 470, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( source, car ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "truck") then local x,y,z = getElementPosition( source ) if(player_money >= tonumber(price_truck)) then takePlayerMoney(source, tonumber(price_truck)) truck = createVehicle ( 433, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( source, truck ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "halftrack") then local x,y,z = getElementPosition( source ) if(player_money >= tonumber(price_halftrack)) then takePlayerMoney(source, tonumber(price_halftrack)) halftrack = createVehicle ( 552, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( source, halftrack ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end elseif(weapon_name == "tiger") then local x,y,z = getElementPosition( source ) if(player_money >= tonumber(price_tiger)) then takePlayerMoney(source, tonumber(price_tiger)) tiger = createVehicle ( 432, -1068.9, -1205.79, 130 ) warpPedIntoVehicle ( source, tiger ) else outputChatBox("You do not have enough money!", source, 255, 0, 0) end end end addEvent("buy_vehicle", true) addEventHandler("buy_vehicle", getRootElement(), BuyWeaponOnServer) Link to comment
Xwad Posted September 28, 2015 Author Share Posted September 28, 2015 I tested the script and it is working! Thanks XeoN-! Link to comment
Fist Posted September 28, 2015 Share Posted September 28, 2015 i dont understand why you make seprate function that spawns vehicle for car that was bought? It can easily be made all in 1 function and reduce lines of script. 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