Hello,
I'm here today to ask if anybody can say whether I am on the right track or not. The only experience I have in LUA is 2 years of Roblox LUA (yes you can laugh, but for being 12 years old at the time I thought I did a pretty good job). So, this is my first script in a while, what I'm trying to do is that when a player spawns or enters a new vehicle, it gets the old vehicle's ID (assuming the player had a previous vehicle) and deletes the old vehicle, then it will spawn (or the player enters) a vehicle and assign a new ID to it, with the ID being "(playername)1". I'm not asking for somebody to do all the work and fix this for me, I'm just asking for feedback.
--Assigns ID on vehicle spawn and deletes old vehicle
function createVehicleForPlayer(thePlayer, command, vehicleModel)
local x, y, z = getElementPosition(thePlayer) --gets position of players x,y,z
x = x + 3
local createdVehicle = createVehicle(tonumber(vehicleModel),x, y, z)
i=1
getElementByID ( player[i] )
destroyElement
getPedOccupiedVehicle ( player )
setElementID ( player[i] )else
if (createdVehicle == false) then
outputChatBox("Failed to create vehicle.", thePlayer)
end
addCommandHandler("createvehicle", createVehicleForPlayer)
--Assigns ID on vehicle enter and deletes old vehicle
function PlayerEntersVehicle
getElementByID ( player[i] )
destroyElement
setElementID ( player[i] )
addEventHandler("onVehicleEnter", PlayerEntersVehicle)
Here's some output from the MTA Script Editor
'=' expected near 'getPedOccupiedVehicle' - Line 9
'<eof>' expected near 'else' - Line 10
'(' expected near 'getElementByID' - Line 17
'=' expected near 'setElementID' - Line 19