berry172 Posted August 27, 2012 Share Posted August 27, 2012 function createCivilianPermVehicle(thePlayer, commandName, ...) if (exports.global:isPlayerSuperAdmin(thePlayer)) then local args = {...} if (#args < 10) then outputChatBox("HASZNÁLD: /" .. commandName .. " [id/név] [szin1 (-1 = random)] [szin2 (-1 = random)] [Munka ID -1 = nem munka jármû]", thePlayer, 255, 194, 14) outputChatBox("MUNKA ID 1 = Csomagszállító", thePlayer, 255, 194, 14) outputChatBox("MUNKA ID 2 = Taxi sofőr", thePlayer, 255, 194, 14) outputChatBox("MUNKA ID 3 = Busz sofőr", thePlayer, 255, 194, 14) outputChatBox("MUNKA ID 8 = Farmer", thePlayer, 255, 194, 14) else local vehicleID = tonumber(args[1]) local col1, col2, job if not vehicleID then -- vehicle is specified as name local vehicleEnd = 1 repeat vehicleID = getVehicleModelFromName(table.concat(args, " ", 1, vehicleEnd)) vehicleEnd = vehicleEnd + 1 until vehicleID or vehicleEnd == #args if vehicleEnd == #args then outputChatBox("Érvénytelen jármû név.", thePlayer, 255, 0, 0) return else col1 = tonumber(args[vehicleEnd]) col2 = tonumber(args[vehicleEnd + 1]) job = tonumber(args[vehicleEnd + 2]) end else col1 = tonumber(args[2]) col2 = tonumber(args[3]) job = tonumber(args[4]) end local id = vehicleID local r = getPedRotation(thePlayer) local x, y, z = getElementPosition(thePlayer) x = x + ( ( math.cos ( math.rad ( r ) ) ) * 5 ) y = y + ( ( math.sin ( math.rad ( r ) ) ) * 5 ) local letter1 = string.char(math.random(65,90)) local letter2 = string.char(math.random(65,90)) local plate = letter1 .. letter2 .. math.random(0, 9) .. " " .. math.random(1000, 9999) local veh = createVehicle(id, x, y, z, 0, 0, r, plate) if not (veh) then outputChatBox("Érvénytelen jármû ID.", thePlayer, 255, 0, 0) else exports['anticheat-system']:changeProtectedElementDataEx(veh, "fuel", 100) exports['anticheat-system']:changeProtectedElementDataEx(veh, "handbrake", 0, false) exports['vehicle-mods-handling']:LoadHandling(veh) if (job>0) then toggleVehicleRespawn(veh, true) setVehicleRespawnDelay(veh, 60000) setVehicleIdleRespawnDelay(veh, 180000) end local rx, ry, rz = getVehicleRotation(veh) setVehicleRespawnPosition(veh, x, y, z, rx, ry, rz) exports['anticheat-system']:changeProtectedElementDataEx(veh, "respawnposition", {x, y, z, rx, ry, rz}, false) setVehicleLocked(veh, false) setVehicleColor(veh, col1, col2, col1, col2) setVehicleOverrideLights(veh, 1) setVehicleEngineState(veh, false) setVehicleFuelTankExplodable(veh, false) local dimension = getElementDimension(thePlayer) local interior = getElementInterior(thePlayer) exports['anticheat-system']:changeProtectedElementDataEx(veh, "dimension", dimension, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "interior", interior, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "job", job, job ~= 0) -- Set the vehicle armored if it is armored if (armoredCars[id]) then setVehicleDamageProof(veh, true) end local insertid = mysql:query_insert_free("INSERT INTO vehicles SET job='" .. mysql:escape_string(job) .. "', model='" .. mysql:escape_string(id) .. "', x='" .. mysql:escape_string(x) .. "', y='" .. mysql:escape_string(y) .. "', z='" .. mysql:escape_string(z) .. "', rotx='" .. mysql:escape_string(rx) .. "', roty='" .. mysql:escape_string(ry) .. "', rotz='" .. mysql:escape_string(rz) .. "', color1='" .. mysql:escape_string(col1) .. "', color2='" .. mysql:escape_string(col2) .. "', faction='-1', owner='-2', plate='" .. mysql:escape_string(plate) .. "', currx='" .. mysql:escape_string(x) .. "', curry='" .. mysql:escape_string(y) .. "', currz='" .. mysql:escape_string(z) .. "', currrx='0', currry='0', currrz='" .. mysql:escape_string(r) .. "', interior='" .. mysql:escape_string(interior) .. "', currinterior='" .. mysql:escape_string(interior) .. "', dimension='" .. mysql:escape_string(dimension) .. "', currdimension='" .. mysql:escape_string(dimension) .. "'") if (insertid) then exports.pool:allocateElement(veh, insertid) exports['anticheat-system']:changeProtectedElementDataEx(veh, "dbid", insertid) exports['anticheat-system']:changeProtectedElementDataEx(veh, "fuel", 100) exports['anticheat-system']:changeProtectedElementDataEx(veh, "engine", 0, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldx", x, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldy", y, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "oldz", z, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "faction", -1) exports['anticheat-system']:changeProtectedElementDataEx(veh, "owner", -2, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "job", job, job ~= 0) exports['anticheat-system']:changeProtectedElementDataEx(veh, "handbrake", 0, false) exports['anticheat-system']:changeProtectedElementDataEx(veh, "vehicle:windowstat", 0, true) outputChatBox(getVehicleName(veh) .. " (CIVIL) lespawnova (ID #" .. insertid .. ").", thePlayer, 255, 194, 14) exports.logs:logMessage("[MAKECIVVEH] " .. getPlayerName( thePlayer ) .. " created car #" .. insertid .. " (" .. getVehicleNameFromModel( id ) .. ")", 9) exports['vehicle-interiors']:add( veh ) else destroyElement( veh ) end end end end end addCommandHandler("makecivveh", createCivilianPermVehicle, false, false) What is the problem? /makecivveh tractor 0 0 8 (8 ID is not work) please help me Link to comment
Castillo Posted August 27, 2012 Share Posted August 27, 2012 Why does not work? does it output any debugscript error ( /debugscript 3 in-game )? 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