[HELP] question about coords.
#1

Well, I am using dini, and I waant to know how I can get float from dini file and use it for player pos? Example:

Код:
//In dini file:

spawn=1235.756, 789.123, 785.12
There are any way to use like this?
Код:
spawnpos = dini_Get("filename.txt", "spawn");

SetPlayerPos(playerid, spawnpos);
Reply
#2

pawn Код:
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
dini_FloatSet("/folder/file.ini", "F_X", X);
dini_FloatSet("/folder/file.ini", "F_Y", Y);
dini_FloatSet("/folder/file.ini", "F_Z", Z);

// the output to "file.ini" in the folder "folder" will be
// F_X = 0.000000
// F_Y = 0.000000
// F_Z = 0.000000


////////////////////////////
new Float:X, Float:Y, FloatZ;
X = dini_Float("/folder/file.ini", "F_X");
Y = dini_Float("/folder/file.ini", "F_Y");
Z = dini_Float("/folder/file.ini", "F_Z");
SetPlayerPos(playerid, X, Y, Z);
Reply
#3

I know this way, but I need to load about 20 spawnpoints from file, so any ideas?
Reply
#4

Make so that every player has It's own file

pawn Код:
OnPlayerSpawn(playerid)
{
  new name[MAX_PLAYER_NAME], string[128];
  GetPlayerName(playerid, name, sizeof(name));
  format(string, sizeof(string), "/folder/%s.ini", name);

  if(dini_Exists(string))
  {
    new Float:X, Float:Y, FloatZ;
    X = dini_Float("/folder/file.ini", "F_X");
    Y = dini_Float("/folder/file.ini", "F_Y");
    Z = dini_Float("/folder/file.ini", "F_Z");
    SetPlayerPos(playerid, X, Y, Z);
  }
  else dini_Create(string);
}

OnPlayerDisconnect(playerid, reason)
{
  new Float:X, Float:Y, Float:Z;
  GetPlayerPos(playerid, X, Y, Z);
  dini_FloatSet(string, "F_X", X);
  dini_FloatSet(string, "F_Y", Y);
  dini_FloatSet(string, "F_Z", Z);
}
Reply
#5

I have only one file, and I need do in that way, like I said, and without split. Is it possible?
Reply
#6

I wanted to make that, no succes, maybe this helps?

Код:
new spawn;
spawn=1235.756, 789.123, 785.12

dini_IntSet(filename, "spawn", spawn);

//OnPlayerConnect Etc.

dini_Get("filename.txt", "spawn");
SetPlayerPos(playerid, spawn);
Reply
#7

Impossible with dini
Reply
#8

That's not true you can get it with dini.
The only question is "how?".

My person spawns on another place then the Class spawn. That means there is something good and the is something wrong.

But It Can Be With Dini
Reply
#9

It can't be done with dini. Dini assigns values to keys, It can't create multidimentional arrays. The only way it can be done is the way a few posts up
Reply
#10

This could be done with the file functions & sscanf:
pawn Код:
//On top of the script
//20 spawns for example
new Float:Spawns[20][3];

//Somewhere below
stock LoadSpawns()
{
    new read[15];
    new File:fSpawns = fopen("filename.txt", io_read);
    new Float:x, Float:y, Float:z;
    new i = 0;
    while(fread(fSpawns, read))
    {
        if(!sscanf(read, "fff", x, y, z))
        {
            Spawns[i][0] = x;
            Spawns[i][1] = y;
            Spawns[i][2] = z;
            i++;
        }
    }
    fclose(fSpawns);
    return 1;
}
The file would have to look like this:
pawn Код:
1235.756 789.123 785.12
1337.999 5543.65 15.992
Just do LoadSpawns() in OnGameModeInit and the spawns will go nicely into the Spawns array.
To spawn a player:
pawn Код:
SetPlayerPos(playerid, Spawns[0][0], Spawns[0][1], Spawns[0][2]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)