Jump to content

Deleting Nearby Infopoints HELP!!!


Recommended Posts

Well I have tried This Script I get no errors but it does'nt delete them, it justs says there are non around

function clearNearbyInfo(thePlayer) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
        local x, y, z = getElementPosition(thePlayer) 
        local object = nil 
        local dist = 999999 
        for key, value in ipairs(exports.global:getNearbyElements(thePlayer, "infopoint")) do 
            local objtype = getElementData(value, "type") 
            if (objtype=="info") then 
                local ox, oy, oz = getElementPosition(value) 
                local distance = getDistanceBetweenPoints3D(x, y, z, ox, oy, oz) 
                if (distance) then 
                    object = value 
                    dist = distance 
                end 
            end 
        end 
         
        if (object) then 
            local id = getElementData(object, "dbid") 
            destroyElement(object) 
            local query = mysql:query_free("DELETE FROM infopoints WHERE id='" .. mysql:escape_string(id) .. "'") 
            outputChatBox("Deleted infopoint with id #" .. id .. ".", thePlayer, 0, 255, 0) 
        else 
            outputChatBox("You are not near any infopoint.", thePlayer, 255, 0, 0) 
        end 
    end 
end 
addCommandHandler("delnearbyinfo", clearNearbyInfo, false, false) 

Link to comment
Well I have tried This Script I get no errors but it does'nt delete them, it justs says there are non around
function clearNearbyInfo(thePlayer) 
    if (exports.global:isPlayerAdmin(thePlayer)) then 
        local x, y, z = getElementPosition(thePlayer) 
        local object = nil 
        local dist = 999999 
        for key, value in ipairs(exports.global:getNearbyElements(thePlayer, "infopoint")) do 
            local objtype = getElementData(value, "type") 
            if (objtype=="info") then 
                local ox, oy, oz = getElementPosition(value) 
                local distance = getDistanceBetweenPoints3D(x, y, z, ox, oy, oz) 
                if (distance) then 
                    object = value 
                    dist = distance 
                end 
            end 
        end 
         
        if (object) then 
            local id = getElementData(object, "dbid") 
            destroyElement(object) 
            local query = mysql:query_free("DELETE FROM infopoints WHERE id='" .. mysql:escape_string(id) .. "'") 
            outputChatBox("Deleted infopoint with id #" .. id .. ".", thePlayer, 0, 255, 0) 
        else 
            outputChatBox("You are not near any infopoint.", thePlayer, 255, 0, 0) 
        end 
    end 
end 
addCommandHandler("delnearbyinfo", clearNearbyInfo, false, false) 

Anyone? Not Even Soildsnake14??

Link to comment
The element: "infopoint" exist?
            local id = mysql:query_insert_free ( "INSERT INTO infopoints SET posx='" .. mysql:escape_string(nX) .. "', posy='" .. mysql:escape_string(nY) .. "', posz='" .. mysql:escape_string(nZ) .. "', message='" .. mysql:escape_string(chText) .. "'" ); 
            exports['anticheat-system']:changeProtectedElementDataEx(pInfoPickup, "dbid", id, false) 
            exports['anticheat-system']:changeProtectedElementDataEx(pInfoPickup, "type", "infopoint") 
            --exports['anticheat-system']:changeProtectedElementDataEx(pInfoPickup, "type", "info") 
            exports.pool:allocateElement(pInfoPickup) 
            outputChatBox("You Have Created A Infopoint With The ID ".. id ..".",pPlayer, 255, 194, 14) 
            --fnSaveInfo(); 
        end 
    else 
        outputChatBox ( "SYNTAX: /" .. chCommand .. " [iNFO]", pPlayer, 255, 194, 14 ); 

    exports['anticheat-system']:changeProtectedElementDataEx(pickup, "dbid", id, false) 
            --exports['anticheat-system']:changeProtectedElementDataEx(pickup, "type", "info") 
            exports['anticheat-system']:changeProtectedElementDataEx(pickup, "type", "infopoint") 
            count = count + 1 
            if id > highest then 
                highest = id 
            end 
        end 
  
        mysql:query_free("ALTER TABLE `infopoints` AUTO_INCREMENT = " .. mysql:escape_string((highest + 1))) 
        
    end 
    mysql:free_result(result1) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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