Storm-Hanma Posted December 29, 2017 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 Visit https://storm-hosting.xyz/ for free game servers !
DiGiTal Posted December 29, 2017 Posted December 29, 2017 Use the create vehicule on server side and call it DRW and Storm-Hanma 2 Our Website : https://tutoplayfun.ml/ Our Discord: https://discord.gg/BxkW65z
Storm-Hanma Posted December 29, 2017 Author Posted December 29, 2017 Veh spawn works fine but problem is in entering vehicle player can't enter vehicle I tested both side Visit https://storm-hosting.xyz/ for free game servers !
DRW Posted December 29, 2017 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. DiGiTal and Storm-Hanma 2 Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Storm-Hanma Posted December 30, 2017 Author 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 Visit https://storm-hosting.xyz/ for free game servers !
Storm-Hanma Posted December 30, 2017 Author Posted December 30, 2017 Now I can't spawn vehicle by adding triggerservervent what to do now @MadnessReloaded Visit https://storm-hosting.xyz/ for free game servers !
DRW Posted December 30, 2017 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. Storm-Hanma and DiGiTal 2 Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Storm-Hanma Posted December 30, 2017 Author 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 ) Visit https://storm-hosting.xyz/ for free game servers !
DRW Posted December 30, 2017 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) Storm-Hanma and DiGiTal 1 1 Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Storm-Hanma Posted December 30, 2017 Author Posted December 30, 2017 let me test and i thing it will work thanks DiGiTal 1 Visit https://storm-hosting.xyz/ for free game servers !
Recommended Posts