gtrg Posted January 31, 2012 Share Posted January 31, 2012 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 Link to comment
JR10 Posted January 31, 2012 Share Posted January 31, 2012 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( player) 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) Link to comment
gtrg Posted January 31, 2012 Author Share Posted January 31, 2012 thank u very much and got no errors now but everyone can still enter the car thats reserved Link to comment
JR10 Posted January 31, 2012 Share Posted January 31, 2012 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( player) local accountName = getAccountName(account) if owner[i] ~= accountName and seat == 0 then outputChatBox ( "You cannot drive this vehicle as it belongs to: "..tostring(owner[i]), player, 200, 0, 0 ) cancelEvent() end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), loadup ) addEventHandler ( "onVehicleStartEnter", getRootElement(), checkowner) Link to comment
gtrg Posted January 31, 2012 Author Share Posted January 31, 2012 THANK U your version did only need one thing more i forgot it wile i was re-making it after a big faillure in the loadup there just needed to be a variable that pinpointed at owner done that now it works comepletely fine thanks for u help Link to comment
BorderLine Posted February 1, 2012 Share Posted February 1, 2012 hey JR10 and how i can change for be uused only by admins? somethingl like this? function checkowner (player,seat,jacked) local account = getPlayerAccount( player) if isObjectInACLGroup( 'user.'..getAccountName( player ), aclGetGroup( 'Admin' )) and seat == 0 then outputChatBox ( "You cannot drive this vehicle as it belongs to Admins ", player, 200, 0, 0 ) cancelEvent() end end Link to comment
Castillo Posted February 1, 2012 Share Posted February 1, 2012 function checkowner (player,seat,jacked) local account = getPlayerAccount( player) if (seat == 0 and not isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ))) then outputChatBox ( "You cannot drive this vehicle as it belongs to Admins ", player, 200, 0, 0 ) cancelEvent() end end Link to comment
JR10 Posted February 1, 2012 Share Posted February 1, 2012 function checkowner (player,seat,jacked) local account = getPlayerAccount( player) if (seat == 0 and not isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ))) then outputChatBox ( "You cannot drive this vehicle as it belongs to Admins ", player, 200, 0, 0 ) cancelEvent() end end 'player' in getAccountName instead of 'account'. Link to comment
BorderLine Posted February 2, 2012 Share Posted February 2, 2012 I tested this, but i have a problem nobody in the server can enter to cars i maked 1 car in the vehicles.xml and when i start the resource nobody can join to cars. Link to comment
JR10 Posted February 2, 2012 Share Posted February 2, 2012 Full script and vehicle.xml please. Link to comment
BorderLine Posted February 2, 2012 Share Posted February 2, 2012 model = {} x = {} y = {} z = {} rx = {} ry = {} rz = {} numberplate = {} paintjob = {} 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"] paintjob[i] = temp["paintjob"] model[i] = temp["model"] vehicle = createVehicle ( model[i], x[i], y[i], z[i], rx[i], ry[i], rz[i], numberplate[i]) setVehicleHeadLightColor (vehicle, 0, 0, 255) setVehicleColor ( vehicle, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) end xmlUnloadFile ( vehicles ) end function checkowner (player,seat,jacked) local account = getPlayerAccount( player) if (seat == 0 and not isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ))) then outputChatBox ( "Car designed for admins", player, 200, 0, 0 ) cancelEvent() end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), loadup ) addEventHandler ( "onVehicleStartEnter", getRootElement(), checkowner) just i remove some lines vehicle.xml "3" model="497" plate="Yakuza" interior="0" dimension="0" posX="830.70001220703" posY="-2598.3000488281" posZ="15.5" rotX="0" rotY="0" rotZ="0"> Link to comment
JR10 Posted February 2, 2012 Share Posted February 2, 2012 No one can enter because it's for admins only. Link to comment
BorderLine Posted February 2, 2012 Share Posted February 2, 2012 Look, leetme explain better i have a zombie server. this gamemode have a map file with cars arround all San andreas. I have a base for Admins and i want make this private cars only for us. But when i active this resource. Nobody can enter to all cars in san andreas not only to car created in this scripts, and that map file and this scripts are in diferents resources i mean the map file with cars arround san andreas are in resource biohazard and this scripts its called privatecars i dont know if i explain. Link to comment
JR10 Posted February 2, 2012 Share Posted February 2, 2012 model = {} x = {} y = {} z = {} rx = {} ry = {} rz = {} numberplate = {} paintjob = {} 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"] paintjob[i] = temp["paintjob"] model[i] = temp["model"] vehicle = createVehicle ( model[i], x[i], y[i], z[i], rx[i], ry[i], rz[i], numberplate[i]) setVehicleHeadLightColor (vehicle, 0, 0, 255) setVehicleColor ( vehicle, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ) end xmlUnloadFile ( vehicles ) end function checkowner (player,seat,jacked) local account = getPlayerAccount( player) if (seat == 0 and not isObjectInACLGroup( 'user.'..getAccountName( account ), aclGetGroup( 'Admin' ))) then outputChatBox ( "Car designed for admins", player, 200, 0, 0 ) cancelEvent() end end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), loadup ) addEventHandler ( "onVehicleStartEnter", resourceRoot, checkowner) Not sure if this is what you mean. Link to comment
BorderLine Posted February 2, 2012 Share Posted February 2, 2012 Perfect..! Working.. thx man, thanks a loot 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