hey ive tried to make a carlocking recource that:
-locks on player accounts
-adds color and upgrades
-easy to add vehicles
i've made it quite far i think myself cause im only 14 yet
so here's my code
model = {}
x = {}
y = {}
z = {}
rx = {}
ry = {}
rz = {}
numberplate = {}
upgrades = {}
color = {}
paintjob = {}
owner = {}
temp = {}
vehicle = {}
function loadup(startedRecource)
vehicles = xmlLoadFile ( "vehicles.xml" )
count = xmlNodeGetChildren(vehicles)
for i=1,#count do
local vehicle = xmlFindChild ( vehicles, "vehicle", i-1 )
local attributes = xmlNodeGetAttributes ( vehicle )
for name,value in pairs ( attributes ) do
temp["" .. name .. ""] = value
end
x[i] = temp["posX"]
y[i] = temp["posY"]
z[i] = temp["posZ"]
rx[i] = temp["rotX"]
ry[i] = temp["rotY"]
rz[i] = temp["rotZ"]
numberplate[i] = temp["plate"]
upgrades[i] = temp["upgrades"]
color[i] = temp["color"]
paintjob[i] = temp["paintjob"]
owner[i] = temp["id"]
model[i] = temp["model"]
vehicle = createVehicle ( model[i], x[i], y[i], z[i], rx[i], ry[i], rz[i], numberplate[i])
addVehicleUpgrade ( vehicle, 1010 )
setVehicleColor ( vehicle, 0, 0, 0, 0)
end
xmlUnloadFile ( vehicles )
end
function checkowner (player,seat,jacked)
local account = getPlayerAccount( sourcePlayer)
local accountName = getAccountName(account)
if owner[i] == accountName and seat == 0 then
outputChatBox ( "You cannot drive this vehicle as it belongs to: "..tostring(owner), player, 200, 0, 0 )
cancelEvent()
end
end
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), loadup )
addEventHandler ( "onVehicleStartEnter", getRootElement(), checkowner)
and this is in the vehicles.xml
"admingtrg" paintjob="3" model="411" plate="admingtrg" interior="0" dimension="0" color="0,0,0,0" posX="1075.5999755859" posY="1230.1999511719" posZ="10.60000038147" rotX="0" rotY="0" rotZ="0" upgrades="1010">
and this are my errors when someone is trying to enter the car, they succeed always
[2012-01-31 10:19:42] WARNING: [gameplay]\carlocking\server.lua:52: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil]
[2012-01-31 10:19:42] WARNING: [gameplay]\carlocking\server.lua:53: Bad argument @ 'getAccountName' [Expected account at argument 1, got boolean]
if someone would help me that would be great because this recource would be really helpful for alot of people
greetz
Gtrg