Hi, I have been introducing to programming in Lua through MTA and I had some doubts to see if you can clarify, I hope this subforum is correct, it is a panel for spawning cars, and achieved basic functionality through the wiki, but I have a problem in which I hope you can help me
Client:
function generar_auto(boton,estado)
local fila,columna = guiGridListGetSelectedItem(grid_autos)
if fila and columna and fila ~= -1 and columna ~= -1 then
local selected = guiGridListGetItemData(grid_autos,fila,columna)
selected = tonumber(selected)
local rotz = getElementRotation(getLocalPlayer())
local x,y,z = getElementPosition(getLocalPlayer())
x = x + ( math.cos ( math.rad ( rotz+90 ) ) * 3)
y = y + ( math.sin ( math.rad ( rotz+90 ) ) * 3)
if selected and x and y and z then
triggerServerEvent("onClientGenerarAuto",getRootElement(),selected,x,y,z)
else
outputChatBox("No spawneo")
end
else
outputChatBox("Error")
end
end
Server:
function generar_auto(vehiculo,posx,posy,posz,player)
-- check all the arguments exist
if vehiculo and posx and posy and posz then
createVehicle(vehiculo,posx,posy,posz)
outputChatBox("Auto creado",source)
end
end
This part of the code is what allows me to create the car and as I said everything is fine, it does, but I would like to put the user inside it directly, when using the warPedIntoVehicle on the server but it doesn't find the argument and it doesn't put it
The other is how I can limit the spawn of the cars to only 1, since if I keep clicking the button it follows me and keeps creating cars.
PS: I am using the wiki, exactly this link, it is the same code but with slight changes in variables: https://wiki.multitheftauto.com/wiki/Scripting_the_GUI_-_Tutorial_1
THANK YOU, I really sorry for mi english, I used google translate