Pedro001 Posted June 24, 2020 Share Posted June 24, 2020 How can I change the position of the spawn in this function ? I suppose it is where it says " vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) " But I see it gets the position stored in a local variable that gets the position of an element. But I don't understand which element is this. Can someone help me? function(Model, cost, r1, g1, b1, r2, g2, b2) abc = false local data = dbPoll(dbQuery(db, "SELECT * FROM VehicleList WHERE Account = ?", getAccountName(getPlayerAccount(source))), -1) for i, data in ipairs (data) do if data["Model"] == Model then abc = true break end end if #data >= 3 then exports.Scripts_Dxmessages:outputDx ( source, "Desculpe, mas você só pode comprar 3 veículos.","error" ) return end if abc then exports.Scripts_Dxmessages:outputDx ( source, "você já tem este veículo", "error" ) return end if getPlayerMoney(source) >= tonumber(cost) then takePlayerMoney ( source, cost ) local x, y, z = getElementPosition(source) local _, _, rz = getElementRotation(source) local shopID = getElementData ( source, "atVehShop") local color = r1..","..g1..","..b1..","..r2..","..g2..","..b2 if shopID and shopsVehSpawns[shopID] then vehicle = createVehicle(Model, shopsVehSpawns[shopID][1], shopsVehSpawns[shopID][2], shopsVehSpawns[shopID][3], shopsVehSpawns[shopID][4], shopsVehSpawns[shopID][5], shopsVehSpawns[shopID][6]) else vehicle = createVehicle(Model, x-5, y+5, z, 0, 0, rz) end setVehicleColor(vehicle, r1, g1, b1, r2, g2, b2) setElementData(vehicle, "Owner", source) local NewID = getFreeID() setElementData(vehicle, "ID", NewID) dbExec(db, "INSERT INTO VehicleList VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", NewID, getAccountName(getPlayerAccount(source)), Model, x-5, y+5, z, rz, color, "", 3, cost, 1000, 0) exports.Scripts_Dxmessages:outputDx ( source, "Comprou este carro por: R$"..cost, "success" ) updateVehicleInfo(source) setElementData(vehicle, "ownercar", getAccountName(getPlayerAccount(source))) warpPedIntoVehicle ( source, vehicle ) vv[vehicle] = setTimer(function(source) if not isElement(source) then killTimer(vv[source]) vv[source] = nil end if isElement(source) and getElementHealth(source) <= 255 then setElementHealth(source, 255.5) setVehicleDamageProof(source, true) setVehicleEngineState(source, false) end end, 150, 0, vehicle) addEventHandler("onVehicleDamage", vehicle, function(loss) local account = getAccountName(getPlayerAccount(getElementData(source, "Owner"))) setTimer(function(source) if isElement(source) then dbExec(db, "UPDATE VehicleList SET HP = ? WHERE Account = ? AND Model = ?", getElementHealth(source), account, getElementModel(source)) updateVehicleInfo(getElementData(source, "Owner")) end end, 100, 1, source) end) addEventHandler("onVehicleEnter", vehicle, function(player) if getElementHealth(source) <= 255.5 then setVehicleEngineState(source, false) else if isVehicleDamageProof(source) then setVehicleDamageProof(source, false) end end end) else exports.Scripts_Dxmessages:outputDx ( source, "Você não tem grana para comprar este veiculo.", "error" ) end end) Link to comment
N3xT Posted June 24, 2020 Share Posted June 24, 2020 Just edit these values (x, y, z)? Click here for more info Link to comment
Pedro001 Posted June 25, 2020 Author Share Posted June 25, 2020 6 hours ago, N3xT said: Just edit these values (x, y, z)? Click here for more info I tried doing so but, no matter what I do the vehicle keeps spawning at the same place. Link to comment
Master_MTA Posted June 25, 2020 Share Posted June 25, 2020 11 hours ago, Pedro001 said: local x, y, z = getElementPosition(source) gonna be like that local x,y,z = 100 ,200 ,330 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