micheal1230 Posted June 12, 2012 Share Posted June 12, 2012 (edited) The Error: Attempt To Compare Number With nil Line 93 Serverside -- Infopoints Script By haws1290 For Use On Fort Carson Roleplay © -- Help From: -- Alpha -- Soildsnake14 -- blazy -- Draken 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" ); 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( pInfoPickup,"Message") outputChatBox("" .. message .."",thePlayer) end mysql = exports.mysql --[[function createInfoPoints( ) local result = mysql:mysql_query(host,"SELECT * FROM infopoints") if #result ~= 0 then for index, pInfoPickup in ipairs(result ) do fnCreateInfo(pInfoPickup ["posx"], pInfoPickup ["posy"], pInfoPickup["posz"], pInfoPickup["message"]) end end end addEventHandler("onResourceStart",resourceRoot, createInfoPoints)]] function loadAllInfopoints(res) -- Load current ones local result = mysql:query("SELECT * FROM infopoints") local count = 0 local highest = 0 if (result) then local run = true while run do local row = exports.mysql:fetch_assoc(result) if not (row) then break end local x = tonumber(row["posx"]) local y = tonumber(row["posy"]) local z = tonumber(row["posz"]) local infomessage = (row["message"]) local pickup = createPickup( x, y, z, 3, 1239, 0.1) exports.pool:allocateElement(pickup) count = count + 1 if id > highest then highest = id end end mysql:query_free("ALTER TABLE `infopoints` AUTO_INCREMENT = " .. mysql:escape_string((highest + 1))) end mysql:free_result(result) end addEventHandler("onResourceStart", getResourceRootElement(), loadAllInfopoints) Edited June 12, 2012 by Guest Link to comment
Castillo Posted June 12, 2012 Share Posted June 12, 2012 I can't see where you defined "id". Link to comment
micheal1230 Posted June 12, 2012 Author Share Posted June 12, 2012 I can't see where you defined "id". Right took me some time but i fixed it the pickups load in when i restart the resource but im unsure how to get the message to load for a certain id. Here is the script Serverside: -- Infopoints Script By haws1290 For Use On Fort Carson Roleplay © -- Help From: -- Alpha -- Soildsnake14 -- blazy -- Draken 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 ); local id = mysql:query_insert_free ( "INSERT INTO infopoints SET posx='" .. mysql:escape_string(nX) .. "', posy='" .. mysql:escape_string(nY) .. "', posz='" .. mysql:escape_string(nZ) .. "', message='" .. mysql:escape_string(chText) .. "'" ); exports['anticheat-system']:changeProtectedElementDataEx(pInfoPickup, "dbid", id, false) outputChatBox("You Have Created A Infopoint With The ID ".. id ..".",pPlayer, 255, 194, 14) --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" ); end]] --[[function infohit(thePlayer) local message = getElementData( pInfoPickup,"Message") outputChatBox("" .. message .."",thePlayer) end]] mysql = exports.mysql --[[function createInfoPoints( ) local result = mysql:mysql_query(host,"SELECT * FROM infopoints") if #result ~= 0 then for index, pInfoPickup in ipairs(result ) do fnCreateInfo(pInfoPickup ["posx"], pInfoPickup ["posy"], pInfoPickup["posz"], pInfoPickup["message"]) end end end addEventHandler("onResourceStart",resourceRoot, createInfoPoints)]] function loadAllInfopoints(res) -- Load current ones local result = mysql:query("SELECT * FROM infopoints") local count = 0 local highest = 0 if (result) then local run = true while run do local row = exports.mysql:fetch_assoc(result) if not (row) then break end local id = tonumber(row["id"]) local x = tonumber(row["posx"]) local y = tonumber(row["posy"]) local z = tonumber(row["posz"]) local infomessage = (row["message"]) local pickup = createPickup( x, y, z, 3, 1239, 0.1) exports.pool:allocateElement(pickup) exports['anticheat-system']:changeProtectedElementDataEx(object, "dbid", id, false) count = count + 1 if id > highest then highest = id end end mysql:query_free("ALTER TABLE `infopoints` AUTO_INCREMENT = " .. mysql:escape_string((highest + 1))) end mysql:free_result(result) end addEventHandler("onResourceStart", getResourceRootElement(), loadAllInfopoints) 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