Raxzen Posted May 16, 2020 Share Posted May 16, 2020 (edited) 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 Edited May 16, 2020 by Raxzen Link to comment
#\_oskar_/# Posted May 16, 2020 Share Posted May 16, 2020 3 hours ago, Raxzen said: 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. use ... isElement + destroyElement Link to comment
Sisqo0 Posted May 16, 2020 Share Posted May 16, 2020 --Edit those --Client 15 hours ago, Raxzen said: triggerServerEvent("onClientGenerarAuto",getRootElement(),selected,x,y,z, getLocalPlayer () ) --Server 15 hours ago, Raxzen said: if vehiculo and posx and posy and posz then local veh = createVehicle(vehiculo,posx,posy,posz) warpPedIntoVehicle(player, veh) outputChatBox("Auto creado",source) end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now