Help with Dini :S
#1

Ok this is the first time with dini and im still learning how it works what i want is to save the LogPos (Log Position) of the player when they Disconnect and then load it on Connect,I got the GetPlayerPos stuff done im just lost with Dini and wiki is not helping.

I want to save there position when they logout to a file...

Then load it if it exists when they connect...

Basically they spawn where they logged out.

Please help and reply in detail :S

pawn Код:
//Test
#include <a_samp>
#include <dini>

new Float:pX, Float:pY, Float:pZ;
new Float:LogPosX[MAX_PLAYERS];
new Float:LogPosY[MAX_PLAYERS];
new Float:LogPosZ[MAX_PLAYERS];

new bool:FirstLog[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    FirstLog[playerid] = true;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerPos(playerid, pX, pY, pZ);
    LogPosX[playerid] = pX;
    LogPosY[playerid] = pY;
    LogPosZ[playerid] = pZ;
    //My Dini Attempt XD
    if(!dini_Exists("LogPos.txt"))
    {
        dini_Create("LogPos.txt");
    }
    if(dini_Exists("LogPos.txt"))
    {
        dini_FloatSet("LogPos.txt","LogPosX","LogPosY","LogPosZ",pX,pY,pZ);//error 035: argument type mismatch (argument 3)
    }
    //End Of Dini Attempt XD
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(FirstLog[playerid] == true)
    {
    SetPlayerPos(playerid,LogPosX[playerid],LogPosY[playerid],LogPosZ[playerid]);
    FirstLog[playerid] = false;
    }
    return 1;
}
Reply
#2

You can't write 3 variables in one line like that. You need 3 separate functions.

Like this:
pawn Код:
dini_FloatSet("LogPos.txt", "LogPosX", pX);
dini_FloatSet("LogPos.txt", "LogPosY", pY);
dini_FloatSet("LogPos.txt", "LogPosZ", pZ);
Reply
#3

how do i load/read files and set the values?

EDIT:

And save there names to the files using %s and GetPlayerName ?
Reply
#4

Ok i think i got it now but how can i make the files with there names? It dont look like it will work unless there files are there names :S

how can i make LogPos.txt into LogPos/%s.txt so i gets and saves the positions to there names ??

Please help

pawn Код:
#include <a_samp>
#include <dini>

new Float:pX, Float:pY, Float:pZ;
new Float:LogPosX[MAX_PLAYERS];
new Float:LogPosY[MAX_PLAYERS];
new Float:LogPosZ[MAX_PLAYERS];

new bool:FirstLog[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    FirstLog[playerid] = true;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerPos(playerid, pX, pY, pZ);
    LogPosX[playerid] = pX;
    LogPosY[playerid] = pY;
    LogPosZ[playerid] = pZ;
    if(!dini_Exists("LogPos.txt"))
    {
        dini_Create("LogPos.txt");
    }
    if(dini_Exists("LogPos.txt"))
    {
        dini_FloatSet("LogPos.txt", "LogPosX", pX);
        dini_FloatSet("LogPos.txt", "LogPosY", pY);
        dini_FloatSet("LogPos.txt", "LogPosZ", pZ);
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(FirstLog[playerid] == true)
    {
    if(dini_Exists("LogPos.txt"))
    {
        LogPosX[playerid] = dini_Int("LogPos.txt", "LogPosX");
        LogPosY[playerid] = dini_Int("LogPos.txt", "LogPosY");
        LogPosZ[playerid] = dini_Int("LogPos.txt", "LogPosZ");
    }
    SetPlayerPos(playerid,LogPosX[playerid],LogPosY[playerid],LogPosZ[playerid]);
    FirstLog[playerid] = false;
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)