Jump to content

Expected near end error :(


ramzi

Recommended Posts

Hi guys,i have downloaded Sqlvehicles script of Jasper,but i have got some bugs;Vehicles cant be respawned,there is no such function for it,so i have made a function but i got an error!:

SCRIPT ERROR: sqlvehicles\vehicles_usefulserver.lua:138: '' expected near 'end'

ERROR: Loading script failed: sqlvehicles\vehicles_usefulserver.lua:138: '' expected near 'end'

i added the function in the last line:

--[[ 
+---------------------------------------------------------------------------- 
| =================== Script made by Jasper~ =================== | 
| Please, respect my work -> do not remove the copyrights. 
| This script took me 45 minutes of my wonderfull life 
| Bugs/Suggestions? Add me on skype!  
+----------------------------------------------------------------------------- 
]]-- 
  
  
function lock_newvehicles(player, seat, jacked) 
if isPedOnGround(player) == true then 
if getElementData(source, "whoLocked") == "team" then 
local lock = getElementData(source, "lockedTo") 
if seat == 0 then 
if getTeamName(getPlayerTeam(player)) == lock then 
return true 
else 
cancelEvent()exports.DZcommands:sendClientMessage("This vehicle is locked for the following team(s): "..lock..".", player, 255, 255, 255) 
end 
end 
elseif getElementData(source, "whoLocked") == "class" then 
local lock = getElementData(source, "lockedTo") 
if seat == 0 then 
if getElementData(player, "class") == lock then 
return true 
else 
cancelEvent() 
exports.DZcommands:sendClientMessage("This vehicle is locked for the following class(es): "..lock..".", player, 255, 255, 255) 
end 
end 
elseif getElementData(source, "whoLocked") == "account" then 
local lock = getElementData(source, "lockedTo") 
local accName = getAccountName(getPlayerAccount(player)) 
if seat == 0 then 
if accName == lock then 
return true 
else 
cancelEvent() 
exports.DZcommands:sendClientMessage("This vehicle is locked and belongs to the following user(s): "..lock..".", player, 255, 255, 255) 
end 
end 
elseif getElementData(source, "whoLocked") == "acl" then 
local lock = getElementData(source, "lockedTo") 
local accName = getAccountName(getPlayerAccount(player)) 
if seat == 0 then 
if isObjectInACLGroup("user."..accName, aclGetGroup(lock)) then 
return true 
else 
cancelEvent() 
exports.DZcommands:sendClientMessage("This vehicle is locked for the following group(s): "..lock..".", player, 255, 255, 255) 
end 
end 
end 
end 
end 
addEventHandler("onVehicleStartEnter", getRootElement(), lock_newvehicles) 
  
  
function add_new_vehicle (source, command, whoLock, ...) 
local accName = getAccountName(getPlayerAccount(source)) 
if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
if isPedInVehicle(source) == true then 
if not isPedDead(source) == true then 
local newlock = whoLock 
if newlock == "team" or newlock == "class" or newlock == "acl" or newlock == "account" then 
if #arg > 0 then 
local occupiedVeh = getPedOccupiedVehicle(source) 
local model = getElementModel(occupiedVeh) 
local x,y,z = getElementPosition(occupiedVeh) 
local rx,ry,rz = getElementRotation(occupiedVeh) 
local lock = table.concat(arg, " ") 
local groupLock = whoLock 
local r1, g1, b1, r2, g2, b2 = getVehicleColor(occupiedVeh, true) 
local color = tostring(r1.. "," ..g1.. "," ..b1.. "," ..r2.. "," ..g2.. "," ..b2) 
local addVeh = executeSQLQuery("INSERT INTO newprivatevehicles (Model,X,Y,Z,RX,RY,RZ,LOCK,GROUPLOCK,Color) VALUES(?,?,?,?,?,?,?,?,?,?)", tonumber(model), tonumber(x), tonumber(y), tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz), lock, groupLock, tostring(color)) 
exports.DZcommands:sendClientMessage("Vehicle successfuly created, info: "..groupLock.." - "..lock..".", source, 0,255,0) 
local newVehicle = createVehicle (tonumber(model),tonumber(x),tonumber(y),tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz)) 
setElementData(newVehicle, "lockedTo", lock) 
setElementData(newVehicle, "whoLocked", whoLock) 
setVehicleColor (newVehicle, tonumber(r1), tonumber(g1), tonumber(b1), tonumber(r2), tonumber(g2), tonumber(b2)) 
warpPedIntoVehicle(source, newVehicle) 
else 
exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
end 
else 
exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
end 
exports.DZcommands:sendClientMessage("You are dead, respawn to make this vehicle!", source, 255, 255, 255) 
end 
elseexports.DZcommands:sendClientMessage("You are not in a vehicle, go in a vehicle to create one!", source, 255, 255, 255) 
end 
end 
end 
addCommandHandler("addveh", add_new_vehicle) 
  
-- remove function 
  
function remove_lockedvehicle (source)  
local accName = getAccountName(getPlayerAccount(source)) 
if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
local vehicle = getPedOccupiedVehicle(source) 
local lock = getElementData(vehicle, "lockedTo") 
    if isPedInVehicle(source) == true then 
        if getElementData(vehicle, "lockedTo") ~= "" then 
                executeSQLQuery("DELETE FROM newprivatevehicles WHERE LOCK=?", lock) 
                 destroyElement(vehicle) 
                  exports.DZcommands:sendClientMessage("Vehicle has successfully been removed from the database.", source, 255, 255, 255) 
                else 
                   exports.DZcommands:sendClientMessage("* This is not a private vehicle, take another vehicle!", source, 255, 255, 255) 
        end 
             else 
        exports.DZcommands:sendClientMessage("* You must be in a vehicle in order to remove this vehicle.", source, 255, 255, 255) 
    end 
end 
end 
addCommandHandler("remveh", remove_lockedvehicle) 
  
addEventHandler("onVehicleExplode",vehicle, 
            function () 
                setTimer ( 
                    function ( vehicleID, vehicle ) 
                        if ( vehicleID and type ( vehicleID ) == "number" ) then 
                            table.remove(vehicles, vehicleID) 
                            if isElement( vehicle ) then 
                                destroyElement ( vehicle ) 
                            end 
                             function table_lockedvehicles () 
executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") 
end 
                            createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) 
                        end 
                    end 
                ,10000, 1, #vehicles, source ) 
            end 
        ) 
         return vehicle 
      end 
  
  

Plz Help :)

Link to comment

I did and i got another error:

SCRIPT ERROR: sqlvehicles\vehicles_usefulserver.lua:133: ')' expected (to close '(' at line 121) near 'end'

ERROR: Loading script failed: sqlvehicles\vehicles_usefulserver.lua:133: ')' expected (to close '(' at line 121) near 'end'

Link to comment
--[[ 
+---------------------------------------------------------------------------- 
| =================== Script made by Jasper~ =================== | 
| Please, respect my work -> do not remove the copyrights. 
| This script took me 45 minutes of my wonderfull life 
| Bugs/Suggestions? Add me on skype! 
+----------------------------------------------------------------------------- 
]]-- 
  
  
function lock_newvehicles(player, seat, jacked) 
if isPedOnGround(player) == true then 
if getElementData(source, "whoLocked") == "team" then 
local lock = getElementData(source, "lockedTo") 
if seat == 0 then 
if getTeamName(getPlayerTeam(player)) == lock then 
return true 
else 
cancelEvent()exports.DZcommands:sendClientMessage("This vehicle is locked for the following team(s): "..lock..".", player, 255, 255, 255) 
end 
end 
elseif getElementData(source, "whoLocked") == "class" then 
local lock = getElementData(source, "lockedTo") 
if seat == 0 then 
if getElementData(player, "class") == lock then 
return true 
else 
cancelEvent() 
exports.DZcommands:sendClientMessage("This vehicle is locked for the following class(es): "..lock..".", player, 255, 255, 255) 
end 
end 
elseif getElementData(source, "whoLocked") == "account" then 
local lock = getElementData(source, "lockedTo") 
local accName = getAccountName(getPlayerAccount(player)) 
if seat == 0 then 
if accName == lock then 
return true 
else 
cancelEvent() 
exports.DZcommands:sendClientMessage("This vehicle is locked and belongs to the following user(s): "..lock..".", player, 255, 255, 255) 
end 
end 
elseif getElementData(source, "whoLocked") == "acl" then 
local lock = getElementData(source, "lockedTo") 
local accName = getAccountName(getPlayerAccount(player)) 
if seat == 0 then 
if isObjectInACLGroup("user."..accName, aclGetGroup(lock)) then 
return true 
else 
cancelEvent() 
exports.DZcommands:sendClientMessage("This vehicle is locked for the following group(s): "..lock..".", player, 255, 255, 255) 
end 
end 
end 
end 
end 
addEventHandler("onVehicleStartEnter", getRootElement(), lock_newvehicles) 
  
  
function add_new_vehicle (source, command, whoLock, ...) 
local accName = getAccountName(getPlayerAccount(source)) 
if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
if isPedInVehicle(source) == true then 
if not isPedDead(source) == true then 
local newlock = whoLock 
if newlock == "team" or newlock == "class" or newlock == "acl" or newlock == "account" then 
if #arg > 0 then 
local occupiedVeh = getPedOccupiedVehicle(source) 
local model = getElementModel(occupiedVeh) 
local x,y,z = getElementPosition(occupiedVeh) 
local rx,ry,rz = getElementRotation(occupiedVeh) 
local lock = table.concat(arg, " ") 
local groupLock = whoLock 
local r1, g1, b1, r2, g2, b2 = getVehicleColor(occupiedVeh, true) 
local color = tostring(r1.. "," ..g1.. "," ..b1.. "," ..r2.. "," ..g2.. "," ..b2) 
local addVeh = executeSQLQuery("INSERT INTO newprivatevehicles (Model,X,Y,Z,RX,RY,RZ,LOCK,GROUPLOCK,Color) VALUES(?,?,?,?,?,?,?,?,?,?)", tonumber(model), tonumber(x), tonumber(y), tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz), lock, groupLock, tostring(color)) 
exports.DZcommands:sendClientMessage("Vehicle successfuly created, info: "..groupLock.." - "..lock..".", source, 0,255,0) 
local newVehicle = createVehicle (tonumber(model),tonumber(x),tonumber(y),tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz)) 
setElementData(newVehicle, "lockedTo", lock) 
setElementData(newVehicle, "whoLocked", whoLock) 
setVehicleColor (newVehicle, tonumber(r1), tonumber(g1), tonumber(b1), tonumber(r2), tonumber(g2), tonumber(b2)) 
warpPedIntoVehicle(source, newVehicle) 
else 
exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
end 
else 
exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
end 
exports.DZcommands:sendClientMessage("You are dead, respawn to make this vehicle!", source, 255, 255, 255) 
end 
elseexports.DZcommands:sendClientMessage("You are not in a vehicle, go in a vehicle to create one!", source, 255, 255, 255) 
end 
end 
end 
addCommandHandler("addveh", add_new_vehicle) 
  
-- remove function 
  
function remove_lockedvehicle (source) 
local accName = getAccountName(getPlayerAccount(source)) 
if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
local vehicle = getPedOccupiedVehicle(source) 
local lock = getElementData(vehicle, "lockedTo") 
    if isPedInVehicle(source) == true then 
        if getElementData(vehicle, "lockedTo") ~= "" then 
                executeSQLQuery("DELETE FROM newprivatevehicles WHERE LOCK=?", lock) 
                 destroyElement(vehicle) 
                  exports.DZcommands:sendClientMessage("Vehicle has successfully been removed from the database.", source, 255, 255, 255) 
                else 
                   exports.DZcommands:sendClientMessage("* This is not a private vehicle, take another vehicle!", source, 255, 255, 255) 
        end 
             else 
        exports.DZcommands:sendClientMessage("* You must be in a vehicle in order to remove this vehicle.", source, 255, 255, 255) 
    end 
end 
end 
addCommandHandler("remveh", remove_lockedvehicle) 
  
addEventHandler("onVehicleExplode",vehicle, 
            function () 
                setTimer ( 
                    function ( vehicleID, vehicle ) 
                        if ( vehicleID and type ( vehicleID ) == "number" ) then 
                            table.remove(vehicles, vehicleID) 
                            if isElement( vehicle ) then 
                                destroyElement ( vehicle ) 
                            end 
                            table_lockedvehicles() 
                            createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) 
                        end 
                    end 
                ,10000, 1, #vehicles, source ) 
         return vehicle 
      end) 
       
function table_lockedvehicles () 
    executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") 
end 
  

Link to comment

Here:

New Lua:

    --[[ 
    +---------------------------------------------------------------------------- 
    | =================== Script made by Jasper~ =================== | 
    | Please, respect my work -> do not remove the copyrights. 
    | This script took me 45 minutes of my wonderfull life 
    | Bugs/Suggestions? Add me on skype! 
    +----------------------------------------------------------------------------- 
    ]]-- 
      
      
    function lock_newvehicles(player, seat, jacked) 
    if isPedOnGround(player) == true then 
    if getElementData(source, "whoLocked") == "team" then 
    local lock = getElementData(source, "lockedTo") 
    if seat == 0 then 
    if getTeamName(getPlayerTeam(player)) == lock then 
    return true 
    else 
    cancelEvent()exports.DZcommands:sendClientMessage("This vehicle is locked for the following team(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "class" then 
    local lock = getElementData(source, "lockedTo") 
    if seat == 0 then 
    if getElementData(player, "class") == lock then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked for the following class(es): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "account" then 
    local lock = getElementData(source, "lockedTo") 
    local accName = getAccountName(getPlayerAccount(player)) 
    if seat == 0 then 
    if accName == lock then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked and belongs to the following user(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "acl" then 
    local lock = getElementData(source, "lockedTo") 
    local accName = getAccountName(getPlayerAccount(player)) 
    if seat == 0 then 
    if isObjectInACLGroup("user."..accName, aclGetGroup(lock)) then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked for the following group(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    end 
    end 
    end 
    addEventHandler("onVehicleStartEnter", getRootElement(), lock_newvehicles) 
      
      
    function add_new_vehicle (source, command, whoLock, ...) 
    local accName = getAccountName(getPlayerAccount(source)) 
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
    if isPedInVehicle(source) == true then 
    if not isPedDead(source) == true then 
    local newlock = whoLock 
    if newlock == "team" or newlock == "class" or newlock == "acl" or newlock == "account" then 
    if #arg > 0 then 
    local occupiedVeh = getPedOccupiedVehicle(source) 
    local model = getElementModel(occupiedVeh) 
    local x,y,z = getElementPosition(occupiedVeh) 
    local rx,ry,rz = getElementRotation(occupiedVeh) 
    local lock = table.concat(arg, " ") 
    local groupLock = whoLock 
    local r1, g1, b1, r2, g2, b2 = getVehicleColor(occupiedVeh, true) 
    local color = tostring(r1.. "," ..g1.. "," ..b1.. "," ..r2.. "," ..g2.. "," ..b2) 
    local addVeh = executeSQLQuery("INSERT INTO newprivatevehicles (Model,X,Y,Z,RX,RY,RZ,LOCK,GROUPLOCK,Color) VALUES(?,?,?,?,?,?,?,?,?,?)", tonumber(model), tonumber(x), tonumber(y), tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz), lock, groupLock, tostring(color)) 
    exports.DZcommands:sendClientMessage("Vehicle successfuly created, info: "..groupLock.." - "..lock..".", source, 0,255,0) 
    local newVehicle = createVehicle (tonumber(model),tonumber(x),tonumber(y),tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz)) 
    setElementData(newVehicle, "lockedTo", lock) 
    setElementData(newVehicle, "whoLocked", whoLock) 
    setVehicleColor (newVehicle, tonumber(r1), tonumber(g1), tonumber(b1), tonumber(r2), tonumber(g2), tonumber(b2)) 
    warpPedIntoVehicle(source, newVehicle) 
    else 
    exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
    end 
    else 
    exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
    end 
    exports.DZcommands:sendClientMessage("You are dead, respawn to make this vehicle!", source, 255, 255, 255) 
    end 
    elseexports.DZcommands:sendClientMessage("You are not in a vehicle, go in a vehicle to create one!", source, 255, 255, 255) 
    end 
    end 
    end 
    addCommandHandler("addveh", add_new_vehicle) 
      
    -- remove function 
      
    function remove_lockedvehicle (source) 
    local accName = getAccountName(getPlayerAccount(source)) 
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
    local vehicle = getPedOccupiedVehicle(source) 
    local lock = getElementData(vehicle, "lockedTo") 
        if isPedInVehicle(source) == true then 
            if getElementData(vehicle, "lockedTo") ~= "" then 
                    executeSQLQuery("DELETE FROM newprivatevehicles WHERE LOCK=?", lock) 
                     destroyElement(vehicle) 
                      exports.DZcommands:sendClientMessage("Vehicle has successfully been removed from the database.", source, 255, 255, 255) 
                    else 
                       exports.DZcommands:sendClientMessage("* This is not a private vehicle, take another vehicle!", source, 255, 255, 255) 
            end 
                 else 
            exports.DZcommands:sendClientMessage("* You must be in a vehicle in order to remove this vehicle.", source, 255, 255, 255) 
        end 
    end 
    end 
    addCommandHandler("remveh", remove_lockedvehicle) 
      
    addEventHandler("onVehicleExplode",vehicle, 
                function () 
                    setTimer ( 
                        function ( vehicleID, vehicle ) 
                            if ( vehicleID and type ( vehicleID ) == "number" ) then 
                                table.remove(vehicles, vehicleID) 
                                if isElement( vehicle ) then 
                                    destroyElement ( vehicle ) 
                                end 
                                  
    executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") 
     
                                createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) 
                            end 
                        end 
                    ,10000, 1, #vehicles, source ) 
                end 
            ) 
             return vehicle 
 end  
      
      
      

Error msg:

SCRIPT ERROR: sqlvehicles\vehicles_usefulserver.lua:138: '' expected near 'end'

ERROR: Loading script failed: sqlvehicles\vehicles_usefulserver.lua:138: '' expected near 'end'

Link to comment

Sry mate,if i have wasted ur time,but errors still showing on:

SCRIPT ERROR: sqlvehicles\vehicles_usefulserver.lua:137: ')' expected (to close '(' at line 119) near 'return'

ERROR: Loading script failed: sqlvehicles\vehicles_usefulserver.lua:137: ')' expected (to close '(' at line 119) near 'return'

Link to comment

Okay here is the new one:

    --[[ 
    +---------------------------------------------------------------------------- 
    | =================== Script made by Jasper~ =================== | 
    | Please, respect my work -> do not remove the copyrights. 
    | This script took me 45 minutes of my wonderfull life 
    | Bugs/Suggestions? Add me on skype! 
    +----------------------------------------------------------------------------- 
    ]]-- 
      
      
    function lock_newvehicles(player, seat, jacked) 
    if isPedOnGround(player) == true then 
    if getElementData(source, "whoLocked") == "team" then 
    local lock = getElementData(source, "lockedTo") 
    if seat == 0 then 
    if getTeamName(getPlayerTeam(player)) == lock then 
    return true 
    else 
    cancelEvent()exports.DZcommands:sendClientMessage("This vehicle is locked for the following team(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "class" then 
    local lock = getElementData(source, "lockedTo") 
    if seat == 0 then 
    if getElementData(player, "class") == lock then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked for the following class(es): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "account" then 
    local lock = getElementData(source, "lockedTo") 
    local accName = getAccountName(getPlayerAccount(player)) 
    if seat == 0 then 
    if accName == lock then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked and belongs to the following user(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "acl" then 
    local lock = getElementData(source, "lockedTo") 
    local accName = getAccountName(getPlayerAccount(player)) 
    if seat == 0 then 
    if isObjectInACLGroup("user."..accName, aclGetGroup(lock)) then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked for the following group(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    end 
    end 
    end 
    addEventHandler("onVehicleStartEnter", getRootElement(), lock_newvehicles) 
      
      
    function add_new_vehicle (source, command, whoLock, ...) 
    local accName = getAccountName(getPlayerAccount(source)) 
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
    if isPedInVehicle(source) == true then 
    if not isPedDead(source) == true then 
    local newlock = whoLock 
    if newlock == "team" or newlock == "class" or newlock == "acl" or newlock == "account" then 
    if #arg > 0 then 
    local occupiedVeh = getPedOccupiedVehicle(source) 
    local model = getElementModel(occupiedVeh) 
    local x,y,z = getElementPosition(occupiedVeh) 
    local rx,ry,rz = getElementRotation(occupiedVeh) 
    local lock = table.concat(arg, " ") 
    local groupLock = whoLock 
    local r1, g1, b1, r2, g2, b2 = getVehicleColor(occupiedVeh, true) 
    local color = tostring(r1.. "," ..g1.. "," ..b1.. "," ..r2.. "," ..g2.. "," ..b2) 
    local addVeh = executeSQLQuery("INSERT INTO newprivatevehicles (Model,X,Y,Z,RX,RY,RZ,LOCK,GROUPLOCK,Color) VALUES(?,?,?,?,?,?,?,?,?,?)", tonumber(model), tonumber(x), tonumber(y), tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz), lock, groupLock, tostring(color)) 
    exports.DZcommands:sendClientMessage("Vehicle successfuly created, info: "..groupLock.." - "..lock..".", source, 0,255,0) 
    local newVehicle = createVehicle (tonumber(model),tonumber(x),tonumber(y),tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz)) 
    setElementData(newVehicle, "lockedTo", lock) 
    setElementData(newVehicle, "whoLocked", whoLock) 
    setVehicleColor (newVehicle, tonumber(r1), tonumber(g1), tonumber(b1), tonumber(r2), tonumber(g2), tonumber(b2)) 
    warpPedIntoVehicle(source, newVehicle) 
    else 
    exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
    end 
    else 
    exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
    end 
    exports.DZcommands:sendClientMessage("You are dead, respawn to make this vehicle!", source, 255, 255, 255) 
    end 
    elseexports.DZcommands:sendClientMessage("You are not in a vehicle, go in a vehicle to create one!", source, 255, 255, 255) 
    end 
    end 
    end 
    addCommandHandler("addveh", add_new_vehicle) 
      
    -- remove function 
      
    function remove_lockedvehicle (source) 
    local accName = getAccountName(getPlayerAccount(source)) 
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
    local vehicle = getPedOccupiedVehicle(source) 
    local lock = getElementData(vehicle, "lockedTo") 
        if isPedInVehicle(source) == true then 
            if getElementData(vehicle, "lockedTo") ~= "" then 
                    executeSQLQuery("DELETE FROM newprivatevehicles WHERE LOCK=?", lock) 
                     destroyElement(vehicle) 
                      exports.DZcommands:sendClientMessage("Vehicle has successfully been removed from the database.", source, 255, 255, 255) 
                    else 
                       exports.DZcommands:sendClientMessage("* This is not a private vehicle, take another vehicle!", source, 255, 255, 255) 
            end 
                 else 
            exports.DZcommands:sendClientMessage("* You must be in a vehicle in order to remove this vehicle.", source, 255, 255, 255) 
        end 
    end 
    end 
    addCommandHandler("remveh", remove_lockedvehicle) 
      
    addEventHandler("onVehicleExplode",vehicle, 
                function () 
                    setTimer ( 
                        function ( vehicleID, vehicle ) 
                            if ( vehicleID and type ( vehicleID ) == "number" ) then 
                                table.remove(vehicles, vehicleID) 
                                if isElement( vehicle ) then 
                                    destroyElement ( vehicle ) 
                                end 
                                  
    executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") 
     
                                createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) 
                            end 
                        end 
                    ,10000, 1, #vehicles, source ) 
                end 
             
             return vehicle 
 end  
      
)      
      

Link to comment

i did,here is the new code:

    --[[ 
    +---------------------------------------------------------------------------- 
    | =================== Script made by Jasper~ =================== | 
    | Please, respect my work -> do not remove the copyrights. 
    | This script took me 45 minutes of my wonderfull life 
    | Bugs/Suggestions? Add me on skype! 
    +----------------------------------------------------------------------------- 
    ]]-- 
      
      
    function lock_newvehicles(player, seat, jacked) 
    if isPedOnGround(player) == true then 
    if getElementData(source, "whoLocked") == "team" then 
    local lock = getElementData(source, "lockedTo") 
    if seat == 0 then 
    if getTeamName(getPlayerTeam(player)) == lock then 
    return true 
    else 
    cancelEvent()exports.DZcommands:sendClientMessage("This vehicle is locked for the following team(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "class" then 
    local lock = getElementData(source, "lockedTo") 
    if seat == 0 then 
    if getElementData(player, "class") == lock then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked for the following class(es): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "account" then 
    local lock = getElementData(source, "lockedTo") 
    local accName = getAccountName(getPlayerAccount(player)) 
    if seat == 0 then 
    if accName == lock then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked and belongs to the following user(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    elseif getElementData(source, "whoLocked") == "acl" then 
    local lock = getElementData(source, "lockedTo") 
    local accName = getAccountName(getPlayerAccount(player)) 
    if seat == 0 then 
    if isObjectInACLGroup("user."..accName, aclGetGroup(lock)) then 
    return true 
    else 
    cancelEvent() 
    exports.DZcommands:sendClientMessage("This vehicle is locked for the following group(s): "..lock..".", player, 255, 255, 255) 
    end 
    end 
    end 
    end 
    end 
    addEventHandler("onVehicleStartEnter", getRootElement(), lock_newvehicles) 
      
      
    function add_new_vehicle (source, command, whoLock, ...) 
    local accName = getAccountName(getPlayerAccount(source)) 
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
    if isPedInVehicle(source) == true then 
    if not isPedDead(source) == true then 
    local newlock = whoLock 
    if newlock == "team" or newlock == "class" or newlock == "acl" or newlock == "account" then 
    if #arg > 0 then 
    local occupiedVeh = getPedOccupiedVehicle(source) 
    local model = getElementModel(occupiedVeh) 
    local x,y,z = getElementPosition(occupiedVeh) 
    local rx,ry,rz = getElementRotation(occupiedVeh) 
    local lock = table.concat(arg, " ") 
    local groupLock = whoLock 
    local r1, g1, b1, r2, g2, b2 = getVehicleColor(occupiedVeh, true) 
    local color = tostring(r1.. "," ..g1.. "," ..b1.. "," ..r2.. "," ..g2.. "," ..b2) 
    local addVeh = executeSQLQuery("INSERT INTO newprivatevehicles (Model,X,Y,Z,RX,RY,RZ,LOCK,GROUPLOCK,Color) VALUES(?,?,?,?,?,?,?,?,?,?)", tonumber(model), tonumber(x), tonumber(y), tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz), lock, groupLock, tostring(color)) 
    exports.DZcommands:sendClientMessage("Vehicle successfuly created, info: "..groupLock.." - "..lock..".", source, 0,255,0) 
    local newVehicle = createVehicle (tonumber(model),tonumber(x),tonumber(y),tonumber(z), tonumber(rx), tonumber(ry), tonumber(rz)) 
    setElementData(newVehicle, "lockedTo", lock) 
    setElementData(newVehicle, "whoLocked", whoLock) 
    setVehicleColor (newVehicle, tonumber(r1), tonumber(g1), tonumber(b1), tonumber(r2), tonumber(g2), tonumber(b2)) 
    warpPedIntoVehicle(source, newVehicle) 
    else 
    exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
    end 
    else 
    exports.DZcommands:sendClientMessage("Wrong command usage, try '/addveh '.", source, 255, 255, 255) 
    end 
    exports.DZcommands:sendClientMessage("You are dead, respawn to make this vehicle!", source, 255, 255, 255) 
    end 
    elseexports.DZcommands:sendClientMessage("You are not in a vehicle, go in a vehicle to create one!", source, 255, 255, 255) 
    end 
    end 
    end 
    addCommandHandler("addveh", add_new_vehicle) 
      
    -- remove function 
      
    function remove_lockedvehicle (source) 
    local accName = getAccountName(getPlayerAccount(source)) 
    if isObjectInACLGroup("user."..accName, aclGetGroup("Admin")) then 
    local vehicle = getPedOccupiedVehicle(source) 
    local lock = getElementData(vehicle, "lockedTo") 
        if isPedInVehicle(source) == true then 
            if getElementData(vehicle, "lockedTo") ~= "" then 
                    executeSQLQuery("DELETE FROM newprivatevehicles WHERE LOCK=?", lock) 
                     destroyElement(vehicle) 
                      exports.DZcommands:sendClientMessage("Vehicle has successfully been removed from the database.", source, 255, 255, 255) 
                    else 
                       exports.DZcommands:sendClientMessage("* This is not a private vehicle, take another vehicle!", source, 255, 255, 255) 
            end 
                 else 
            exports.DZcommands:sendClientMessage("* You must be in a vehicle in order to remove this vehicle.", source, 255, 255, 255) 
        end 
    end 
    end 
    addCommandHandler("remveh", remove_lockedvehicle) 
      
    addEventHandler("onVehicleExplode",vehicle, 
                function () 
                    setTimer ( 
                        function ( vehicleID, vehicle ) 
                            if ( vehicleID and type ( vehicleID ) == "number" ) then 
                                table.remove(vehicles, vehicleID) 
                                if isElement( vehicle ) then 
                                    destroyElement ( vehicle ) 
                                end 
                                  
    executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") 
     
                                createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) 
                            end 
                        end 
                    ,10000, 1, #vehicles, source ) 
                end 
             
             return vehicle 
) 
   
      
      
      

Link to comment

error msg:

SCRIPT ERROR: sqlvehicles\vehicles_usefulserver.lua:137: ')' expected (to close '(' at line 119) near 'return'

ERROR: Loading script failed: sqlvehicles\vehicles_usefulserver.lua:137: ')' expected (to close '(' at line 119) near 'return'

Link to comment

Replace the last function lines with this.

  
    addEventHandler("onVehicleExplode",vehicle, 
                function () 
                    setTimer ( 
                        function ( vehicleID, vehicle ) 
                            if ( vehicleID and type ( vehicleID ) == "number" ) then 
                                table.remove(vehicles, vehicleID) 
                                if isElement( vehicle ) then 
                                    destroyElement ( vehicle ) 
                                end 
                              executeSQLQuery("CREATE TABLE IF NOT EXISTS newprivatevehicles (Model NUMERIC, X NUMBERIC, Y NUMERIC, Z NUMERIC, RX NUMERIC, RY NUMERIC, RZ NUMERIC, LOCK TEXT, GROUPLOCK TEXT, Color TEXT)") 
                                createPrivateVehicle(model, x, y, z, rot, color, upgrades, dataType, allowedTo) 
                            end 
                        end 
                    ,10000, 1, #vehicles, source ) 
            return vehicle 
end 
) 
  

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...