Jump to content

The information system has been corrupted.


ironimust

Recommended Posts

Hello MTA users.

My info-system has been corrupted.

I use classic roleplay server info-system, but info-system now running /addii command use new info but only object get in.

new created infos succesfull saved the mysql but info-system infos dimension, interior, info:id and object not loading the server. 

info-system command lines;

--------------------server.lua-----------------
 

mysql = exports.mysql

-- Done by Anthony
local informationicons = { }

function SmallestID() -- 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 informationicons AS e1 LEFT JOIN informationicons AS e2 ON e1.id +1 = e2.id WHERE e2.id IS NULL")
    if result then
        local id = tonumber(result["nextID"]) or 1
        return id
    end
    return false
end

function makeInformationIcon(thePlayer, commandName, ...)
    if exports.integration:isPlayerTrialAdmin(thePlayer) then
    if ... then
        local arg = {...}
        local information = table.concat( arg, " " )
        local x, y, z = getElementPosition(thePlayer)
        --z = z + 0.5 only use for i object
        local rx, ry, rz = getElementRotation(thePlayer)
        local interior = getElementInterior(thePlayer)
        local dimension = getElementDimension(thePlayer)
        local id = SmallestID()
        local createdby = getPlayerName(thePlayer):gsub("_", " ")
        local query = mysql:query_free("INSERT INTO informationicons SET id="..mysql:escape_string(id)..",createdby='"..mysql:escape_string(createdby).."',x='"..mysql:escape_string(x).."', y='"..mysql:escape_string(y).."', z='"..mysql:escape_string(z).."', rx='"..mysql:escape_string(rx).."', ry='"..mysql:escape_string(ry).."', rz='"..mysql:escape_string(rz).."', interior='"..mysql:escape_string(interior).."', dimension='"..mysql:escape_string(dimension).."', information='"..mysql:escape_string(information).."'")
        if query then
            informationicons[id] = createPickup(x, y, z, 3, 1239, 0)--createObject(1239, x, y, z, rx, ry, rz)
            setElementInterior(informationicons[id], interior)
            setElementDimension(informationicons[id], dimension)
            setElementData(informationicons[id], "informationicon:id", id)
            setElementData(informationicons[id], "informationicon:createdby", createdby)
            setElementData(informationicons[id], "informationicon:x", x)
            setElementData(informationicons[id], "informationicon:y", y)
            setElementData(informationicons[id], "informationicon:z", z)
            setElementData(informationicons[id], "informationicon:rx", rx)
            setElementData(informationicons[id], "informationicon:ry", ry)
            setElementData(informationicons[id], "informationicon:rz", rz)
            setElementData(informationicons[id], "informationicon:interior", interior)
            setElementData(informationicons[id], "informationicon:dimension", dimension)
            setElementData(informationicons[id], "informationicon:information", information)
            outputChatBox("Information icon created with ID: "..id, thePlayer, 0, 255, 0)
        else
            outputChatBox("Error creating information icon. Please report on the mantis.", thePlayer, 255, 0, 0)
        end
        else
            outputChatBox("SYNTAX: /addii [Information]", thePlayer, 255, 194, 14)
        end
    end
end
addCommandHandler("addii", makeInformationIcon, false, false)

function saveAllInformationIcons()
    for key, value in ipairs (informationicons) do
        local id = getElementData(informationicons[key], "informationicon:id")
        local createdby = getElementData(informationicons[key], "informationicon:createdby")
        local x = getElementData(informationicons[key], "informationicon:x")
        local y = getElementData(informationicons[key], "informationicon:y")
        local z = getElementData(informationicons[key], "informationicon:z")
        local rx = getElementData(informationicons[key], "informationicon:rx")
        local ry = getElementData(informationicons[key], "informationicon:ry")
        local rz = getElementData(informationicons[key], "informationicon:rz")
        local interior = getElementData(informationicons[key], "informationicon:interior")
        local dimension = getElementData(informationicons[key], "informationicon:dimension")
        local information = getElementData(informationicons[key], "informationicon:information")
        mysql:query_free("UPDATE informationicons SET createdby = '" .. mysql:escape_string(createdby) .. "', x = '" .. mysql:escape_string(x) .. "', y = '" .. mysql:escape_string(y) .. "', z = '" .. mysql:escape_string(z) .. "', rx = '" .. mysql:escape_string(rx) .. "', ry = '" .. mysql:escape_string(ry) .. "', rz = '" .. mysql:escape_string(rz) .. "', interior = '" .. mysql:escape_string(interior) .. "', dimension = '" .. mysql:escape_string(dimension) .. "', information = '" .. mysql:escape_string(information) .. "' WHERE id='" .. mysql:escape_string(id) .. "'")
    end
end
addEventHandler("onResourceStop", getResourceRootElement(), saveAllInformationIcons)


function loadAllInformationIcons()
    local ticks = getTickCount( )
    local counter = 0
    local result = mysql:query("SELECT * FROM `informationicons`")
    while true do
        local row = mysql:fetch_assoc(result)
        if not row then break end
        local id = tonumber(row["id"])
        local createdby = tostring(row["createdby"])
        local x = tonumber(row["x"])
        local y = tonumber(row["y"])   -- bunlar tuhaf
        local z = tonumber(row["z"])
        local rx = tonumber(row["rx"])
        local ry = tonumber(row["ry"])
        local rz = tonumber(row["rz"])
        local interior = tonumber(row["interior"])
        local dimension = tonumber(row["dimension"])
        local information = tostring(row["information"])
        informationicons[id] = createPickup(x, y, z, 3, 1239, 0)--createObject(1239, x, y, z, rx, ry, rz)
        setElementInterior(informationicons[id], interior)
        setElementDimension(informationicons[id], dimension)
        setElementData(informationicons[id], "informationicon:id", id)
        setElementData(informationicons[id], "informationicon:createdby", createdby)
        setElementData(informationicons[id], "informationicon:x", x)
        setElementData(informationicons[id], "informationicon:y", y)
        setElementData(informationicons[id], "informationicon:z", z)
        setElementData(informationicons[id], "informationicon:rx", rx)
        setElementData(informationicons[id], "informationicon:ry", ry)
        setElementData(informationicons[id], "informationicon:rz", rz)
        setElementData(informationicons[id], "informationicon:interior", interior)
        setElementData(informationicons[id], "informationicon:dimension", dimension)
        setElementData(informationicons[id], "informationicon:information", information)
        counter = counter + 1
    end
    outputDebugString("Loaded " .. counter .. " information icons in " .. ( getTickCount( ) - ticks ) .. "ms")
end
addEventHandler("onResourceStart", getResourceRootElement(), loadAllInformationIcons)

function getNearbyInformationIcons(thePlayer, commandName)
    if (exports.integration:isPlayerTrialAdmin(thePlayer)) then
        local posX, posY, posZ = getElementPosition(thePlayer)
        outputChatBox("Nearby Information Icons:", thePlayer, 255, 126, 0)
        local count = 0
        for key, value in ipairs (informationicons) do
            local dbid = getElementData(informationicons[key], "informationicon:id")
            if dbid then
                local x, y, z = getElementPosition(informationicons[key])
                local distance = getDistanceBetweenPoints3D(posX, posY, posZ, x, y, z)
                if distance <= 10 and getElementDimension(informationicons[key]) == getElementDimension(thePlayer) and getElementInterior(informationicons[key]) == getElementInterior(thePlayer) then
                    local createdby = getElementData(informationicons[key], "informationicon:createdby")
                    local information = getElementData(informationicons[key], "informationicon:information")
                    outputChatBox("   #" .. dbid .. " by " .. createdby .. " - Icon: " .. information, thePlayer, 255, 126, 0)
                    count = count + 1
                end
            end
        end        
        if (count==0) then
            outputChatBox("   None.", thePlayer, 255, 126, 0)
        end
    end
end
addCommandHandler("nearbyii", getNearbyInformationIcons, false, false)

function deleteInformationIcon(thePlayer, commandName, ID)
    if (exports.integration:isPlayerTrialAdmin(thePlayer)) then
        if tonumber(ID) then
            local ID = tonumber(ID)
            if informationicons[ID] then
                for k,v in pairs(getAllElementData(informationicons[ID])) do
                    removeElementData(informationicons[ID],k)
                end
                destroyElement(informationicons[ID])
                local query = mysql:query_free("DELETE FROM informationicons WHERE id='"..mysql:escape_string(ID).."'")
                if query then
                    informationicons[ID] = nil
                    outputChatBox("Information icon ID: "..ID.." deleted.", thePlayer, 0, 255, 0)
                else
                    outputChatBox("Error deleting information icon. Please report on the mantis.", thePlayer, 255, 0, 0)
                end
            else
                outputChatBox("An information icon with that ID does not exist.", thePlayer, 255, 0, 0)
            end
        else
            outputChatBox("SYNTAX: /delii [ID]", thePlayer, 255, 194, 14)
        end
    end
end
addCommandHandler("delii", deleteInformationIcon, false, false)



--------------------server.lua-----------------


and CLİENT file

--------------------client.lua-----------------
 

local informationicons = { }

function showNearbyInformationIconsInformation()
    for index, informationicon in ipairs( exports.global:getNearbyElements(getLocalPlayer(), "marker") ) do
            informationicons[index] = informationicon
    end
    showInformationText()
end
setTimer(showNearbyInformationIconsInformation, 0, 0)

function showInformationText()
    for i = 1, #informationicons, 1 do
    if isElement(informationicons) then
        local x,y,z = getElementPosition(informationicons)            
        local cx,cy,cz = getCameraMatrix()
        local information = getElementData(informationicons, "informationicon:information")
        local dbid = getElementData(informationicons, "informationicon:id")
        if information then
            if getDistanceBetweenPoints3D(cx,cy,cz,x,y,z) <= 40 then
                local px,py,pz = getScreenFromWorldPosition(x,y,z+0.5,0.05)
                if px and isLineOfSightClear(cx, cy, cz, x, y, z, true, true, true, true, true, false, false) then
                    dxDrawText(information, px-4, py-4, px+6, py+6, tocolor(0, 0, 0, 255), 1.5, "default-bold", "center", "center", false, false)
                    dxDrawText(information, px, py, px, py, tocolor(234, 200, 0, 255), 1.5, "default-bold", "center", "center", false, false)                    
                else
                end
            end
        end
    end
    end
end
addEventHandler("onResourceStart", getRootElement(), showInformationText)


--------------------client.lua-----------------



error codes server.lua, line 91,92,93,94


        informationicons[id] = createPickup(x, y, z, 3, 1239, 0)--createObject(1239, x, y, z, rx, ry, rz)
        setElementInterior(informationicons[id], interior)
        setElementDimension(informationicons[id], dimension)
        setElementData(informationicons[id], "informationicon:id", id)



PLS Help now has been break my info-system :(

spacer.png

Error messages

Edited by Vinyard
Link to comment
  • Moderators
6 hours ago, ironimust said:

info-system command lines;

 

SELECT 
	* 
FROM 
	`informationicons` AS infoIcons
WHERE 
	infoIcons.id IS NULL 
	OR infoIcons.x IS NULL 
	OR infoIcons.y IS NULL 
	OR infoIcons.z IS NULL
	OR infoIcons.interior IS NULL
	OR infoIcons.dimension IS NULL

Does this query gives you any results? (run in mysql interface)

(note this query does only check for null values)

 

If this query does not give you results.

Add a log to the following function, in case of a missing x, y or z, it will log the ID of that database row (and abort the loading process).

function loadAllInformationIcons()
    local ticks = getTickCount( )
    local counter = 0
    local result = mysql:query("SELECT * FROM `informationicons`")
    while true do
        local row = mysql:fetch_assoc(result)
        if not row then break end
        local id = tonumber(row["id"])
        local createdby = tostring(row["createdby"])
        local x = tonumber(row["x"])
        local y = tonumber(row["y"])   -- bunlar tuhaf
        local z = tonumber(row["z"])
        local rx = tonumber(row["rx"])
        local ry = tonumber(row["ry"])
        local rz = tonumber(row["rz"])
        local interior = tonumber(row["interior"])
        local dimension = tonumber(row["dimension"])
        local information = tostring(row["information"])
    	---------------------------------------------
    	if not x or not y or not z then
      		iprint("Data is corruption starts at ID", id)
      		break
      	end
    	---------------------------------------------
        informationicons[id] = createPickup(x, y, z, 3, 1239, 0)--createObject(1239, x, y, z, rx, ry, rz)
        setElementInterior(informationicons[id], interior)
        setElementDimension(informationicons[id], dimension)
        setElementData(informationicons[id], "informationicon:id", id)
        setElementData(informationicons[id], "informationicon:createdby", createdby)
        setElementData(informationicons[id], "informationicon:x", x)
        setElementData(informationicons[id], "informationicon:y", y)
        setElementData(informationicons[id], "informationicon:z", z)
        setElementData(informationicons[id], "informationicon:rx", rx)
        setElementData(informationicons[id], "informationicon:ry", ry)
        setElementData(informationicons[id], "informationicon:rz", rz)
        setElementData(informationicons[id], "informationicon:interior", interior)
        setElementData(informationicons[id], "informationicon:dimension", dimension)
        setElementData(informationicons[id], "informationicon:information", information)
        counter = counter + 1
    end

After wards you can look the id up like this (replace ID 1 with the one in the debug logs)

SELECT 
	* 
FROM 
	`informationicons` AS infoIcons
WHERE infoIcons.id = 1

 

 

Link to comment
27 minutes ago, IIYAMA said:

 

SELECT 
	* 
FROM 
	`informationicons` AS infoIcons
WHERE 
	infoIcons.id IS NULL 
	OR infoIcons.x IS NULL 
	OR infoIcons.y IS NULL 
	OR infoIcons.z IS NULL
	OR infoIcons.interior IS NULL
	OR infoIcons.dimension IS NULL

Does this query gives you any results? (run in mysql interface)

(note this query does only check for null values)

 

If this query does not give you results.

Add a log to the following function, in case of a missing x, y or z, it will log the ID of that database row (and abort the loading process).

function loadAllInformationIcons()
    local ticks = getTickCount( )
    local counter = 0
    local result = mysql:query("SELECT * FROM `informationicons`")
    while true do
        local row = mysql:fetch_assoc(result)
        if not row then break end
        local id = tonumber(row["id"])
        local createdby = tostring(row["createdby"])
        local x = tonumber(row["x"])
        local y = tonumber(row["y"])   -- bunlar tuhaf
        local z = tonumber(row["z"])
        local rx = tonumber(row["rx"])
        local ry = tonumber(row["ry"])
        local rz = tonumber(row["rz"])
        local interior = tonumber(row["interior"])
        local dimension = tonumber(row["dimension"])
        local information = tostring(row["information"])
    	---------------------------------------------
    	if not x or not y or not z then
      		iprint("Data is corruption starts at ID", id)
      		break
      	end
    	---------------------------------------------
        informationicons[id] = createPickup(x, y, z, 3, 1239, 0)--createObject(1239, x, y, z, rx, ry, rz)
        setElementInterior(informationicons[id], interior)
        setElementDimension(informationicons[id], dimension)
        setElementData(informationicons[id], "informationicon:id", id)
        setElementData(informationicons[id], "informationicon:createdby", createdby)
        setElementData(informationicons[id], "informationicon:x", x)
        setElementData(informationicons[id], "informationicon:y", y)
        setElementData(informationicons[id], "informationicon:z", z)
        setElementData(informationicons[id], "informationicon:rx", rx)
        setElementData(informationicons[id], "informationicon:ry", ry)
        setElementData(informationicons[id], "informationicon:rz", rz)
        setElementData(informationicons[id], "informationicon:interior", interior)
        setElementData(informationicons[id], "informationicon:dimension", dimension)
        setElementData(informationicons[id], "informationicon:information", information)
        counter = counter + 1
    end

After wards you can look the id up like this (replace ID 1 with the one in the debug logs)

SELECT 
	* 
FROM 
	`informationicons` AS infoIcons
WHERE infoIcons.id = 1

 

 

x y z and all other values of information objects are successfully saved in mysql.

And I don't understand anything of what you're saying, I don't know much.

But one thing I noticed is that the information system can successfully use this to save and delete x y z dimension values.

but when I want to add a new information object, it gives an error while uploading x, y, z, measure, internal values to the server.

And the main thing is that when these information objects are registered to mysql, they make x, y, z, Dimension, Interior values with a different code.


but when asked to upload to the server, the code tries to load x, y, z, measure, internal values in a different way.




-------------save codes---------------------

local x = getElementData(informationicons[key], "informationicon:x")
        local y = getElementData(informationicons[key], "informationicon:y")
        local z = getElementData(informationicons[key], "informationicon:z")
        local rx = getElementData(informationicons[key], "informationicon:rx")
        local ry = getElementData(informationicons[key], "informationicon:ry")
        local rz = getElementData(informationicons[key], "informationicon:rz")
        local interior = getElementData(informationicons[key], "informationicon:interior")
        local dimension = getElementData(informationicons[key], "informationicon:dimension")

-------------save codes---------------------

-----

-------------to server load codes-------------

    local x = tonumber(row["x"])
        local y = tonumber(row["y"])
        local z = tonumber(row["z"])
        local rx = tonumber(row["rx"])
        local ry = tonumber(row["ry"])
        local rz = tonumber(row["rz"])
        local interior = tonumber(row["interior"])
        local dimension = tonumber(row["dimension"])
        local information = tostring(row["information"])
        informationicons[id] = createPickup(x, y, z, 3, 1239, 0)
        setElementInterior(informationicons[id], interior)
        setElementDimension(informationicons[id], dimension)
        setElementData(informationicons[id], "informationicon:id", id)
        setElementData(informationicons[id], "informationicon:createdby", createdby)
        setElementData(informationicons[id], "informationicon:x", x)
        setElementData(informationicons[id], "informationicon:y", y)
        setElementData(informationicons[id], "informationicon:z", z)
        setElementData(informationicons[id], "informationicon:rx", rx)
        setElementData(informationicons[id], "informationicon:ry", ry)
        setElementData(informationicons[id], "informationicon:rz", rz)
        setElementData(informationicons[id], "informationicon:interior", interior)
        setElementData(informationicons[id], "informationicon:dimension", dimension)

-------------to server load codes-------------

  codes different from the save code   "tonumber"  

Why is this code
"tonumber" contains a line?


These are the codes used to add information to the server, how is this line of code different from the others?
Link to comment
  • Moderators
53 minutes ago, ironimust said:

but when I want to add a new information object, it gives an error while uploading x, y, z, measure, internal values to the server.

 

58 minutes ago, ironimust said:

Why is this code "tonumber" contains a line?

The tonumber function is used to convert a string to a number. A string is basically text "abcdef12345!@$#%" and a number is 1234567890.

local thisIsAString = "1234"

print(type(thisIsAString)) -- string

thisIsAString = tonumber(thisIsAString) -- convert a string to number

print(type(thisIsAString)) -- number

 

Why is it trying to convert a string to a number? Probably just to be sure, since the code will not work if strings are using for example for the position x, y, z

 

7 hours ago, ironimust said:
function makeInformationIcon(thePlayer, commandName, ...)

This function is used to add information icons.

Please specify errors are shown when using the following command:

/addii

 

And mark them in the function with a comment:

local id = SmallestID() -- for example this line
Spoiler
function makeInformationIcon(thePlayer, commandName, ...)
    if exports.integration:isPlayerTrialAdmin(thePlayer) then
    if ... then
        local arg = {...}
        local information = table.concat( arg, " " )
        local x, y, z = getElementPosition(thePlayer)
        --z = z + 0.5 only use for i object
        local rx, ry, rz = getElementRotation(thePlayer)
        local interior = getElementInterior(thePlayer)
        local dimension = getElementDimension(thePlayer)
        local id = SmallestID()
        local createdby = getPlayerName(thePlayer):gsub("_", " ")
        local query = mysql:query_free("INSERT INTO informationicons SET id="..mysql:escape_string(id)..",createdby='"..mysql:escape_string(createdby).."',x='"..mysql:escape_string(x).."', y='"..mysql:escape_string(y).."', z='"..mysql:escape_string(z).."', rx='"..mysql:escape_string(rx).."', ry='"..mysql:escape_string(ry).."', rz='"..mysql:escape_string(rz).."', interior='"..mysql:escape_string(interior).."', dimension='"..mysql:escape_string(dimension).."', information='"..mysql:escape_string(information).."'")
        if query then
            informationicons[id] = createPickup(x, y, z, 3, 1239, 0)--createObject(1239, x, y, z, rx, ry, rz)
            setElementInterior(informationicons[id], interior)
            setElementDimension(informationicons[id], dimension)
            setElementData(informationicons[id], "informationicon:id", id)
            setElementData(informationicons[id], "informationicon:createdby", createdby)
            setElementData(informationicons[id], "informationicon:x", x)
            setElementData(informationicons[id], "informationicon:y", y)
            setElementData(informationicons[id], "informationicon:z", z)
            setElementData(informationicons[id], "informationicon:rx", rx)
            setElementData(informationicons[id], "informationicon:ry", ry)
            setElementData(informationicons[id], "informationicon:rz", rz)
            setElementData(informationicons[id], "informationicon:interior", interior)
            setElementData(informationicons[id], "informationicon:dimension", dimension)
            setElementData(informationicons[id], "informationicon:information", information)
            outputChatBox("Information icon created with ID: "..id, thePlayer, 0, 255, 0)
        else
            outputChatBox("Error creating information icon. Please report on the mantis.", thePlayer, 255, 0, 0)
        end
        else
            outputChatBox("SYNTAX: /addii [Information]", thePlayer, 255, 194, 14)
        end
    end
end
addCommandHandler("addii", makeInformationIcon, false, false)

 

 

Link to comment
  • 2 weeks later...

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...