Jump to content

Loading Stuff From MYSQL


Recommended Posts

How do you mean by "load a table"?

Like for example you have seen my infopoints script? Right? But When The Resource Gets Restarted The Infopoint Blips Dont Load In From The MYSQL Database

Off Topic:

Also In The MYSQL Database It Only Saves the X Postition And It Doesnt Save The Y Or Z Position

mysql = exports.mysql 
  
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, 255, 194, 14 ); 
    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 
  
function infohit(thePlayer) 
    local message = getElementData( infopointpickup,"Message") 
    outputChatBox("" .. message .."",thePlayer) 
end 
  

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