Storm-Hanma Posted December 29, 2017 Share Posted December 29, 2017 Hi want to make a system for vehicles like hydra rhino were players can buy it from money by using it only for 2-5min ! I tested many trays the things is server is spawning vehicle but can't enter the vehicle ,take money also working fine but I can't enter the vehicle First try it works for take money and spawning vehicle but cant enter vehicle ! function buy() --<spawn a vehicle >-- local luckyBugger = getLocalPlayer() -- get the local player local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position if lol()then lel() veh=createVehicle ( 520, x, y, z + 10 ) outputChatBox ( "You got Hydra", 255, 0, 0) end end addEventHandler("onClientGUIClick",GUIEditor.button[1],buy) local money = getPlayerMoney(luckyBugger) local count = 2000000 function lol() if (money >= count ) then takePlayerMoney(luckyBugger,count) else outputChatBox("You don't have Money") end end function lel() destroyElement(veh) end setTimer(lel,120000,1) Second i tried with only spawn same hydra spawnbut cant enter addEventHandler("onClientGUIClick",GUIEditor.button[1], function () --<spawn a vehicle >-- local luckyBugger = getLocalPlayer() -- get the local player local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position createVehicle ( 520, x, y, z + 10 ) outputChatBox ( "You got Hydra", 255, 0, 0) end) I used it in both client and server side same error on both sides Link to comment
DiGiTal Posted December 29, 2017 Share Posted December 29, 2017 Use the create vehicule on server side and call it 2 Link to comment
Storm-Hanma Posted December 29, 2017 Author Share Posted December 29, 2017 Veh spawn works fine but problem is in entering vehicle player can't enter vehicle I tested both side Link to comment
DRW Posted December 29, 2017 Share Posted December 29, 2017 2 minutes ago, Khadeer143 said: Veh spawn works fine but problem is in entering vehicle player can't enter vehicle I tested both side As Digital said above, you can't enter vehicles if they've been created client-side. You should create them server-sided and try that way. If you can't enter anyway, you should look for any other script that's cancelling onVehicleStartEnter or something, there is no other way around. 2 Link to comment
Storm-Hanma Posted December 30, 2017 Author Share Posted December 30, 2017 (edited) well thankyou its done as u guys said i did and i got idea on how to work next time also! Edited December 30, 2017 by Khadeer143 Link to comment
Storm-Hanma Posted December 30, 2017 Author Share Posted December 30, 2017 Now I can't spawn vehicle by adding triggerservervent what to do now @MadnessReloaded Link to comment
DRW Posted December 30, 2017 Share Posted December 30, 2017 2 minutes ago, Khadeer143 said: Now I can't spawn vehicle by adding triggerservervent what to do now @MadnessReloaded Inside the onClientGUIClick event, there should be something like: function spawnVehicleServerside () triggerServerEvent ("spawnServerVehicle",localPlayer) end The source is the player. addEvent ("spawnServerVehicle",true) addEventHandler ("spawnServerVehicle",root,function() local x,y,z = getElementPosition (source) --The source is the player that triggered the event local vehicle = createVehicle (520,x+3,y+3,z+1) -- I'll just spawn a hydra or whatever end) Probably you did not add the event, or did not set the "true" value after adding the event, I used to do these kinds of mistakes. 2 Link to comment
Storm-Hanma Posted December 30, 2017 Author Share Posted December 30, 2017 its worked bro how can i make a timer so that player can use it for only 5 min? addEvent ("HYDRA - 2000000$/min",true) addEventHandler ("HYDRA - 2000000$/min",root, function ( ) if getPlayerMoney ( source ) > 199 then takePlayerMoney (source,200) setElementHealth (source,200) local x,y,z = getElementPosition (source) --The source is the player that triggered the event local vehicle = createVehicle (520,x+3,y+3,z+1) -- I'll just spawn a hydra or whatever else outputChatBox ("[Server]: Thank you ^." ,source,0,255,0,true) end end ) Link to comment
DRW Posted December 30, 2017 Share Posted December 30, 2017 2 minutes ago, Khadeer143 said: its worked bro how can i make a timer so that player can use it for only 5 min? addEvent ("HYDRA - 2000000$/min",true) addEventHandler ("HYDRA - 2000000$/min",root, function ( ) if getPlayerMoney ( source ) > 199 then takePlayerMoney (source,200) setElementHealth (source,200) local x,y,z = getElementPosition (source) --The source is the player that triggered the event local vehicle = createVehicle (520,x+3,y+3,z+1) -- I'll just spawn a hydra or whatever else outputChatBox ("[Server]: Thank you ^." ,source,0,255,0,true) end end ) When the vehicle gets created, just do this. local minutes = 5 local milisec = minutes * 60000 --Just passing minutes to miliseconds. setTimer (function() destroyElement (vehicle) end,milisec,1) 1 1 Link to comment
Storm-Hanma Posted December 30, 2017 Author Share Posted December 30, 2017 let me test and i thing it will work thanks 1 Link to comment
Recommended Posts