Jump to content

[Help]vehicle enter !


Storm-Hanma

Recommended Posts

Posted

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 !
 

Posted
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.

tJ5zeFm.gif

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

Posted
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.

tJ5zeFm.gif

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

Posted

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 !
 

Posted
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)

 

tJ5zeFm.gif

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...