Jump to content

Cepillado

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Cepillado

  1. Hello, I'm having a problem loading a position from a player file into the script, I saved the position as a string and now I can't load it. Here's what I have The string goes like this: (I know that this will spawn me really high, that's not the point)I've tried splitting it like this: local x,y,z = fileRead(playerPos,28) split("x,y,z", ",") setElementPosition(player,x,y,z) And I just keep spawning at the same place, under the ground (As if the z coord equals to 0) Also, I would like to know, since the position length can vary, how can I tell the script to grab the exact amount of numbers that are in the string? For example: 0.000000,0.000000,100.000000 equals to 28 characters, but if it was 10.000000,0.000000,100.000000 it would equal to 29, how could I make the script know when is the end of the string? Because if I use fileRead(playerPos,29) and it's just 28 characters, it would grab the next thing on the file, making the Z coord unusable. Thanks
  2. Hello, I'm having a problem trying to save an element data into a .ini file, here's my code local playerName = getPlayerName( source ) local levelAdmin = getElementData(source,"Admin") local stringName = string.format("Users/%s.ini",playerName) local stringAdmin = string.format("Admin: %i\n",levelAdmin) fileOpen(stringName) fileWrite(stringName,stringAdmin) fileClose(stringName) But when I disconnect, I get 2 warnings and nothing saves: Bad 'file' pointer @ 'fileWrite' (1) and Bad 'file' pointer @ 'fileClose' (1). Thanks
  3. Hello, I'm trying to store some positions in a .txt file, but whenever I use the command to save the position, it writes over the same line and replaces the first position saved. Here's my code function saveCoords(source) local x,y,z = getElementPosition( source ) local stringPos = string.format("%f, %f, %f \n ",x,y,z) local hFile = fileOpen("coords.txt",false) fileWrite(hFile,stringPos) fileClose(hFile) end I've tried the code without closing the file, same thing happens, I've also tried the code without the \n, and I get the same result. (I'm really sorry if you don't understand some of the things that I wrote, English is not my first language)
×
×
  • Create New...