ramzi Posted March 10, 2015 Posted March 10, 2015 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 DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Delte function line 128 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 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' DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Delete end line 130 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 Still not working :\ SCRIPT ERROR: sqlvehicles\vehicles_usefulserver.lua:138: '' expected near 'end' ERROR: Loading script failed: sqlvehicles\vehicles_usefulserver.lua:138: '' expected near 'end' DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 So added end line 138 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
roaddog Posted March 10, 2015 Posted March 10, 2015 --[[ +---------------------------------------------------------------------------- | =================== 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 You gone learn today. I work my ass off, but I still can't pay tho.
ramzi Posted March 10, 2015 Author Posted March 10, 2015 Thnx rly for helping meh!,but still got the problem DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Post it #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 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' DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
ramzi Posted March 10, 2015 Author Posted March 10, 2015 Note:i added this function in usefulserver.lua,i didnt add it in server/client side. DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Delete ) line 136and put it at the end line 140 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 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' DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Post the new code i thought you should addee ) cuz your code isnt closed #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 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 ) DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Delte end line 138 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 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 ) DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
ramzi Posted March 10, 2015 Author Posted March 10, 2015 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' DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
roaddog Posted March 10, 2015 Posted March 10, 2015 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 ) You gone learn today. I work my ass off, but I still can't pay tho.
ramzi Posted March 10, 2015 Author Posted March 10, 2015 Another error shows up : WARNING: sqlvehicles\vehicles_usefulserver.lua:120: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nil] DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Repalce vehicle with root at line 120 #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 Well bodypart of the blown vehicles respwned,but the vehicles itself didnt respawn and i got another error: ERROR: sqlvehicles\vehicles_usefulserver.lua:130: attempt to call global 'createPrivateVehicle' (a nil value) DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
darhal Posted March 10, 2015 Posted March 10, 2015 Well createPrivateVehicle is not defined you can search in the wiki for a function that fix broken vehicles #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
darhal Posted March 10, 2015 Posted March 10, 2015 fixVehicle #include <iostream> int main() { std::cout << "C++ is amazing <3" << std::endl; return 0; } I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please
ramzi Posted March 10, 2015 Author Posted March 10, 2015 Still not working DZ Army Base: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11101 Flyingcars script: https://community.multitheftauto.com/index.php?p=resources&s=details&id=11116
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