micheal1230 Posted June 5, 2012 Share Posted June 5, 2012 Well Here Is The Error Everything Else Works Serverside: mysql = exports.mysql local pInfo = createPickup ( -204.19921875, 1116.7587890625, 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 outputChatBox ( "Our Forums Address Is mtafcrp.freeforums.org", pPlayer ); 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, "PosX", nX ); setElementData ( pInfoPickup, "PosY", nY ); setElementData ( pInfoPickup, "PosZ", 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 posx = getElementData ( pInfoPickup, "PosX" ); local posy = getElementData ( pInfoPickup, "PosY" ); local posz = getElementData ( pInfoPickup, "PosZ" ); exports['mysql']:query_free ( "INSERT INTO `infopoints` ( posx, posy, posz, message ) VALUES ( '" .. exports.mysql:escape_string(posx) .. "', '" .. exports.mysql:escape_string(posy) .. "', '" .. exports.mysql:escape_string(posz) .. "', '" .. exports.mysql:escape_string(message) .. "' )" ); end function infohit(thePlayer) local message = getElementData( infopointpickup,"Message") outputChatBox("" .. message .."",thePlayer) end addEventHandler("onResourceStart",resourceRoot, function () for index, infopointpickup in pairs do exports['mysql']:query_free("SELECT * FROM infopoints") do fnCreateInfo(infopointpickup["posx"], infopointpickup["posy"], infopointpickup["posz"], infopointpickup["message"]) end end end) Link to comment
Axel Posted June 5, 2012 Share Posted June 5, 2012 This might work: addEventHandler("onResourceStart",resourceRoot, function () local infopointpickup = getElementsByType("pickup") for index, infopointpickup in pairs do local result = mysql:query_free("SELECT * FROM infopoints") if (result) then fnCreateInfo(infopointpickup["posx"], infopointpickup["posy"], infopointpickup["posz"], infopointpickup["message"]) end end end end) (if it doesn't tell me the error) Link to comment
micheal1230 Posted June 5, 2012 Author Share Posted June 5, 2012 This might work: addEventHandler("onResourceStart",resourceRoot, function () local infopointpickup = getElementsByType("pickup") for index, infopointpickup in pairs do local result = mysql:query_free("SELECT * FROM infopoints") if (result) then fnCreateInfo(infopointpickup["posx"], infopointpickup["posy"], infopointpickup["posz"], infopointpickup["message"]) end end end end) (if it doesn't tell me the error) expected ")" @ Line 67 To Close "(" @ Line 57 Near 'end' Link to comment
Edikosh998 Posted June 5, 2012 Share Posted June 5, 2012 If you count, there is one more end. Link to comment
micheal1230 Posted June 5, 2012 Author Share Posted June 5, 2012 This might work: addEventHandler("onResourceStart",resourceRoot, function () local infopointpickup = getElementsByType("pickup") for index, infopointpickup in pairs do local result = mysql:query_free("SELECT * FROM infopoints") if (result) then fnCreateInfo(infopointpickup["posx"], infopointpickup["posy"], infopointpickup["posz"], infopointpickup["message"]) end end end end) (if it doesn't tell me the error) I removed the extra end but you still get the (generator) expected table got nill error but at like 60 instead Link to comment
Stanley Sathler Posted June 5, 2012 Share Posted June 5, 2012 We can use ";" in Lua codes? ._. Link to comment
micheal1230 Posted June 5, 2012 Author Share Posted June 5, 2012 We can use ";" in Lua codes? ._. Yep It Works For Me But Can We Try And Stay On Topic Im Trying To Fix This MYSQL Problem Any Idea's? Link to comment
Edikosh998 Posted June 5, 2012 Share Posted June 5, 2012 Yes, Lua is a C++ extension... addEventHandler("onResourceStart",resourceRoot, function () local result = mysql_query(host,"SELECT * FROM infopoints") -- U need to put the host for index, infopointpickup in ipairs(result ) do fnCreateInfo(infopointpickup ["posx"], infopointpickup ["posy"], infopointpickup["posz"], infopointpickup["message"]) end end) Wait, mysql:query_free, lol... Link to comment
Cyandie Posted June 6, 2012 Share Posted June 6, 2012 mysql = exports.mysql function createInfoPoints( ) local result = mysql:mysql_query("SELECT * FROM infopoints") for index, infopointpickup in ipairs(result ) do fnCreateInfo(infopointpickup ["posx"], infopointpickup ["posy"], infopointpickup["posz"], infopointpickup["message"]) end end addEventHandler("onResourceStart",resourceRoot, createInfoPoints) Try that. Link to comment
Edikosh998 Posted June 6, 2012 Share Posted June 6, 2012 In his code, it appears the mysql = exports.mysql The problem might be that there is no table. You can check it, doing this mysql = exports.mysql function createInfoPoints( ) local result = mysql:mysql_query("SELECT * FROM infopoints") if #result ~= 0 then for index, infopointpickup in ipairs(result ) do fnCreateInfo(infopointpickup ["posx"], infopointpickup ["posy"], infopointpickup["posz"], infopointpickup["message"]) end end end addEventHandler("onResourceStart",resourceRoot, createInfoPoints) Link to comment
micheal1230 Posted June 6, 2012 Author Share Posted June 6, 2012 Attempt to get local result a bootlean value Link to comment
Cyandie Posted June 6, 2012 Share Posted June 6, 2012 in the vG Script whitch he is using it is already set by mysql = exports.mysql. 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