Jump to content

CodeMaster

Members
  • Posts

    126
  • Joined

  • Last visited

Everything posted by CodeMaster

  1. Hi. 'Till now I didn't have any problems with lua concluding that my scripts was only basics. This one is basic too, but I went on a problem when it wasn't able to add any additional text to a file (ex. new line). Its used to get coordinates to a file, like SA-MP debug mode, and then to I read it and get needed info. This is the current code: posFile = nil function loadScript(startedResource) if startedResource == getThisResource() then posFile = fileOpen("Positions.txt") if posFile then outputChatBox("Positions.txt loaded") else posFile = nil posFile = fileCreate("Positions.txt") end outputChatBox("MapMaker loaded...") outputConsole("MapMaker loaded...") end end addEventHandler("onResourceStart",getRootElement(),loadScript) function addLoc(playerSource) local rot = getPlayerRotation(playerSource) local posx,posy,posz = getElementPosition(playerSource) if posFile then fileWrite(posFile,"Positions " .. posx .. " " .. posy .. " " .. posz .. " " .. "Rotation " .. rot .. "\n") outputConsole("Saved...") outputChatBox(posx .. posy .. posz) outputChatBox("Saved") end end addCommandHandler("saveloc",addLoc) EDIT: I forgot to say that it gives in outputChatBox the right coords, but writes some weird to file...
×
×
  • Create New...