Jump to content

Info Marker Script Doesnt Export To MYSQL Database


Recommended Posts

Well i got some help making this script from blazy but i not 100% sure how to integrate it into MYSQL i think i have done it right but im not sure

mysql = exports.mysql 
  
infopoint = createPickup(-206.5537109375, 1132.1015625, 19.7421875, 3, 1239) 
    -- ServerSide! 
    function info (thePlayer) 
        outputChatBox("Welcome To Fort Carson Roleplay Server",thePlayer) 
        cancelEvent() 
    end 
    addEventHandler ( "onPickupHit", infopoint, info ) 
      
    function createinfo(thePlayer, commandName, ...) 
        if info then 
        if (exports.global:isPlayerAdmin(thePlayer)) then 
        local x,y,z = getElementPosition(thePlayer) 
        local message = table.concat({...}, " ") 
        infopointpickup = createPickup(x, y, z, 3, 1239, 0.1) 
        setElementData( infopointpickup,"Message", message ) 
        addEventHandler("onPickupHit", infopointpickup, infohit) 
        end 
        else 
        outputChatBox("SYNTAX: /" .. commandName .. " [info]", thePlayer) 
        end 
    end 
    addCommandHandler("createinfo", createinfo) 
      
    function infohit(thePlayer) 
        message = getElementData( infopointpickup,"Message") 
        outputChatBox("" .. message .."",thePlayer) 
    end 
    
   function saveinfo() 
   message = getElementData( infopointpickup,"Message") 
   mysql:query_free('INSERT INTO infopoints (pos, message) VALUES ("' .. mysql:escape_string(x, y, z) .. '", ' .. mysql:escape_string(message) .. ')') 
   end 
    
     

Link to comment

Well it doesnt save on the mysql database And I Get This Error

error-1.png

mysql = exports.mysql 
  
infopoint = createPickup(-206.5537109375, 1132.1015625, 19.7421875, 3, 1239) 
    -- ServerSide! 
    function info (thePlayer) 
        outputChatBox("Welcome To Fort Carson Roleplay Server",thePlayer) 
        cancelEvent() 
    end 
    addEventHandler ( "onPickupHit", infopoint, info ) 
      
    function createinfo(thePlayer, commandName, ...) 
        if info then 
        if (exports.global:isPlayerAdmin(thePlayer)) then 
        local x,y,z = getElementPosition(thePlayer) 
        local message = table.concat({...}, " ") 
        infopointpickup = createPickup(x, y, z, 3, 1239, 0.1) 
        setElementData( infopointpickup,"Message", message ) 
        setElementData( infopointpickup,"Pos", x,y,z ) 
        addEventHandler("onPickupHit", infopointpickup, infohit) 
        end 
        else 
        outputChatBox("SYNTAX: /" .. commandName .. " [info]", thePlayer) 
        end 
    end 
    addCommandHandler("createinfo", createinfo) 
      
    function infohit(thePlayer) 
        message = getElementData( infopointpickup,"Message") 
        outputChatBox("" .. message .."",thePlayer) 
    end 
    
   function saveinfo() 
   message = getElementData( infopointpickup,"Message") 
   pos = getElementData( infopointpickup,"Pos") 
   mysql:query_free('INSERT INTO infopoints (pos, message) VALUES ("' .. mysql:escape_string(pos) .. '", ' .. mysql:escape_string(message) .. ')') 
   end 
    
     

Link to comment

You have to save the position element data as a string.

mysql = exports.mysql 
  
infopoint = createPickup(-206.5537109375, 1132.1015625, 19.7421875, 3, 1239) 
    -- ServerSide! 
    function info (thePlayer) 
        outputChatBox("Welcome To Fort Carson Roleplay Server",thePlayer) 
        cancelEvent() 
    end 
    addEventHandler ( "onPickupHit", infopoint, info ) 
      
    function createinfo(thePlayer, commandName, ...) 
        if info then 
        if (exports.global:isPlayerAdmin(thePlayer)) then 
        local x,y,z = getElementPosition(thePlayer) 
        local message = table.concat({...}, " ") 
        infopointpickup = createPickup(x, y, z, 3, 1239, 0.1) 
        setElementData( infopointpickup,"Message", message ) 
        setElementData( infopointpickup,"Pos", x ..", ".. y ..",".. z ) 
        addEventHandler("onPickupHit", infopointpickup, infohit) 
        end 
        else 
        outputChatBox("SYNTAX: /" .. commandName .. " [info]", thePlayer) 
        end 
    end 
    addCommandHandler("createinfo", createinfo) 
      
    function infohit(thePlayer) 
        message = getElementData( infopointpickup,"Message") 
        outputChatBox("" .. message .."",thePlayer) 
    end 
    
   function saveinfo() 
   message = getElementData( infopointpickup,"Message") 
   pos = getElementData( infopointpickup,"Pos") 
   mysql:query_free('INSERT INTO infopoints (pos, message) VALUES ("' .. mysql:escape_string(pos) .. '", ' .. mysql:escape_string(message) .. ')') 
   end 

Link to comment
You have to save the position element data as a string.
mysql = exports.mysql 
  
infopoint = createPickup(-206.5537109375, 1132.1015625, 19.7421875, 3, 1239) 
    -- ServerSide! 
    function info (thePlayer) 
        outputChatBox("Welcome To Fort Carson Roleplay Server",thePlayer) 
        cancelEvent() 
    end 
    addEventHandler ( "onPickupHit", infopoint, info ) 
      
    function createinfo(thePlayer, commandName, ...) 
        if info then 
        if (exports.global:isPlayerAdmin(thePlayer)) then 
        local x,y,z = getElementPosition(thePlayer) 
        local message = table.concat({...}, " ") 
        infopointpickup = createPickup(x, y, z, 3, 1239, 0.1) 
        setElementData( infopointpickup,"Message", message ) 
        setElementData( infopointpickup,"Pos", x ..", ".. y ..",".. z ) 
        addEventHandler("onPickupHit", infopointpickup, infohit) 
        end 
        else 
        outputChatBox("SYNTAX: /" .. commandName .. " [info]", thePlayer) 
        end 
    end 
    addCommandHandler("createinfo", createinfo) 
      
    function infohit(thePlayer) 
        message = getElementData( infopointpickup,"Message") 
        outputChatBox("" .. message .."",thePlayer) 
    end 
    
   function saveinfo() 
   message = getElementData( infopointpickup,"Message") 
   pos = getElementData( infopointpickup,"Pos") 
   mysql:query_free('INSERT INTO infopoints (pos, message) VALUES ("' .. mysql:escape_string(pos) .. '", ' .. mysql:escape_string(message) .. ')') 
   end 

It Still Doesnt Export To The Database !!!!!!!!!!!!!!!!!!

Link to comment
local pInfo = createPickup ( -206.5537109375, 1132.1015625, 19.7421875, 3, 1239 ); -- create marker 
  
addEventHandler ( "onResourceStart", resourceRoot, 
    function ( ) 
        addEventHandler ( "onPickupHit", pInfo, fnShow ); -- add handler of event 'onPickupHit' to fn 'fnShow' 
        addCommandHandler ( "createinfo", fnCreateInfo ); -- add command 'createinfo' to fn 'fnCreateInfo' 
    end 
) 
  
function fnShow ( pPlayer ) 
    outputChatBox ( "Welcome to Fort Carson Roleplay Server!", pPlayer ); -- output on chat some text 
    cancelEvent(); 
end 
  
function fnCreateInfo ( pPlayer, chCommand, ... ) 
    if ( ... ) then 
        if ( exports['global']:isPlayerAdmin ( pPlayer ) ) then 
            local nX, nY, nZ = getElementPosition ( pPlayer ); 
            local chText = table.concat ( { ... }, " " ); 
            pInfoPickup = createPickup ( nX, nY, nZ, 3, 1239, 0.1 ); 
            setElementData ( pInfoPickup, "Message", chText ); 
            setElementData ( pInfoPickup, "Pos", nX .. nY .. nZ ); 
            addEventHandler ( "onPickupHit", pInfoPickup, infohit ); 
            fnSaveInfo(); 
        end 
    else 
        outputChatBox ( "SYNTAX: /" .. chCommand .. " [iNFO]", pPlayer ); 
    end 
end 
  
function fnSaveInfo ( ) 
    local message       = getElementData ( pInfoPickup, "Message" ); 
    local position      = getElementData ( pInfoPickup, "Pos" ); 
    exports['mysql']:query_free ( "INSERT INTO `infopoints` ( pos, message ) VALUES ( '" .. exports.mysql:escape_string(position) .. "', '" .. exports.mysql:escape_string(message) .. "' )" ); 
end 
  

Link to comment
You're pretty much asking us to know which functions your script really has, which is impossible because we're not telepathic.

Lol nevermind but in the mysql database it only logs the X postion Not The Y Nor Z And how can i load things from mysql database?

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