micheal1230 Posted June 3, 2012 Share Posted June 3, 2012 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
Wei Posted June 3, 2012 Share Posted June 3, 2012 I don't know allmost nothing about mysql scripting. You need to get x,y,z to put it in table I think. Link to comment
micheal1230 Posted June 3, 2012 Author Share Posted June 3, 2012 Well it doesnt save on the mysql database And I Get This Error 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
Wei Posted June 3, 2012 Share Posted June 3, 2012 so what? i've just got idea for virtual gamers an the tag is allmost the same Link to comment
Cyandie Posted June 3, 2012 Share Posted June 3, 2012 Try using the SQL stuff like this `message`='".. message .." Link to comment
micheal1230 Posted June 3, 2012 Author Share Posted June 3, 2012 Try using the SQL stuff like this`message`='".. message .." please give a example Link to comment
Castillo Posted June 3, 2012 Share Posted June 3, 2012 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
micheal1230 Posted June 3, 2012 Author Share Posted June 3, 2012 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
Castillo Posted June 3, 2012 Share Posted June 3, 2012 Maybe because you never execute: "saveinfo" function? Link to comment
micheal1230 Posted June 4, 2012 Author Share Posted June 4, 2012 Maybe because you never execute: "saveinfo" function? How do i do that? Link to comment
Anderl Posted June 4, 2012 Share Posted June 4, 2012 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
micheal1230 Posted June 4, 2012 Author Share Posted June 4, 2012 Thanks Draken But There Is A Error Aint Line 23 Because There Is No infohit function addEventHandler ( "onPickupHit", pInfoPickup, infohit ); Link to comment
Anderl Posted June 4, 2012 Share Posted June 4, 2012 You've put that function on your code, do you think we guess if functions are defined or not? Link to comment
micheal1230 Posted June 4, 2012 Author Share Posted June 4, 2012 You've put that function on your code, do you think we guess if functions are defined or not? i Dont Understand Link to comment
Castillo Posted June 4, 2012 Share Posted June 4, 2012 You're pretty much asking us to know which functions your script really has, which is impossible because we're not telepathic. Link to comment
micheal1230 Posted June 4, 2012 Author Share Posted June 4, 2012 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now