Jump to content

Info Marker Script Doesnt Export To MYSQL Database


Recommended Posts

Posted

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 
    
     

Posted

I don't know allmost nothing about mysql scripting.

You need to get x,y,z to put it in table I think.

Diet with russian vodka, lose 3 days in one week !

Posted

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 
    
     

Posted

so what? i've just got idea for virtual gamers an the tag is allmost the same

Diet with russian vodka, lose 3 days in one week !

Posted

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 !!!!!!!!!!!!!!!!!!

Posted

Maybe because you never execute: "saveinfo" function?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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 
  

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

You've put that function on your code, do you think we guess if functions are defined or not?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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?

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