[Help] /pv (personal vehicle) execute auto with a Menu (Mysql..)

I create a personal menu and i want help… When the player click on “Spawn personal vehicle” the command is automaticly executed and the vehicule spawn…

This code doesnt work:

véhicle.lua (client)

local spawn

RegisterNUICallback("vehicles", function(data, cb)

	local action = data.action
	
	if action == "spawn" then
	TriggerServerEvent("menupersonal:vehicleSpawn")
	   drawNotification("~g~Votre véhicule a spawn")
	end

	cb("ok")
end)

And Server.lua

require "resources/essentialmode/lib/MySQL"
MySQL:open("127.0.0.1", "gta5_gamemode_essential", "root", "1234")

RegisterServerEvent('menupersonal:vehicleSpawn')
AddEventHandler('menupersonal:vehicleSpawn', function()
print("Player ID " ..source)

  local player = user.identifier
local executed_query = MySQL:executeQuery("SELECT * FROM users WHERE identifier = '@username'",{['@username'] = player})
  local car = MySQL:getResults(executed_query, {'personalvehicle'})
  local playerPed = GetPlayerPed(-1)
  local playerCoords = GetEntityCoords(playerPed)

  pv.veh = CreateVehicle(car, playerCoords, 0.0, true, false)
SetVehRadioStation(pv.veh, "OFF")
SetPedIntoVehicle(playerPed, pv.veh, -1)
SetVehicleEngineOn(pv.veh, true, false, false)
end)

BUT MY FU***** DOESNT WORK… :rage:

Why nobody help me :’(

Re-up pls help dude :’(

it is urgent…

This might help you? [Release] GUI Script - v0.8

One thing I would suggest as well is…however annoying it might be that people don’t reply just be patient.

Someone will eventually reply, by ‘upping’ your post you can negatively impact the replies.

Search google for LUA tutorials, start out with the basics and also look at scripts that are already released on the forums and try and understand how they work.

2 Likes

How this addon help me for execute a command when a player select “spawn vehicle personal” ?

but thx for ur help ^^

If you read the description of the script it explains how to run functions

that ?

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsControlJustPressed(1,Keys["H"]) then
		
			NameOfMenu()                     -- Menu to draw
			Menu.hidden = not Menu.hidden    -- Hide/Show the menu

		end
		Menu.renderGUI()     -- Draw menu on each tick if Menu.hidden = false
	end
end)

That is used to trigger your Menu, so you would press H key to active it.

To add a Menu add this function to your client side script :

function NameOfMenu()
	MenuTitle = "Title of the menu"
	ClearMenu()
	Menu.addButton("First Button","FunctionName1","arg")	
	Menu.addButton("Second Button","FunctionName2",nil) -- No arg
	-- ...
end

This is the code you need to look at, I’m limited with the assistance I can give you at the moment as I’m at work.

The menu is fonctional but its the command when i click on the menu for spawn the vehicle the vehicle doesnt spawn… I search the command for execute the command when a player click on the menu… :stuck_out_tongue:

Are you trying to spawn a vehicle when the menu is clicked? or are you trying to just send a message telling them what command to write?

I help u…

It is my menu “trainer.html”

            <div id="vehiclesmenu" data-parent="mainmenu">
                <p class="traineroption" data-action="vehicles spawn">Spawn my personal vehicle[WIP]</p>
            </div>

and my script lua is “vehicle.lua”

local spawn

RegisterNUICallback("vehicles", function(data, cb)

	local action = data.action
	
	if action == "spawn" then
	TriggerClientEvent("chatMessage", -1, "", {255, 255, 255}, "/pv")
	   drawNotification("~g~Your vehicle has spawned")
	end
	
	cb("ok")
end)

Right okay, all that will happen there is you’ll receive a chat message with the following…/pv

But the button doesnt work :confused: he doesnt execute the command “/pv”

Si tu veux tu peux m’ajouter sur Skype je peux t’aider : wheezx

I make a update in my message :wink:

it’s possible to add permission level to use the menu ?

idk but i think yes for what ??

i want use a menu for only admin or specific job

ah ok but its not the good poste dude… I just need a help for fix my menu