Jump to content

TheGUF

Members
  • Posts

    27
  • Joined

  • Last visited

About TheGUF

  • Birthday 04/03/1991

Details

  • Gang
    DayZRP Majestic
  • Location
    Romania

Recent Profile Visitors

441 profile views

TheGUF's Achievements

Advanced Member

Advanced Member (8/54)

0

Reputation

  1. Hi all ! Can you help me please with the elevator system, when I make the first position of the elevator in the second position it gives me this error! how can i solve [ADDELEVATOR] Source point saved. Please /addelevator once again at destination point. [ADDELEVATOR] There was an error while creating an elevator. Try again. s_elevator_system.lua local timerLoadAllElevators = 30000 mysql = exports.mysql addEvent("onPlayerInteriorChange", true) -- Defines INTERIOR_X = 1 INTERIOR_Y = 2 INTERIOR_Z = 3 INTERIOR_INT = 4 INTERIOR_DIM = 5 INTERIOR_ANGLE = 6 INTERIOR_FEE = 7 INTERIOR_TYPE = 1 INTERIOR_DISABLED = 2 INTERIOR_LOCKED = 3 INTERIOR_OWNER = 4 INTERIOR_COST = 5 INTERIOR_SUPPLIES = 6 -- Small hack function setElementDataEx(source, field, parameter, streamtoall, streamatall) exports.anticheat:changeProtectedElementDataEx( source, field, parameter, streamtoall, streamatall) end -- End small hack function SmallestElevatorID( ) -- finds the smallest ID in the SQL instead of auto increment local result = mysql:query_fetch_assoc("SELECT MIN(e1.id+1) AS nextID FROM elevators AS e1 LEFT JOIN elevators AS e2 ON e1.id +1 = e2.id WHERE e2.id IS NULL") if result then return tonumber(result["nextID"]) end return false end function createElevator(thePlayer, commandName, oneway) if (exports.integration:isPlayerTrialAdmin(thePlayer) or exports.integration:isPlayerScripter(thePlayer) or exports.integration:isPlayerSupporter(thePlayer)) then if not getElementData(thePlayer, "adm:addelevator") then local x, y, z = getElementPosition(thePlayer) local rx, ry, rz = getElementRotation(thePlayer) local dim = getElementDimension(thePlayer) local int = getElementInterior(thePlayer) setElementData(thePlayer, "adm:addelevator", {x, y , z, rz, int, dim}) outputChatBox("[ADDELEVATOR] Source point saved. Please /"..commandName.." once again at destination point.", thePlayer, 0, 255, 0) return false end local sourceP = getElementData(thePlayer, "adm:addelevator") local x1, y1, z1 = getElementPosition(thePlayer) local rx1, ry1, rz1 = getElementRotation(thePlayer) local interiorwithin = getElementInterior(thePlayer) local dimensionwithin = getElementDimension(thePlayer) local ix = tonumber(ix) local iy = tonumber(iy) local iz = tonumber(iz) local id = SmallestElevatorID() if id then if oneway then if(oneway == "1") then oneway = "1" else oneway = "0" end else oneway = "0" end local query = mysql:query_free("INSERT INTO elevators SET id='" .. mysql:escape_string(id) .. "', x='" .. mysql:escape_string(x1) .. "', y='" .. mysql:escape_string(y1) .. "', z='" .. mysql:escape_string(z1) .. "', tpx='" .. mysql:escape_string(sourceP[1]) .. "', tpy='" .. mysql:escape_string(sourceP[2]) .. "', tpz='" .. mysql:escape_string(sourceP[3]) .. "', dimensionwithin='" .. mysql:escape_string(dimensionwithin) .. "', interiorwithin='" .. mysql:escape_string(interiorwithin) .. "', dimension='" .. mysql:escape_string(sourceP[6]) .. "', interior='" .. mysql:escape_string(sourceP[5]) .. "', rot='" .. mysql:escape_string(rz1) .. "', tprot='" .. mysql:escape_string(sourceP[4]) .. "', oneway=" .. mysql:escape_string(oneway) .. " ") if (query) then --reloadOneElevator(id, true) loadOneElevator(id) outputChatBox("[ADDELEVATOR] Elevator and elevator remote created with ID #" .. id .. ". Check your inventory!", thePlayer, 0, 255, 0) exports.global:giveItem(thePlayer, 73, id) removeElementData(thePlayer, "adm:addelevator") end else outputChatBox("[ADDELEVATOR] There was an error while creating an elevator. Try again.", thePlayer, 255, 0, 0) end end end addCommandHandler("addelevator", createElevator, false, false) addCommandHandler("adde", createElevator, false, false) function createElevatorWithFriend(thePlayer, commandName, targetPlayer) if (exports.integration:isPlayerTrialAdmin(thePlayer) or exports.integration:isPlayerSupporter(thePlayer)) then if not (targetPlayer) then outputChatBox("SYNTAX: /" .. commandName .. " [Target Partial Nick or ID]", thePlayer, 255, 194, 14) else local targetPlayer, tragetPlayerName = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) local x, y, z = getElementPosition(thePlayer) local interiorwithin = getElementInterior(thePlayer) local dimensionwithin = getElementDimension(thePlayer) local ix, iy, iz = getElementPosition(targetPlayer) local interior = getElementInterior(targetPlayer) local dimension = getElementDimension(targetPlayer) local rx1, ry1, rz1 = getElementPosition(thePlayer) local rx2, ry2, rz2 = getElementPosition(targetPlayer) local id = SmallestElevatorID() if id then local query = mysql:query_free("INSERT INTO elevators SET id='" .. mysql:escape_string(id) .. "', x='" .. mysql:escape_string(x) .. "', y='" .. mysql:escape_string(y) .. "', z='" .. mysql:escape_string(z) .. "', tpx='" .. mysql:escape_string(ix) .. "', tpy='" .. mysql:escape_string(iy) .. "', tpz='" .. mysql:escape_string(iz) .. "', dimensionwithin='" .. mysql:escape_string(dimensionwithin) .. "', interiorwithin='" .. mysql:escape_string(interiorwithin) .. "', dimension='" .. mysql:escape_string(dimension) .. "', interior='" .. mysql:escape_string(interior) .. "', rot='" .. mysql:escape_string(rz1) .. "', tprot='" .. mysql:escape_string(rz2) .. "' ") if (query) then loadOneElevator(id) outputChatBox("Elevator created with ID #" .. id .. "!", thePlayer, 0, 255, 0) outputChatBox(getPlayerName(thePlayer):gsub("_"," ") .. " created an elevator with an ID of " .. id .. "!", targetPlayer, 0, 255, 0) end else outputChatBox("There was an error while creating an elevator. Try again.", thePlayer, 255, 0, 0) end end end end addCommandHandler("aelevator", createElevatorWithFriend, false, false) addCommandHandler("adde2", createElevatorWithFriend, false, false) function getOposite(rot) if not rot or not tonumber(rot) then return 0 end rot = tonumber(rot) if rot > 180 then return rot - 180 else return rot + 180 end end function findElevator(elevatorID) elevatorID = tonumber(elevatorID) if elevatorID > 0 then local possibleInteriors = getElementsByType("elevator") for _, elevator in ipairs(possibleInteriors) do local eleID = getElementData(elevator, "dbid") if eleID == elevatorID then local elevatorEntrance = getElementData(elevator, "entrance") local elevatorExit = getElementData(elevator, "exit") local elevatorStatus = getElementData(elevator, "status") return elevatorID, elevatorEntrance, elevatorExit, elevatorStatus, elevator end end end return 0 end function findElevatorElement(elevatorID) elevatorID = tonumber(elevatorID) if elevatorID > 0 then local possibleInteriors = getElementsByType("elevator") for _, elevator in ipairs(possibleInteriors) do local eleID = getElementData(elevator, "dbid") if eleID == elevatorID then return elevator end end end return false end function reloadOneElevator(elevatorID, skipcheck) local dbid, entrance, exit, status, elevatorElement = findElevator( elevatorID ) if (dbid > 0 or skipcheck)then local realElevatorElement = findElevatorElement(dbid) if not realElevatorElement then outputDebugString("[reloadOneElevator] Can't find element") end triggerClientEvent("deleteInteriorElement", realElevatorElement, tonumber(dbid)) destroyElement(realElevatorElement) loadOneElevator(tonumber(dbid), false) else --outputDebugString("You suckx2") outputDebugString("Tried to reload elevator without ID.") end end local loadedElevators = 0 local initializeSoFarDetector = 0 local stats_numberOfElevators = 0 local timerDelay = 0 function loadOneElevator(elevatorID, massLoad) local row = mysql:query_fetch_assoc("SELECT rot, tprot, id, x, y, z, tpx, tpy, tpz, dimensionwithin, interiorwithin, dimension, interior, car, disabled, oneway FROM `elevators` WHERE id = " .. elevatorID ) if row then if row then for k, v in pairs( row ) do if v == null then row[k] = nil else row[k] = tonumber(v) or v end end local elevatorElement = createElement("elevator", "ele"..tostring(row.id)) setElementDataEx(elevatorElement, "dbid", row.id, true) -- X Y Z Interior Dimension Angle Entree fee setElementDataEx(elevatorElement, "entrance", { row.x, row.y, row.z, row.interiorwithin, row.dimensionwithin, row.rot, 0 }, true ) setElementDataEx(elevatorElement, "exit", { row.tpx, row.tpy, row.tpz, row.interior, row.dimension, row.tprot, 0 }, true ) -- Type Is diabled? setElementDataEx(elevatorElement, "status", { row.car, row.disabled == 1 } , true ) setElementDataEx(elevatorElement, "name", row.name, true ) setElementDataEx(elevatorElement, "oneway", row.oneway == 1 or false, true) if massLoad then loadedElevators = loadedElevators + 1 local newInitializeSoFarDetector = math.ceil(loadedElevators/(stats_numberOfElevators/100)) if loadedElevators == 1 or loadedElevators == stats_numberOfElevators or initializeSoFarDetector ~= newInitializeSoFarDetector then triggerClientEvent("elevator:initializeSoFar", root, loadedElevators, stats_numberOfElevators) initializeSoFarDetector = newInitializeSoFarDetector end else triggerClientEvent("interior:schedulePickupLoading", getRootElement(), elevatorElement) end exports.pool:allocateElement(elevatorElement, tonumber(row.id), true) return true end end end function loadAllElevators(res) triggerClientEvent("interior:clearElevators", getRootElement()) local result = mysql:query("SELECT id FROM elevators") if (result) then while true do local row = mysql:fetch_assoc(result) if not row then break end timerDelay = timerDelay + 100 stats_numberOfElevators = stats_numberOfElevators + 1 setTimer(loadOneElevator, timerDelay, 1, row.id, true) end mysql:free_result(result) -- outputDebugString("[ELEVATOR] Spawning "..stats_numberOfElevators.." elevators will be finished in approx. "..math.ceil(timerDelay/1000).." seconds.") end end setTimer(loadAllElevators,timerLoadAllElevators, 1) --addEventHandler("onResourceStart", getResourceRootElement(), loadAllElevators) --[[function resumeCo() for _, value in ipairs(threads) do coroutine.resume(value) end end]] function isInteriorLocked(dimension) local result = mysql:query_fetch_assoc("SELECT type, locked FROM `interiors` WHERE id = " .. mysql:escape_string(dimension)) local locked = false if result then if tonumber(result["rype"]) ~= 2 and tonumber(result["locked"]) == 1 then locked = true end end return locked end --MAXIME'S NEW MELTHOD local elevatorTimer = {} function enterElevator(goingin) local pickup = source local player = client if getElementType(pickup) ~= "elevator" then return false end local elevatorStatus = getElementData(pickup, "status") if elevatorStatus[INTERIOR_TYPE] == 3 then outputChatBox("You try the door handle, but it seems to be locked.", player, 255, 0,0, true) return false end vehicle = getPedOccupiedVehicle( player ) if ( ( vehicle and elevatorStatus[INTERIOR_TYPE] ~= 0 and getVehicleOccupant( vehicle ) == player ) or not vehicle ) then if not vehicle and elevatorStatus[INTERIOR_TYPE] == 2 then outputChatBox( "This entrance is for vehicles only.", player, 255, 0, 0 ) return false end if elevatorStatus[INTERIOR_DISABLED] then outputChatBox( "This interior is currently disabled.", player, 255, 0, 0 ) return false end local currentCP = nil local otherCP = nil if goingin then currentCP = getElementData(pickup, "entrance") otherCP = getElementData(pickup, "exit") else currentCP = getElementData(pickup, "exit") otherCP = getElementData(pickup, "entrance") end local locked = false local movingInSameInt = false if currentCP[INTERIOR_DIM] == 0 and otherCP[INTERIOR_DIM] ~= 0 then -- entering a house locked = isInteriorLocked(otherCP[INTERIOR_DIM]) elseif currentCP[INTERIOR_DIM] ~= 0 and otherCP[INTERIOR_DIM] == 0 then -- leaving a house locked = isInteriorLocked(currentCP[INTERIOR_DIM]) elseif currentCP[INTERIOR_DIM] ~= 0 and otherCP[INTERIOR_DIM] ~= 0 and currentCP[INTERIOR_DIM] ~= otherCP[INTERIOR_DIM] then -- changing between two houses locked = isInteriorLocked(currentCP[INTERIOR_DIM]) or isInteriorLocked(otherCP[INTERIOR_DIM]) else -- Moving in the same dimension locked = false movingInSameInt = true end local oneway = getElementData(pickup, "oneway") if oneway then if goingin then outputChatBox("It seems as if this door can only be opened from the other side.", player, 255, 0,0, true) return false end end if locked then outputChatBox("You try the door handle, but it seems to be locked.", player, 255, 0,0, true) return false end local dbid, entrance, exit, interiorType, interiorElement = call( getResourceFromName( "interior-system" ), "findProperty", player, otherCP[INTERIOR_DIM] ) if dbid > 0 then else dbid, entrance, exit, interiorType, interiorElement = call( getResourceFromName( "interior-system" ), "findProperty", player, currentCP[INTERIOR_DIM] ) end if vehicle then setTimer(warpVehicleIntoInteriorfunction, 500, 1, vehicle, otherCP[INTERIOR_INT], otherCP[INTERIOR_DIM], 2, otherCP[INTERIOR_X],otherCP[INTERIOR_Y],otherCP[INTERIOR_Z],currentCP,otherCP, interiorElement,movingInSameInt) if interiorElement and isElement(interiorElement) and getElementType(interiorElement) == "interior" then exports.anticheat:changeProtectedElementDataEx(interiorElement, "lastused", exports.datetime:now(), true) mysql:query_free("UPDATE interiors SET lastused=NOW() WHERE id="..dbid) --Alright, it's time to give admins some clues of what just happened exports.logs:dbLog("SYSTEM", 31, { interiorElement, player, vehicle } , "ENTERED/EXITED") exports["interior-manager"]:addInteriorLogs(dbid, "ENTERED/EXITED", player) end elseif isElement(player) then if movingInSameInt then setElementPosition(player, otherCP[INTERIOR_X],otherCP[INTERIOR_Y],otherCP[INTERIOR_Z], true) else exports["interior-system"]:setPlayerInsideInterior(interiorElement, player, otherCP,movingInSameInt) end return true else outputChatBox("This elevator is locked.", player, 255, 0,0, true) return false end end --outputChatBox( "This elevator needs to be set mode using a remote.", player, 255, 0, 0 ) return false end addEvent("elevator:enter", true) addEventHandler("elevator:enter", getRootElement(), enterElevator) function warpVehicleIntoInteriorfunction(vehicle, interior, dimension, offset, x,y,z,pickup,other, interiorElement,movingInSameInt) if isElement(vehicle) then if elevatorTimer[vehicle] then return false end elevatorTimer[vehicle] = true setElementFrozen(vehicle, true) setElementVelocity(vehicle, 0, 0, 0) setVehicleTurnVelocity(vehicle, 0, 0, 0) local offset = getElementData(vehicle, "groundoffset") or 2 local rx, ry, rz = getVehicleRotation(vehicle) setVehicleRotation(vehicle, 0, 0, rz) setElementPosition(vehicle, x, y, z - 1 + offset) setElementInterior(vehicle, interior) setElementDimension(vehicle, dimension) setElementRotation(vehicle, 0, 0, getOposite(other[INTERIOR_ANGLE])) exports.anticheat:changeProtectedElementDataEx(vehicle, "health", getElementHealth(vehicle), false) for i = 0, getVehicleMaxPassengers( vehicle ) do local player = getVehicleOccupant( vehicle, i ) if player then --fadeToBlack(player) triggerClientEvent( player, "CantFallOffBike", player ) --exports["interior-system"]:setPlayerInsideInterior(interiorElement, player, other ) setElementDimension(player, dimension) setElementInterior(player, interior) setCameraInterior(player, interior) triggerClientEvent(player, "setPlayerInsideInterior", interiorElement, other, interiorElement) --fadeFromBlack(player) end end setTimer(function () setVehicleTurnVelocity(vehicle, 0, 0, 0) setElementHealth(vehicle, getElementData(vehicle, "health") or 1000) exports.anticheat:changeProtectedElementDataEx(vehicle, "health") setElementFrozen(vehicle, false) elevatorTimer[vehicle] = false end, 1000, 1) end end function fadeToBlack(player) fadeCamera ( player, true, 0, 0, 0, 0 ) fadeCamera ( player, false, 1, 0, 0, 0 ) end function fadeFromBlack(player) setTimer(fadeCamera, 2000, 1, player, true, 1, 0, 0, 0 ) end function deleteElevator(thePlayer, commandName, id) if (exports.integration:isPlayerTrialAdmin(thePlayer) or exports.integration:isPlayerSupporter(thePlayer) or exports.integration:isPlayerScripter(thePlayer)) or commandName == "PROPERTYCLEANUP" then if not (tonumber(id)) then outputChatBox("SYNTAX: /" .. commandName .. " [ID]", thePlayer, 255, 194, 14) else id = tonumber(id) local dbid, entrance, exit, status, elevatorElement = findElevator( id ) if elevatorElement then local query = mysql:query_free("DELETE FROM elevators WHERE id='" .. mysql:escape_string(dbid) .. "'") if query then reloadOneElevator(dbid) if commandName ~= "PROPERTYCLEANUP" then outputChatBox("Elevator #" .. id .. " Deleted!", thePlayer, 0, 255, 0) end else if commandName ~= "PROPERTYCLEANUP" then outputChatBox("ELE0015 Error, please report to a scripter.", thePlayer, 255, 0, 0) end end else if commandName ~= "PROPERTYCLEANUP" then outputChatBox("Elevator ID does not exist!", thePlayer, 255, 0, 0) end end end end end addCommandHandler("delelevator", deleteElevator, false, false) addCommandHandler("dele", deleteElevator, false, false) function getNearbyElevators(thePlayer, commandName) if (exports.integration:isPlayerTrialAdmin(thePlayer) or exports.integration:isPlayerSupporter(thePlayer) or exports.integration:isPlayerScripter(thePlayer)) then local posX, posY, posZ = getElementPosition(thePlayer) local dimension = getElementDimension(thePlayer) outputChatBox("Nearby Elevators:", thePlayer, 255, 126, 0) local found = false local possibleElevators = getElementsByType("elevator") for _, elevator in ipairs(possibleElevators) do local elevatorEntrance = getElementData(elevator, "entrance") local elevatorExit = getElementData(elevator, "exit") for _, point in ipairs( { elevatorEntrance, elevatorExit } ) do if (point[INTERIOR_DIM] == dimension) then local distance = getDistanceBetweenPoints3D(posX, posY, posZ, point[INTERIOR_X], point[INTERIOR_Y], point[INTERIOR_Z]) if (distance <= 11) then local dbid = getElementData(elevator, "dbid") if point == elevatorEntrance then outputChatBox(" ID " .. dbid ..", leading to dimension "..elevatorExit[INTERIOR_DIM], thePlayer, 255, 126, 0) else outputChatBox(" ID " .. dbid ..", leading to dimension "..elevatorEntrance[INTERIOR_DIM], thePlayer, 255, 126, 0) end found = true end end end end if not found then outputChatBox(" None.", thePlayer, 255, 126, 0) end end end addCommandHandler("nearbyelevators", getNearbyElevators, false, false) addCommandHandler("nearbye", getNearbyElevators, false, false) --TEMP FIX ELEVATOR FOR PLAYERS / MAXIME function fixNearbyElevator(thePlayer) local posX, posY, posZ = getElementPosition(thePlayer) local dimension = getElementDimension(thePlayer) outputChatBox("Fixing Nearby Elevators:", thePlayer, 255, 126, 0) local found = false local possibleElevators = getElementsByType("elevator") for _, elevator in ipairs(possibleElevators) do local elevatorEntrance = getElementData(elevator, "entrance") local elevatorExit = getElementData(elevator, "exit") elevator = elevator for _, point in ipairs( { elevatorEntrance, elevatorExit } ) do if (point[INTERIOR_DIM] == dimension) then local distance = getDistanceBetweenPoints3D(posX, posY, posZ, point[INTERIOR_X], point[INTERIOR_Y], point[INTERIOR_Z]) if (distance <= 11) then local dbid = getElementData(elevator, "dbid") if point == elevatorEntrance then reloadOneElevator(dbid) outputChatBox(" Fixed elevator ID " .. dbid ..", leading to int ID #"..elevatorExit[INTERIOR_DIM], thePlayer, 255, 126, 0) else reloadOneElevator(dbid) outputChatBox(" Fixed elevator ID " .. dbid ..", leading to intID #"..elevatorEntrance[INTERIOR_DIM], thePlayer, 255, 126, 0) end found = true end end end end if not found then outputChatBox(" There is no elevators around here, please get an admin to create a new one.", thePlayer, 255, 126, 0) end end addCommandHandler("fixnearbyelevators", fixNearbyElevator, false, false) addCommandHandler("fixnearbye", fixNearbyElevator, false, false) function delNearbyElevators(thePlayer, commandName) if (exports.integration:isPlayerTrialAdmin(thePlayer) or exports.integration:isPlayerSupporter(thePlayer)) then local posX, posY, posZ = getElementPosition(thePlayer) local dimension = getElementDimension(thePlayer) outputChatBox("Deleting Nearby Elevators:", thePlayer, 255, 126, 0) local found = false local possibleElevators = getElementsByType("elevator") for _, elevator in ipairs(possibleElevators) do local elevatorEntrance = getElementData(elevator, "entrance") local elevatorExit = getElementData(elevator, "exit") for _, point in ipairs( { elevatorEntrance, elevatorExit } ) do if (point[INTERIOR_DIM] == dimension) then local distance = getDistanceBetweenPoints3D(posX, posY, posZ, point[INTERIOR_X], point[INTERIOR_Y], point[INTERIOR_Z]) if (distance <= 11) then local dbid = getElementData(elevator, "dbid") if point == elevatorEntrance then if deleteElevator(thePlayer, "dele", dbid) then outputChatBox(" Elevator ID #" .. dbid .." was deleted.", thePlayer, 255, 126, 0) end else if deleteElevator(thePlayer, "dele", dbid) then outputChatBox(" Elevator ID #" .. dbid .." was deleted.", thePlayer, 255, 126, 0) end end found = true end end end end if not found then outputChatBox(" None was deleted.", thePlayer, 255, 126, 0) end end end addCommandHandler("delnearbyelevators", delNearbyElevators, false, false) addCommandHandler("delnearbye", delNearbyElevators, false, false) function delElevatorsFromInterior(thePlayer, commandName, intID) if (exports.integration:isPlayerTrialAdmin(thePlayer)) or commandName == "PROPERTYCLEANUP" then if (not tonumber(intID) or tonumber(intID)%1~= 0 ) and commandName ~= "PROPERTYCLEANUP" then outputChatBox("SYNTAX: /" .. commandName .. " [ID]", thePlayer, 255, 194, 14) outputChatBox("Deletes all elevators within an interior, Int 0 = World map.", thePlayer, 220, 170, 0) else if tonumber(intID) == 0 and not exports.integration:isPlayerSeniorAdmin(thePlayer) then outputChatBox("Only Head+ Admins can delete all elevators from world map.", thePlayer, 255,0,0) return false end if commandName ~= "PROPERTYCLEANUP" then outputChatBox("Deleting Elevators From Interior ID #"..intID..":", thePlayer, 255, 126, 0) end local found = false local query = exports.mysql:query( "SELECT `id` FROM `elevators` WHERE `dimensionwithin` = '" .. mysql:escape_string(intID).."' OR `dimension` = '" .. mysql:escape_string(intID).."'" ) if query then while true do local row = mysql:fetch_assoc(query) if not row then break end if deleteElevator(thePlayer, "PROPERTYCLEANUP", tonumber(row["id"])) then if commandName ~= "PROPERTYCLEANUP" then outputChatBox(" Elevator ID #" .. tonumber(row["id"]) .." was deleted.", thePlayer, 255, 126, 0) found = true end end end mysql:free_result(query) end if not found and commandName ~= "PROPERTYCLEANUP" then outputChatBox(" None was deleted.", thePlayer, 255, 126, 0) end end end end addCommandHandler("delefromint", delElevatorsFromInterior, false, false) addCommandHandler("delelevatorsfrominterior", delElevatorsFromInterior, false, false) addEvent( "toggleCarTeleportMode", false ) addEventHandler( "toggleCarTeleportMode", getRootElement(), function( player ) local elevatorStatus = getElementData(source, "status") local mode = ( elevatorStatus[INTERIOR_TYPE] + 1 ) % 4 local query = mysql:query_free("UPDATE elevators SET car = " .. mysql:escape_string(mode) .. " WHERE id = " .. mysql:escape_string(getElementData( source, "dbid" )) ) if query then elevatorStatus[INTERIOR_TYPE] = mode exports.anticheat:changeProtectedElementDataEx( source, "status", elevatorStatus, false ) if mode == 0 then outputChatBox( "You changed the mode to 'players only'.", player, 0, 255, 0 ) elseif mode == 1 then outputChatBox( "You changed the mode to 'players and vehicles'.", player, 0, 255, 0 ) elseif mode == 2 then outputChatBox( "You changed the mode to 'vehicles only'.", player, 0, 255, 0 ) else outputChatBox( "You changed the mode to 'no entrance'.", player, 0, 255, 0 ) end else outputChatBox( "Error 9019 - Report on Forums.", player, 255, 0, 0 ) end end ) function toggleElevator( thePlayer, commandName, id ) if exports.integration:isPlayerTrialAdmin( thePlayer ) or exports.integration:isPlayerSupporter(thePlayer) then id = tonumber( id ) if not id then outputChatBox( "SYNTAX: /" .. commandName .. " [ID]", thePlayer, 255, 194, 14 ) else local dbid, entrance, exit, status, elevatorElement = findElevator( id ) if elevatorElement then if status[INTERIOR_DISABLED] then mysql:query_free("UPDATE elevators SET disabled = 0 WHERE id = " .. mysql:escape_string(dbid) ) else mysql:query_free("UPDATE elevators SET disabled = 1 WHERE id = " .. mysql:escape_string(dbid) ) end reloadOneElevator(dbid) else outputChatBox( "Elevator not found.", thePlayer, 255, 194, 14 ) end end end end addCommandHandler( "toggleelevator", toggleElevator ) addCommandHandler( "togglee", toggleElevator ) c_elevator_system.lua addEventHandler( "onClientPlayerVehicleEnter", getLocalPlayer(), function( vehicle ) setElementData( vehicle, "groundoffset", 0.2 + getElementDistanceFromCentreOfMassToBaseOfModel( vehicle ) ) end ) addEvent( "CantFallOffBike", true ) addEventHandler( "CantFallOffBike", getLocalPlayer(), function( ) --outputDebugString("setPedCanBeKnockedOffBike") setPedCanBeKnockedOffBike( getLocalPlayer(), false ) setTimer( setPedCanBeKnockedOffBike, 5000, 1, getLocalPlayer(), true ) end )
  2. TheGUF

    [HELP]BANS

    Hi all ! Can anyone help me with a problem please!?! It doesn't work to give / sban / pban / skick! show me the error in debugscript 3 below! how can i solve ?! https://imgur.com/ySzNMpZ ban_s.lua function offlineBanAPlayer(thePlayer, commandName, targetUsername, hours, ...) if exports.integration:isPlayerTrialAdmin(thePlayer) then if not (targetUsername) or not (hours) or not tonumber(hours) or (tonumber(hours)<0) or not (...) then outputChatBox("SYNTAX: /" .. commandName .. " [Player Username] [Time in Hours, 0 = Infinite] [Reason]", thePlayer, 255, 194, 14) else hours = tonumber(hours) or 0 if (hours>168) then outputChatBox("You cannot ban for more than 7 days (168 Hours).", thePlayer, 255, 194, 14) return false end mysql/connection.lua Error 101 on starting in if (mysql_ping(forumConnection) == false) then function forumPing() if (mysql_ping(forumConnection) == false) then -- FUU, NO MOAR CONNECTION destroyForumConnection() openForumDatabase(nil) if (mysql_ping(forumConnection) == false) then logForumSQLError() return false end return true end return true end HELP ME POR FAVOR !
  3. Hi all ! I also have a problem with debugscript 3 on the server and it's hosted! why does this error occur to me continuously? please help me I'm a Beginner-Medium! ERROR: Server triggered clientside event syncFuel, but event is not added clientside ! Thank you in advance ! https://imgur.com/GBtIL9j
  4. hello everyone again, who can explain or help me to the carshop resource that I don't have npcs or cars but no error in the console ?! how can it be solved?
  5. TheGUF

    Server bug!

    Thanks for the help! but I still didn't understand what you meant? for me, the resources are arranged in alphabetical order and all are activated, so can you give me an example of help?
  6. TheGUF

    Server bug!

    Hi all ! I don't know if you encountered such a problem on your server, but I have a bug that I see for the first time, I put my server on the host's roleplay and from the beginning everything went perfectly, I was working on internal gates etc ... after a while everything disappeared from the server and there is no error given in the server I tell you that everything disappeared the interiors, npc, blips on the folder and gates and I do not know why, in the database everything is fine nothing deleted but I do not know and I did not see such a bug in the disappearance of all things on the server ?! please what's the problem help me please !
  7. Well, can't you give me a bug fix and what to put in the database?
  8. Hello friends, I came to ask you for help with errors. Go to the Ped system ?! how can it be solved? ERROR: ped-system\s_peds.lua:67: ped-system\s_peds.lua:170: attempt to index local 'animTable' (a boolean value) [string "?"] ERROR: ped-system\s_peds.lua:169: call: failed to call 'global:split' [string "?"] local tempPeds = {} local pedMoveTimer = {} local pedMoveTimerTO = {} local null = mysql_null() local toLoad = { } local threads = { } local skinsMale = {7,14,15,17,20,21,24,25,26,29,35,36,37,44,46,57,58,59,60,68,72,98,147,185,186,187,223,227,228,234,235,240,258,259} local skinsFemale = {9,11,12,40,41,55,56,69,76,88,89,91,93,129,130,141,148,150,151,190,191,192,193,194,196,211,215,216,219,224,225,226,233,263} function loadAllPeds(res) local mysql = exports.mysql local players = exports.pool:getPoolElementsByType("player") for key, value in ipairs(players) do exports.anticheat:changeProtectedElementDataEx(value, "realinvehicle", 0, false) end local result = mysql:query("SELECT id FROM `peds` ORDER BY `id` ASC") if result then while true do local row = mysql:fetch_assoc(result) if not row then break end toLoad[tonumber(row["id"])] = true end mysql:free_result(result) for id in pairs( toLoad ) do local co = coroutine.create(loadOnePed) coroutine.resume(co, id, true) table.insert(threads, co) end setTimer(resume, 1000, 4) else outputDebugString( "loadAllPeds failed" ) end end addEventHandler("onResourceStart", getResourceRootElement(), loadAllPeds) function resume() for key, value in ipairs(threads) do coroutine.resume(value) end end function reloadPed(id) local thePed = exports.pool:getElement("ped", tonumber(id)) if(thePed) then destroyElement(thePed) end loadOnePed(id, false) return true end function loadOnePed(id, hasCoroutine) local mysql = exports.mysql if (hasCoroutine==nil) then hasCoroutine = false end local row = mysql:query_fetch_assoc("SELECT * FROM peds WHERE id = " .. mysql:escape_string(id) .. " LIMIT 1" ) if row then if (hasCoroutine) then coroutine.yield() end for k, v in pairs( row ) do if v == null then row[k] = nil else row[k] = tonumber(row[k]) or row[k] end end local gender = row.gender local skin = row.skin if skin then if not gender then gender = getGenderFromSkin(skin) end else if not gender then gender = getRandomName("gender") end if(gender == 0) then skin = skinsMale[math.random(#skinsMale)] elseif(gender == 1) then skin = skinsFemale[math.random(#skinsFemale)] end end local trueSkin, trueClothing = skin, 0 if type(skin) == "string" then local yup = split(skin, ":") trueSkin = yup[1] trueClothing = yup[2] end local ped = createPed(trueSkin, row.x, row.y, row.z, row.rotation, row.synced == 1) if ped then setElementData(ped,"clothing:id", trueClothing) exports.anticheat:changeProtectedElementDataEx(ped, "dbid", row.id) exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.dbid", row.id) exports.pool:allocateElement(ped, row.id, true) setElementDimension(ped, row.dimension) setElementInterior(ped, row.interior) local pedname = row.name if not pedname then pedname = getRandomName("full", gender) end if row.type then exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.type", row.type) end exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.name", pedname) exports.anticheat:changeProtectedElementDataEx(ped, "ped:name", pedname) -- For chat system exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.gender", gender) exports.anticheat:changeProtectedElementDataEx(ped, "name", pedname) --for owl if row.nametag then exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.nametag", true) exports.anticheat:changeProtectedElementDataEx(ped, "nametag", true) --for owl end exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.behav", row.behaviour) if row.money then exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.money", row.money) else if(row.owner_type ~= 0 and row.owner ~= 0) then exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.owner_type", row.owner_type) exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.owner", row.owner) end end if(tonumber(row.frozen) == 1) then setElementFrozen(ped, true) end if row.animation then exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.animation", row.animation) local animTable = exports.global:split(row.animation, ";") local animBlock = animTable[1] local anim = animTable[2] if animBlock and anim then setPedAnimation(ped, animBlock, anim) end end local badges = {} badges = exports['item-system']:getBadges() for k,v in pairs(badges) do local hasItem = exports['item-system']:hasItem(ped, k) if hasItem then local itemresult = exports['item-system']:npcUseItem(ped, k) break; end end local masks = {} masks = exports['item-system']:getMasks() for k,v in pairs(masks) do local hasItem = exports['item-system']:hasItem(ped, k) if hasItem then local itemresult = exports['item-system']:npcUseItem(ped, k) break; end end exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.createdBy", row.created_by) exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.createdByUsername", exports.global:getUserNameFromID(row.created_by)) exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.createdAt", row.created_at) exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.comment", row.comment) exports.anticheat:changeProtectedElementDataEx(ped, "rpp.npc.synced", tonumber(row.synced) == 1 or false) end end end function savePed(id) local mysql = exports.mysql if id then local thePed = exports.pool:getElement("ped", tonumber(id)) if thePed then local money = getElementData(thePed, "rpp.npc.money") if money then local query = mysql:query_free("UPDATE peds SET money = '" .. mysql:escape_string(money) .. "' WHERE id='" .. mysql:escape_string(id) .. "'") if query then return true end end end end return false end function healByHospitalPed(ped) local pedname = tostring(getElementData(ped, "rpp.npc.name")) local playername = tostring(getPlayerNametagText(source)) local health = getElementHealth(source) local needed = 100 - tonumber(health) if(needed < 5) then exports.RPPchat:chatPed(ped, "say", "You seem to be fine, sir. No treatment needed.") else local cost = math.ceil(1 * needed) if(getPlayerMoney(source) > cost or getPlayerMoney(source) == cost) then local newHealth = health + needed exports.RPPchat:chatMe(source, false, "takes out a wallet and hands a few dollar notes to "..pedname) exports.RPPchat:chatPed(ped, "me", "takes the money") takePlayerMoney(source, tonumber(cost)) exports.RPPchat:chatPed(ped, "say", "Thank you sir. I'll get you fixed up.") exports.RPPchat:chatPed(ped, "me", "heals "..playername) setElementHealth(source, newHealth) else exports.RPPchat:chatMe(source, false, "takes out a wallet and hands a few dollar notes to "..pedname) exports.RPPchat:chatPed(ped, "say", "Sorry sir. I don't think that is enough.") end end end addEvent("clientHealByNPC", true) addEventHandler("clientHealByNPC", getRootElement(), healByHospitalPed) function reloadWeaponForPed(ped) if ped then reloadPedWeapon(ped) end end addEvent("clientReloadPedWeapon", true) addEventHandler("clientReloadPedWeapon", getRootElement(), reloadWeaponForPed) function makeTempPed(thePlayer, command, behav, gender, skin, name) --create temporary ped (no dbid) if exports.integration:isPlayerTrialAdmin(thePlayer) then if not behav then behav = 1 else behav = tonumber(behav) end if(gender == "male") then gender = 0 elseif(gender == "female") then gender = 1 end if(gender ~= 1 and gender ~= 0) then gender = getRandomName("gender") end if not skin then if(gender == 0) then skin = skinsMale[math.random(#skinsMale)] elseif(gender == 1) then skin = skinsFemale[math.random(#skinsFemale)] end end local x,y,z = getElementPosition(thePlayer) local rx,ry,rz = getElementRotation(thePlayer) local int = getElementInterior(thePlayer) local dim = getElementDimension(thePlayer) local i = #tempPeds + 1 tempPeds[i] = createPed(skin, x, y, z, rz, false) outputConsole("PED: "..tostring(skin)..","..tostring(x)..","..tostring(y)..","..tostring(z)..","..tostring(rz),thePlayer) setElementInterior(tempPeds[i], int) setElementDimension(tempPeds[i], dim) if name then local splitname = exports.global:split(name, "_") if(#splitname >= 2) then name = splitname[1].." "..splitname[2] end else name = getRandomName("full",gender) end setElementData(tempPeds[i], "dbid", -i) setElementData(tempPeds[i], "rpp.npc.dbid", -i) setElementData(tempPeds[i], "rpp.npc.name", tostring(name)) setElementData(tempPeds[i], "rpp.npc.nametag", true) setElementData(tempPeds[i], "rpp.npc.behav", tostring(behav)) setElementData(tempPeds[i], "rpp.npc.spawnpos", {x, y, z, rz, int, dim}) setElementData(tempPeds[i], "rpp.npc.spawnpos2", tostring(x)..","..tostring(y)..","..tostring(z)..","..tostring(rz)..","..tostring(int)..","..tostring(dim)) if(behav == 2) then giveWeapon(tempPeds[i], 22) setPedStat(tempPeds[i], 69, 999) setPedStat(tempPeds[i], 76, 999) end if(behav == 5) then local shape = createMarker(x, y, z, "cylinder", 20) setMarkerColor(shape, 0, 0, 0, 0) local result = addEventHandler("onMarkerHit", shape, npcEnterPCT) attachElements(shape, tempPeds[i], 0, 0, -1, 0, 0, 0) end end end addCommandHandler("ped", makeTempPed) function createPermPed(thePlayer, command, interact) if exports.integration:isPlayerTrialAdmin(thePlayer) then local mysql = exports.mysql local x,y,z = getElementPosition(thePlayer) local rx,ry,rz = getElementRotation(thePlayer) local int = getElementInterior(thePlayer) local dim = getElementDimension(thePlayer) local name = "Unnamed Ped" local behav = 1 local gender = 0 local skin = 264 local userID = getElementData(thePlayer, "account:id") if not interact then interact = "" end mysql:query_free("INSERT INTO `peds` (`name`, `type`, `x`, `y`, `z`, `rotation`, `interior`, `dimension`, `skin`, `gender`, `created_by`, `created_at`) VALUES ('"..name.."', '"..mysql:escape_string(interact).."', '"..x.."', '"..y.."', '"..z.."', '"..rz.."', '"..int.."', '"..dim.."', '"..skin.."', '"..gender.."', '"..userID.."', NOW());") local insertid = mysql:insert_id() setElementPosition(thePlayer, x+0.5, y, z) loadOnePed(insertid) end end addCommandHandler("makeped", createPermPed) function pedMoveTowardsElement(ped, element) local x,y,z = getElementPosition(element) local px,py,pz = getElementPosition(ped) local rot = 0 if ( x >= px ) and ( y > py ) then -- north-east rot = 90 - rot elseif ( x <= px ) and ( y > py ) then -- north-west rot = 270 + rot elseif ( x >= px ) and ( y <= py ) then -- south-east rot = 90 + rot elseif ( x < px ) and ( y <= py ) then -- south-west rot = 270 - rot end setPedRotation(ped, rot) --setPedLookAt(ped, x, y, z + 0.5) setPedAnimation(ped, "ped", "run_civi", -1, true, true, true, true) end function pedMoveTowardsCoordinates(ped, x, y, z, px, py, pz) --local x,y,z = getElementPosition(element) if not px and py and pz then px,py,pz = getElementPosition(ped) end local rot = 0 if ( x >= px ) and ( y > py ) then -- north-east rot = 90 - rot elseif ( x <= px ) and ( y > py ) then -- north-west rot = 270 + rot elseif ( x >= px ) and ( y <= py ) then -- south-east rot = 90 + rot elseif ( x < px ) and ( y <= py ) then -- south-west rot = 270 - rot end setPedRotation(ped, rot) --setPedLookAt(ped, x, y, z + 0.5) setPedAnimation(ped, "ped", "run_civi", -1, true, true, true, true) end function pedMoveTimeout(ped) --outputDebugString("timeout") killTimer(pedMoveTimer[ped]) pedMoveTimer[ped] = nil setPedAnimation(ped) pedMoveTimerTO[ped] = nil end function pedMoveToTram(ped, tram) --outputDebugString("pedMoveToTram") x,y,z = getElementPosition(tram) px,py,pz = getElementPosition(ped) local distance = getDistanceBetweenPoints3D(x, y, z, px, py, pz) --if distance > 20 then -- outputDebugString("moving") -- pedMoveTowardsCoordinates(ped, x, y, z, px, py, pz) --else --outputDebugString("close enough") killTimer(pedMoveTimerTO[ped]) pedMoveTimerTO[ped] = nil killTimer(pedMoveTimer[ped]) pedMoveTimer[ped] = nil setPedAnimation(ped) exports.trams:npcEnterTramPassenger(ped, tram) --end end function npcEnterPCT(hitElement, matchingDimension, marker) if not source then source = marker end --outputDebugString("triggered") if matchingDimension then if(getElementType(hitElement) == "vehicle") then if(getElementModel(hitElement) == 449) then outputDebugString("is tram") if(getVehicleController(hitElement)) then if(getResourceState(getResourceFromName("trams")) == "running") then outputDebugString("all good") local ped = getElementParent(source) pedMoveTimer[ped] = setTimer(pedMoveToTram, 100, 0, ped, hitElement) pedMoveTimerTO[ped] = setTimer(pedMoveTimeout, 10000, 1, ped) end end end end end end function respawnPed(player, ped) if(getElementType(ped) == "ped") then if getElementData(ped, "dbid") then local dbid = getElementData(ped, "dbid") --if(ped == exports.pool:getElement("ped", tonumber(dbid))) then --extra security check local result = reloadPed(tonumber(dbid)) if result then outputDebugString("Successfully respawned ped with dbid "..tostring(dbid)) return true else outputDebugString("Failed to respawn ped with dbid "..tostring(dbid).." (#2)") return false end --else -- outputDebugString("Failed to respawn ped with dbid "..tostring(dbid).." (#1) ("..tostring(ped).." = "..tostring(exports.pool:getElement("ped", tonumber(dbid)))..")") -- return false --end elseif getElementData(ped, "rpp.npc.spawnpos") then local spawnpos = getElementData(ped, "rpp.npc.spawnpos") new = createPed(getElementModel(ped),spawnpos[1],spawnpos[2],spawnpos[3],spawnpos[4]) setPedRotation(new, spawnpos[4]) setElementInterior(new, tonumber(spawnpos[5])) setElementDimension(new, tonumber(spawnpos[6])) elseif getElementData(ped, "rpp.npc.spawnpos2") then local posstring = getElementData(ped, "rpp.npc.spawnpos2") local pos = exports.global:split(posstring, ",") new = createPed(getElementModel(ped),pos[1],pos[2],pos[3],pos[4]) setPedRotation(new, getElementData(ped,"rotation")) setElementInterior(new, tonumber(pos[5])) setElementDimension(new, tonumber(pos[6])) else new = createPed(getElementModel(ped),getElementPosition(ped)) local rz, ry, rx = getElementRotation(ped) setElementRotation(new, rz, ry, rx) setElementInterior(new, getElementInterior(ped)) setElementDimension(new, getElementDimension(ped)) end for k, v in next, getAllElementData(ped) do exports.anticheat:changeProtectedElementDataEx(new, k, v) end exports.anticheat:changeProtectedElementDataEx(new, "activeConvo", 0) destroyElement(ped) --destroy old ped --[[ local posstring = getElementData(ped, "rpp.npc.spawnpos") if posstring then local pos = exports.global:split(posstring, ",") local nametag = getElementData(ped, "rpp.npc.nametag") local name if nametag == "true" then name = getElementData(ped, "rpp.npc.name") end local behav = getElementData(ped, "rpp.npc.behav") local ptype = getElementData(ped, "rpp.npc.type") local fuelPriceratio if(ptype == "fuel") then fuelPriceratio = getElementData(ped, "fuel:priceratio") end local skin = getElementModel(ped) local newPed = createPed(skin, pos[1], pos[2], pos[3], pos[4], false) if newPed then if nametag and name then setElementData(newPed, "rpp.npc.name", tostring(name)) setElementData(newPed, "rpp.npc.nametag", "true") end setElementData(newPed, "rpp.npc.behav", tostring(behav)) setElementData(newPed, "rpp.npc.type", tostring(ptype)) if(ptype == "fuel") then setElementData(newPed, "fuel:priceratio", tostring(fuelPriceratio)) end destroyElement(ped) --destroy old ped end end --]] end end addEvent("peds:respawnPed", true) addEventHandler("peds:respawnPed", getRootElement(), respawnPed) function healPed(player, ped) if(getElementType(ped) == "ped") then local factionType = getElementData(getPlayerTeam(player), "type") if not (factionType==4) then outputChatBox("You have no basic medic skills, contact the ES.", player, 255, 0, 0) else local foundkit, slot, itemValue = exports.global:hasItem(player, 70) if foundkit then if isPedDead(ped) then respawnPed(player, ped) else setElementHealth(ped, 100) local name = getPlayerName(player) local pedName = getElementData(ped, "rpp.npc.name") local message if pedName then message = "opens his medical kit and treats "..tostring(pedName) else message = "opens his medical kit and treats the person" end exports.global:sendLocalText(source, " *" .. string.gsub(name, "_", " ").. ( message:sub( 1, 1 ) == "'" and "" or " " ) .. message, 255, 51, 102) if itemValue > 1 then exports['item-system']:updateItemValue(player, slot, itemValue - 1) else exports.global:takeItem(thePlayer, 70, itemValue) if not exports.global:hasItem(thePlayer, 70) then outputChatBox("Warning, you're out of first aid kits. re /duty to get new ones.", player, 255, 0, 0) end end local tax = exports.global:getTaxAmount() local price = 100 exports.global:giveMoney( exports.factions:getTeamFromFactionID(2), math.ceil((1-tax)*price) ) exports.global:giveMoney( exports.factions:getTeamFromFactionID(3), math.ceil(tax*price) ) if pedName then outputChatBox("You healed " ..pedName.. " (NPC).", player, 0, 255, 0) else outputChatBox("You healed a NPC.", player, 0, 255, 0) end exports.logs:dbLog(player, 35, ped, "HEAL NPC FOR $" .. price) end else outputChatBox("You need a first aid kit to heal people.", player, 255, 0, 0) end end end end addEvent("peds:healPed", true) addEventHandler("peds:healPed", getRootElement(), healPed) local allowedFunctionPeds = { --["function"] = true/false } function deletePed(player, ped) if(getElementType(ped) == "ped") then if exports.integration:isPlayerAdmin(player) then local dbid = tonumber(getElementData(ped, "rpp.npc.dbid")) or 0 if dbid > 0 then local pedFunction = getElementData(ped, "rpp.npc.type") if pedFunction then --if(allowedFunctionPeds[pedFunction] or exports.global:isPlayerHeadAdmin(player)) then deleteDbPed(player, dbid, ped) --end else deleteDbPed(player, dbid, ped) end else local pedName = getElementData(ped, "rpp.npc.name") if not pedName then pedName = getElementData(ped, "name") end if not pedName then pedName = "Unnamed" end destroyElement(ped) exports.global:sendMessageToAdmins("[Peds] Temp NPC '"..tostring(pedName).."' was deleted by " .. getPlayerName(player) .. ".") end end end end addEvent("peds:deletePed", true) addEventHandler("peds:deletePed", getRootElement(), deletePed) function deleteDbPed(player, pedID, ped) local mysql = exports.mysql if exports.integration:isPlayerTrialAdmin(player) then if not ped then ped = exports.global:getPoolElement("ped", pedID) end if not ped then outputChatBox("Ped not found!", player, 255, 0, 0) return false end local pedType = getElementData(ped, "rpp.npc.type") if pedType then if(not allowedFunctionPeds[pedFunction]) then if not exports.integration:isPlayerAdmin(player) then outputChatBox("Only Admin+ can delete this ped type.", player, 255, 0, 0) return false end end end mysql:query_free("DELETE FROM peds WHERE id='"..mysql:escape_string(pedID).."'") destroyElement(ped) else outputChatBox("Only admins can delete permanent peds.", player, 255, 0, 0) end end function savePedToDB(arguments, element) if exports.integration:isPlayerTrialAdmin(source) then local mysql = exports.mysql local dbid = tonumber(arguments[1]) or false --argument = {} --for i = 1, #arguments do -- 16 arguments -- argument[i] = mysql:escape_string(arguments[i]) --end local keys = {"dbid", "name", "type", "behaviour", "x", "y", "z", "rotation", "interior", "dimension", "skin", "animation", "synced", "nametag", "frozen", "comment"} if dbid then argument = {} for i = 1, #arguments do local v = arguments[i] if(type(v) == "boolean" and not v) then argument[i] = "NULL" elseif(type(v) == "boolean" and v) then argument[i] = "'1'" elseif(type(v) == "string") then argument[i] = "'"..mysql:escape_string(v).."'" elseif(type(v) == "number") then argument[i] = "'"..tostring(v).."'" else outputChatBox("Error saving ped (invalid value '"..tostring(v).."' for '"..tostring(keys[i]).."').", source, 255, 0, 0) return end end --outputConsole("UPDATE peds SET id="..argument[1]..", name="..argument[2]..", type="..argument[3]..", behaviour="..argument[4]..", x="..argument[5]..", y="..argument[6].."', z="..argument[7].."', rotation="..argument[8].."', interior="..argument[9]..", dimension="..argument[10]..", skin="..argument[11]..", animation="..argument[12]..", synced="..argument[13]..", nametag="..argument[14]..", frozen="..argument[15]..", comment="..argument[16]..";", source) mysql:query_free("UPDATE peds SET name="..argument[2]..", type="..argument[3]..", behaviour="..argument[4]..", x="..argument[5]..", y="..argument[6]..", z="..argument[7]..", rotation="..argument[8]..", interior="..argument[9]..", dimension="..argument[10]..", skin="..argument[11]..", animation="..argument[12]..", synced="..argument[13]..", nametag="..argument[14]..", frozen="..argument[15]..", comment="..argument[16].." WHERE id="..argument[1]..";") --outputDebugString("behaviour="..tostring(argument[4])) --outputDebugString("(frozen="..tostring(arguments[15])..")") --outputDebugString("frozen="..tostring(argument[15])) outputChatBox("Updated ped #"..tostring(argument[1]).." in the database.", source, 0, 255, 0) reloadPed(dbid) return elseif(not dbid and element) then local name = arguments[2] local pedType = arguments[3] local behaviour = arguments[4] local x = arguments[5] local y = arguments[6] local z = arguments[7] local rotation = arguments[8] local interior = arguments[9] local dimension = arguments[10] local skin = arguments[11] local animation = arguments[12] local synced = arguments[13] local nametag = arguments[14] local frozen = arguments[15] == 1 local comment = arguments[16] if not gender then gender = getRandomName("gender") end if not skin then if(gender == 0) then skin = skinsMale[math.random(#skinsMale)] elseif(gender == 1) then skin = skinsFemale[math.random(#skinsFemale)] end end if type(skin) == "string" then local yup = split(skin, ":") setElementModel(element, yup[1]) setElementData(element,"clothing:id", yup[2]) elseif type(skin) == "number" then setElementModel(element, skin) setElementData(element,"clothing:id", 0) end setElementPosition(element, x, y, z) setElementInterior(element, interior) setElementDimension(element, dimension) setElementRotation(element, 0, 0, rotation) if not name then name = getRandomName("full",gender) end setElementData(element, "rpp.npc.name", tostring(name)) setElementData(element, "rpp.npc.nametag", nametag) setElementData(element, "rpp.npc.behav", behaviour) setElementData(element, "rpp.npc.spawnpos", {x, y, z, rotation, interior, dimension}) setElementData(element, "rpp.npc.spawnpos2", tostring(x)..","..tostring(y)..","..tostring(z)..","..tostring(rotation)..","..tostring(interior)..","..tostring(dimension)) setElementData(element, "rpp.npc.comment", comment) if(behav == 2) then giveWeapon(element, 22) setPedStat(element, 69, 999) setPedStat(element, 76, 999) else end --[[if(behav == 5) then local shape = createMarker(x, y, z, "cylinder", 20) setMarkerColor(shape, 0, 0, 0, 0) local result = addEventHandler("onMarkerHit", shape, npcEnterPCT) --outputDebugString(tostring(result).." ("..tostring(shape)..")") attachElements(shape, tempPeds[i], 0, 0, -1, 0, 0, 0) end--]] setElementFrozen(element, frozen) outputChatBox("Updated the temporary ped.", source, 0, 255, 0) else outputChatBox("No ped to edit.", source, 255, 0, 0) end end end addEvent("peds:saveeditped", true) addEventHandler("peds:saveeditped", getRootElement( ), savePedToDB) function hideMyID(thePlayer, command) if(exports.integration:isPlayerScripter(thePlayer)) then local hideMyID = getElementData(thePlayer, "hidemyid") if hideMyID then setElementData(thePlayer, "hidemyid", false) outputChatBox("Showing ID",thePlayer) else setElementData(thePlayer, "hidemyid", true) outputChatBox("Hiding ID",thePlayer) end end end addCommandHandler("hidemyid", hideMyID) function giveFakeName(thePlayer, command) if(exports.integration:isPlayerScripter(thePlayer)) then local fakename = getElementData(thePlayer, "fakename") if fakename then setElementData(thePlayer, "fakename", false) outputChatBox("Fake name removed.",thePlayer) else local gender = tonumber(getElementData("gender",thePlayer)) or 0 local fakenameName = getRandomName("full", gender) setElementData(thePlayer, "fakename", tostring(fakenameName)) outputChatBox("Fake name set to "..tostring(fakenameName)..".",thePlayer) end end end addCommandHandler("givemefakename", giveFakeName) please help me, I will be very grateful if you will help me !
  9. I found out that in the database to work /ads you have to enter the following codes ! -- -------------------------------------------------------- -- -- Structura de tabel pentru tabelul `advertisements` -- CREATE TABLE `advertisements` ( `id` int(11) NOT NULL, `phone` varchar(10) NOT NULL, `name` varchar(50) NOT NULL, `address` varchar(100) NOT NULL, `advertisement` text NOT NULL, `start` int(11) NOT NULL, `expiry` int(11) NOT NULL, `created_by` int(11) NOT NULL, `section` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Salvarea datelor din tabel `advertisements` -- INSERT INTO `advertisements` (`id`, `phone`, `name`, `address`, `advertisement`, `start`, `expiry`, `created_by`, `section`) VALUES -- -------------------------------------------------------- -- -- Indexes for table `advertisements` -- ALTER TABLE `advertisements` ADD PRIMARY KEY (`id`); -- -- AUTO_INCREMENT for table `advertisements` -- ALTER TABLE `advertisements` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=697; I put it in and when I gave /ads it tells me to wait 2 hours to place an ad! I gave /forcepaydayall to have 2 hours and when I give /ads again I get this error in the console ?! ERROR: advertisements\advertisements.Lua:187: bad argument #1 to 'ipairs' (table expected, got boolean) ERROR: advertisements\advertisements.Lua:187: call: failed to call 'mysql:select' [string "?"] how can i solve ?! please help me !
  10. local SCREEN_X, SCREEN_Y = guiGetScreenSize() local resourceName = getResourceName( getThisResource( ) ) local ONE_HOUR = 3600 local SERVICES_SECTION = 1 --Places to offer services such as house cleaning or mechanics and whatnot local CARS_VEHICLES_SECTION = 2 --Offer to buy or sell a vehicle in this section local REAL_ESTATE_SECTION = 3 --Houses for sale go in this section local COMMUNITY_SECTION = 4 --Advertisements about communities can go here, for example, palomino creek. local JOBS_SECTION = 5 --Advertisements about hiring people or looking for work will go in this section local PERSONALS_SECTION = 6 --People looking for other people go in this section local sections = { "Servicii", "Vehicule", "Proprietăți", "Communitate", "Slujbe", "Personal" } local deleteAny = false local window = { } local viewad = {} local postad = {} function getTime( day, month, timestamp ) local months = { "Ianuarie", "Februarie", "Martie", "Aprile", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octobrie", "Niembrie", "Decembrie" } local days = { "Sâmbătă", "Luni", "Marți", "Miercuri", "Joi", "Vineri", "Duminică" } local time = nil local ts = nil if timestamp then time = getRealTime( timestamp ) else time = getRealTime( ) end ts = ( tonumber( time.hour ) >= 12 and tostring( tonumber( time.hour ) - 12 ) or time.hour ) .. ":"..("%02d"):format(time.minute)..( tonumber( time.hour ) >= 12 and " PM" or " AM" ) if month then ts = months[ time.month + 1 ] .. " ".. time.monthday .. ", " .. ts end if day then ts = days[ time.weekday + 1 ].. ", " .. ts end return ts end addEvent( resourceName .. ":ad_create_fail", true ) addEventHandler( resourceName .. ":ad_create_fail", root, function() local window = { } --Store all of our window elements local width = 230 -- The width of our window local height = 110 -- The height of our window local x = SCREEN_X / 2 - width / 2 --Where on the screen our window will be located local y = SCREEN_Y / 2 - height / 2 window.window = guiCreateWindow( x, y, width, height, "Eroare de creatie", false ) --Create the window. window.errorLabel = guiCreateLabel( 10, 30, width - 20, 20, "A fost o eroare la introducere.", false, window.window ) window.closeButton = guiCreateButton( 10, 60, width - 20, 40, "Ieși", false, window.window ) addEventHandler( "onClientGUIClick", window.closeButton, function () guiSetVisible( window.window, false ) destroyElement( window.window ) window = { } end ) end ) function createAdvertisement( ) closePostAd() if window and window.window and isElement(window.window) then guiSetEnabled(window.window, false) end guiSetInputEnabled ( true ) local window = { } -- Store all of our window elements local width = 400 -- The width of our window local height = 440 -- The height of our window local x = SCREEN_X / 2 - width / 2 --Where on the screen our window will be located local y = SCREEN_Y / 2 - height / 2 postad.window = guiCreateWindow( x, y, width, height, "Crează Reclamă", false ) --Create the postad. postad.label = { } --This will hold our label elements local labels = { "Telefon", "Nume", "Adresă", "Expiră", "Secțiune", "Reclamă" } --This holds all of the labels we will create here local y = 35 --We'll set y to 30, which is the y coordinate of where our first label will go. for label = 1, #labels do postad.label[ label ] = guiCreateLabel( 10, y * label, 100, 30, labels[ label ], false, postad.window ) end postad.input = { } -- Will hold all of our input elements. y = 30 -- We'll start y off at 25 here to stay even with the inputs. postad.input[ 1 ] = guiCreateEdit( 100, y, width - 120, 30, "", false, postad.window ) --Phone input y = y + 35 postad.input[ 2 ] = guiCreateEdit( 100, y, width - 120, 30, "", false, postad.window ) --Name Input y = y + 35 postad.input[ 3 ] = guiCreateEdit( 100, y, width - 120, 30, "", false, postad.window ) --Address input y = y + 40 postad.input[ 4 ] = guiCreateComboBox( 100, y, width - 120, 95, "", false, postad.window ) --Expiry guiComboBoxAddItem( postad.input[ 4 ], "1 oră" ) guiComboBoxAddItem( postad.input[ 4 ], "2 ore" ) guiComboBoxAddItem( postad.input[ 4 ], "6 ore" ) guiComboBoxAddItem( postad.input[ 4 ], "O zi" ) y = y + 34 postad.input[ 5 ] = guiCreateComboBox( 100, y, width - 120, 125, "", false, postad.window ) --Section for i = 1, #sections do --Loop through each of the 6 advertisement sections. guiComboBoxAddItem( postad.input[ 5 ], sections[ i ] ) end postad.input[ 6 ] = guiCreateMemo( 10, y + 60, width - 20, 90, "", false, postad.window ) --Advertisement for i = 1, 6 do addEventHandler(getElementType( postad.input[i] ) == 'gui-combobox' and 'onClientGUIComboBoxAccepted' or 'onClientGUIChanged', postad.input[i], function( ) for i = 1, 6 do if getElementType( postad.input[i] ) == 'gui-combobox' then if guiComboBoxGetSelected( postad.input[i] ) == -1 then guiSetEnabled( postad.postButton, false ) return end else local text = ( guiGetText( postad.input[i] ) or '' ):gsub("\n", ''):gsub("\r", '') if #text == 0 then guiSetEnabled( postad.postButton, false ) return end end end guiSetEnabled( postad.postButton, true ) end, false ) end postad.postButton = guiCreateButton( 10, height - 100, width - 20, 40, "Postează Reclamă", false, postad.window ) guiSetEnabled( postad.postButton, false ) addEventHandler( "onClientGUIClick", postad.postButton, function () local phone = guiGetText( postad.input[ 1 ] ) or "" local name = guiGetText( postad.input[ 2 ] ) or "" local address = guiGetText( postad.input[ 3 ] ) or "" local advertisement = guiGetText( postad.input[ 6 ] ) local expirySelected = guiComboBoxGetSelected( postad.input[ 4 ] ) local expires = nil if expirySelected == -1 or expirySelected == 0 then expires = ONE_HOUR elseif expirySelected == 1 then expires = ONE_HOUR * 2 elseif expirySelected == 2 then expires = ONE_HOUR * 6 else expires = ONE_HOUR * 24 end local section = tostring( guiComboBoxGetSelected( postad.input[ 5 ] ) + 1 ) closePostAd() triggerServerEvent( resourceName .. ":create_advertisement", getLocalPlayer(), phone, name, address, advertisement, expires, section ) end , false ) postad.closeButton = guiCreateButton( 10, height - 50, width - 20, 40, "Ieși", false, postad.window ) addEventHandler( "onClientGUIClick", postad.closeButton, function () if source == postad.closeButton then closePostAd() end end , false ) end addCommandHandler( "postad", createAdvertisement, false, false ) function closePostAd() if postad and postad.window and isElement(postad.window) then guiSetInputEnabled ( false ) destroyElement( postad.window ) postad = { } if window and window.window and isElement(window.window) then guiSetEnabled(window.window, true) else showCursor( false, false ) end end end function viewAdvertisement( advertisement ) closeViewAd() if window and window.window and isElement(window.window) then guiSetEnabled(window.window, false) end guiSetInputEnabled ( false ) local window = { } local width = 400 local height = 530 local x = SCREEN_X / 2 - width / 2 local y = SCREEN_Y / 2 - height / 2 viewad.window = guiCreateWindow( x, y, width, height, "Vezi reclamă", false ) viewad.label = { } local labels = { "Telefon", "Nume", "Adresă", "Start", "Expiră", "Secțiune", "Reclamă" } local y = 35 for label = 1, #labels do viewad.label[ label ] = guiCreateLabel( 10, y * label, 100, 30, labels[ label ], false, viewad.window ) end viewad.input = { } y = 30 viewad.input[ 1 ] = guiCreateEdit( 100, y, width - 120, 30, advertisement.phone, false, viewad.window ) guiEditSetReadOnly( viewad.input[ 1 ], true ) y = y + 35 viewad.input[ 2 ] = guiCreateEdit( 100, y, width - 120, 30, advertisement.name, false, viewad.window ) guiEditSetReadOnly( viewad.input[ 2 ], true ) y = y + 35 viewad.input[ 3 ] = guiCreateEdit( 100, y, width - 120, 30, advertisement.address, false, viewad.window ) guiEditSetReadOnly( viewad.input[ 3 ], true ) y = y + 35 viewad.input[ 4 ] = guiCreateEdit( 100, y, width - 120, 30, getTime( true, true, advertisement.start ), false, viewad.window ) guiEditSetReadOnly( viewad.input[ 4 ], true ) y = y + 35 viewad.input[ 5 ] = guiCreateEdit( 100, y, width - 120, 30, getTime( true, true, advertisement.expiry ), false, viewad.window ) guiEditSetReadOnly( viewad.input[ 5 ], true ) y = y + 35 viewad.input[ 6 ] = guiCreateEdit( 100, y, width - 120, 30, sections[ tonumber( advertisement.section ) ], false, viewad.window ) guiEditSetReadOnly( viewad.input[ 6 ], true ) viewad.input[ 7 ] = guiCreateMemo( 10, y + 60, width - 20, 90, advertisement.advertisement, false, viewad.window ) guiMemoSetReadOnly( viewad.input[ 7 ], true ) if tonumber( getElementData( localPlayer, "dbid" ) ) == tonumber( advertisement.created_by ) or deleteAny then guiCreateLabel( 100, 245, 200, 25, "Creat de: " .. advertisement.author:gsub("_", " "), false, viewad.window ) viewad.pushButton = guiCreateButton( 10, height - 150, width - 20, 40, "Trimite reclama ($100)", false, viewad.window ) if tonumber( getElementData( localPlayer, "dbid" ) ) ~= tonumber( advertisement.created_by ) then guiSetProperty( viewad.pushButton, 'NormalTextColour', 'FFFF0000' ) end addEventHandler( "onClientGUIClick", viewad.pushButton, function () triggerServerEvent( resourceName .. ":push_advertisement", localPlayer, advertisement.id ) end , false ) end if tonumber( getElementData( localPlayer, "dbid" ) ) == tonumber( advertisement.created_by ) or deleteAny then viewad.deleteButton = guiCreateButton( 10, height - 100, width - 20, 40, "Șterge Reclamă", false, viewad.window ) if tonumber( getElementData( localPlayer, "dbid" ) ) ~= tonumber( advertisement.created_by ) then guiSetProperty( viewad.deleteButton, 'NormalTextColour', 'FFFF0000' ) end addEventHandler( "onClientGUIClick", viewad.deleteButton, function () closeViewAd() triggerServerEvent( resourceName .. ":delete_advertisement", localPlayer, advertisement.id ) end , false ) end viewad.closeButton = guiCreateButton( 10, height - 50, width - 20, 40, "Ieși", false, viewad.window ) addEventHandler( "onClientGUIClick", viewad.closeButton, function () if source == viewad.closeButton then closeViewAd() end end , false ) end function closeViewAd() if viewad and viewad.window and isElement(viewad.window) then guiSetInputEnabled ( false ) guiSetVisible( viewad.window, false ) destroyElement( viewad.window ) viewad = { } if window and window.window and isElement(window.window) then guiSetEnabled(window.window, true) else showCursor( false, false ) end end end addEvent( resourceName .. ":display_all", true ) addEventHandler( resourceName .. ":display_all", root, function( advertisements, canDeleteAnyAd ) closeAds() deleteAny = canDeleteAnyAd showCursor( true, true ) local width = 500 local height = 500 local x = SCREEN_X / 2 - width / 2 local y = SCREEN_Y / 2 - height / 2 window.window = guiCreateWindow( x, y, width, height, "Reclame", false ) window.closeButton = guiCreateButton( 10, 30, width - 20, 40, "Creează Reclamă", false, window.window ) addEventHandler( "onClientGUIClick", window.closeButton, function () createAdvertisement( ) end , false ) window.mainPanel = guiCreateTabPanel ( 10, 90, width - 15, height - 150, false, window.window ) window.tab = { } window.table = { } window.colPhone = { } window.colName = { } window.colAd = { } for i = 1, #sections do window.tab[ i ] = guiCreateTab( sections[ i ], window.mainPanel ) window.table[ i ] = guiCreateGridList ( 10, 10, width - 35, height - 190, false, window.tab[ i ] ) window.colPhone[ i ]= guiGridListAddColumn( window.table[ i ], "Telefon", 0.2 ) window.colName[ i ] = guiGridListAddColumn( window.table[ i ], "Nume", 0.2 ) window.colAd[ i ] = guiGridListAddColumn( window.table[ i ], "Reclamă", 0.5 ) for ad = 1, #advertisements do if tonumber( advertisements[ ad ].section ) == i then local row = guiGridListAddRow ( window.table[ i ] ) guiGridListSetItemText( window.table[ i ], row, window.colPhone[ i ], advertisements[ ad ].phone, false, false ) guiGridListSetItemText( window.table[ i ], row, window.colName[ i ], advertisements[ ad ].name, false, false ) guiGridListSetItemText( window.table[ i ], row, window.colAd[ i ], advertisements[ ad ].advertisement, false, false ) guiGridListSetItemData( window.table[ i ], row, window.colPhone[ i ], ad ) addEventHandler( "onClientGUIDoubleClick", window.table[ i ], function ( button, state ) if button == 'left' and state == 'up' and window and window.table then local selectedRow, selectedCol = guiGridListGetSelectedItem( window.table[ i ] ) local key = guiGridListGetItemData( window.table[ i ], selectedRow, window.colPhone[ i ] ) if advertisements[ key ] then viewAdvertisement( advertisements[ key ] ) end end end , false ) end end if guiGridListGetRowCount( window.table[ i ] ) == 0 then local row = guiGridListAddRow ( window.table[ i ] ) guiGridListSetItemText ( window.table[ i ], row, window.colPhone[ i ], "Nici-o reclamă", false, false ) end end window.closeButton = guiCreateButton( 10, height - 50, width - 20, 40, "Ieși", false, window.window ) addEventHandler( "onClientGUIClick", window.closeButton, function () if source == window.closeButton then closeAds() end end , false ) end ) function closeAds() if window and window.window and isElement(window.window) then showCursor( false, false ) destroyElement( window.window ) window = { } closePostAd() end end local SERVICES_SECTION = 1 --Places to offer services such as house cleaning or mechanics and whatnot local CARS_VEHICLES_SECTION = 2 --Offer to buy or sell a vehicle in this section local REAL_ESTATE_SECTION = 3 --Houses for sale go in this section local COMMUNITY_SECTION = 4 --Advertisements about communities can go here, for example, palomino creek. local JOBS_SECTION = 5 --Advertisements about hiring people or looking for work will go in this section local PERSONALS_SECTION = 6 --People looking for other people go in this section local COOLDOWN_MINUTES = 5 --Number of minutes between push alerts being sent by players local resourceName = getResourceName( getThisResource( ) ) local sections = { "Servicii", "Vehicule", "Proprietăți", "Communitate", "Slujbe", "Personal" } function escape( value ) return exports.mysql:escape_string( value ) end function now( ) return tonumber( getRealTime().timestamp ) end addEvent( resourceName .. ":create_advertisement", true ) addEventHandler( resourceName .. ":create_advertisement", root, function( phone, name, address, advertisement, expires, section ) --Check if all fields have been entered by the user. if not ( phone == nil or name == nil or address == nil or advertisement == nil ) then --Fetch the created by local createdBy = tostring( getElementData( source, "dbid" ) ) --Get the current server time to store as our start time local start = getRealTime().timestamp --Add the time until expiry to the start time to get the actual time it will expire. local expiry = start + expires --Check if our query went into the database successfully. if exports.mysql:insert( 'advertisements', { phone = phone, name = name, address = address, advertisement = advertisement, start = start, expiry = expiry, section = section, created_by = createdBy } ) then --We'll send something to the client side so they can close the add form and reopen the main advertisements form. --openAdvertisements( source, nil ) else --If the database query was unsucessful, alert the end user. outputChatBox( "SQL Error.", source ) triggerClientEvent( source, resourceName .. ":ad_create_fail", root ) end else --If all fields were not entered, alert the user. outputChatBox( "Field Error.", source ) triggerClientEvent( source, resourceName .. ":ad_create_fail", root ) end end ) local coolDown = {} addEvent( resourceName .. ":push_advertisement", true ) addEventHandler( resourceName .. ":push_advertisement", root, function( id ) local advertisement = exports.mysql:select_one( "advertisements", { id = id } ) advertisement.author = exports.mysql:select_one( "characters", { id = advertisement.created_by } ).charactername if not coolDown[ id ] or ( coolDown[ id ] < now() - ( 60 * COOLDOWN_MINUTES ) ) then if exports.bank:takeBankMoney( client, 100 ) then coolDown[ id ] = now() for i, k in pairs( getElementsByType( 'player' ) ) do if exports.integration:isPlayerTrialAdmin( k ) then outputChatBox( "ADVERT: " .. advertisement.advertisement .. " | Ph: " .. advertisement.phone .. " | Cat: " .. sections[ tonumber( advertisement.section ) ] .. " (( " .. advertisement.author:gsub("_", " ") .." )) .", k, 0, 255, 0 ) else outputChatBox( "ADVERT: " .. advertisement.advertisement .. " | Ph: " .. advertisement.phone .. " | Cat: " .. sections[ tonumber( advertisement.section ) ] .. ".", k, 0, 255, 0 ) end end else outputChatBox( "Nu ai destui bani în bancă să trimiți această reclamă.", client, 255, 155, 155 ) end else outputChatBox( "Poți trimite o reclamă o dată la " .. COOLDOWN_MINUTES .. " minute.", client, 255, 155, 155 ) end end ) function deleteAdvertisement( id ) return exports.mysql:delete('advertisements', {id = id}) end addEvent( "advertisements:delete_advertisement", true ) addEventHandler( "advertisements:delete_advertisement", getRootElement(), function( id ) if deleteAdvertisement( id ) then --openAdvertisements( source ) else outputChatBox( "An error occured with deleting that ad.", source, 255, 100, 100 ) end end ) function openAdvertisements( player, command ) local advertisements = { } --These will hold our advertisements to send to the client and populate our advertisement tables. if not player then player = source end for _, ad in ipairs( exports.mysql:select('advertisements') ) do if tonumber( ad.expiry ) >= tonumber( getRealTime().timestamp ) then --Check if the advertisement has expired, delete it if so. ad.author = exports.mysql:select_one( "characters", { id = ad.created_by } ).charactername table.insert( advertisements, ad ) else deleteAdvertisement( ad.id ) end end triggerClientEvent( player, resourceName .. ":display_all", root, advertisements, exports.integration:isPlayerAdmin( player ) ) --Send the advertisements to the client to create the GUI. end addCommandHandler( "advertisements", openAdvertisements, false, false ) addCommandHandler( "ads", openAdvertisements, false, false ) addCommandHandler( "classifieds", openAdvertisements, false, false ) addEvent( resourceName .. ":open_ads", true ) addEventHandler( resourceName .. ":open_ads", root, openAdvertisements ) Hello guys I just wanna know what I messed up in my script I'm facing this error for hours!! ERROR: advertisements\advertisements.Lua:187: call: failed to call 'mysql:select' [string "?"] ERROR: advertisements\advertisements.Lua:187: bad argument #1 to 'ipairs' (table expected, got boolean)
  11. și cum pot scăpa de costum weapons?
  12. Salutare Tuturor! Vreau să întreb cum pot remedia o greșeală cu o armă? Am 2 arme într-o armă, una originală și una modificată? !! cum pot rezolva asta ?! În ce fișier ar trebui rezolvată problema cu o eroare de armă? Iată o imagine a modului meu de joc DayZ! Aceasta este versiunea 0.7b! https://imgur.com/a/nddULJg https://imgur.com/a/wcr9pVY Mie mi-a spus cineva că trebuie de rezolvat în core.Lua și core_client.Lua ! Uitați fișierele aici ! https://www.mediafire.com/file/brgoz8ebc2g06jn/core_client.Lua/file https://www.mediafire.com/file/ev34e1kbsrzapxj/core.Lua/file Mulțumesc Anticipat !
×
×
  • Create New...