/loadplace - it says i don't have /saveplace
#1

hello i just made my /loadplace command and /saveplace.
/saveplace works. but the /loadplace makes me strange.
even i do /saveplace it still not working and it says

"You don't have /saveplace, /saveplace first!"

maybe the problem is here

pawn Код:
/* OnDialogResponse - dialogid - DIALOG_REGISTER */
        dini_FloatSet(file, "X", PlayerInfo[playerid][PlX] = 0);
        dini_FloatSet(file, "Y", PlayerInfo[playerid][PlY] = 0);
        dini_FloatSet(file, "Z", PlayerInfo[playerid][PlZ] = 0);
        dini_IntSet(file, "Interior", PlayerInfo[playerid][InteriorP] = 0);
        dini_IntSet(file, "World", PlayerInfo[playerid][World] = 0);
but still i'm not sure if the problem is because of that one. just to be sure i put my /saveplace and /loadplace code below

pawn Код:
CMD:saveplace(playerid, params[])
{
    new pname[MAX_PLAYER_NAME],file[256];
    new Float:PX, Float:PY, Float:PZ;
    GetPlayerPos(playerid, PX, PY, PZ);
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][Admin] > 1)
    {
        format(file, sizeof(file), "ServerFiles/Users/%s.ini", pname);
        PlayerInfo[playerid][PlX] = PX;
        PlayerInfo[playerid][PlY] = PY;
        PlayerInfo[playerid][PlZ] = PZ;
        PlayerInfo[playerid][InteriorP] = GetPlayerInterior(playerid);
        PlayerInfo[playerid][World] = GetPlayerVirtualWorld(playerid);
        dini_FloatSet(file, "X", PlayerInfo[playerid][PlX]);
        dini_FloatSet(file, "Y", PlayerInfo[playerid][PlY]);
        dini_FloatSet(file, "Z", PlayerInfo[playerid][PlZ]);
        dini_IntSet(file, "Interior", PlayerInfo[playerid][InteriorP]);
        dini_IntSet(file, "World", PlayerInfo[playerid][World]);
        SendClientMessage(playerid, COLOR_GREEN, "| - You save your place location! - |");
        SendClientMessage(playerid, -1, "(/loadplace) to go back to your saved place location");
    }
    else return SendClientMessage(playerid, COLOR_RED, "You must be Administrator Level 1 or higher to use this command!");
    return 1;
}

CMD:loadplace(playerid, params[])
{
    new pname[MAX_PLAYER_NAME],file[256];
    new Float:PX, Float:PY, Float:PZ;
    GetPlayerPos(playerid, PX, PY, PZ);
    GetPlayerName(playerid, pname, sizeof(pname));
    if(PlayerInfo[playerid][Admin] > 1)
    {
        if(dini_Int(file, "X") == 0 || dini_Int(file, "Y") == 0 || dini_Int(file, "Z") == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "You do not have /saveplace!, /saveplace first!");
        }
        else
        {
            format(file, sizeof(file), "ServerFiles/Users/%s.ini", pname);
            PlayerInfo[playerid][PlX] = dini_Float(file, "X");
            PlayerInfo[playerid][PlY] = dini_Float(file, "Y");
            PlayerInfo[playerid][PlZ] = dini_Float(file, "Z");
            PlayerInfo[playerid][InteriorP] = dini_Int(file, "Interior");
            PlayerInfo[playerid][World] = dini_Int(file, "World");
            SetPlayerPos(playerid, PlayerInfo[playerid][PlX], PlayerInfo[playerid][PlY], PlayerInfo[playerid][PlZ]);
            SetPlayerInterior(playerid, PlayerInfo[playerid][InteriorP]);
            SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][World]);
            SendClientMessage(playerid, COLOR_GREEN, "| - You load your place location! - |");
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "You must be Administrator Level 1 or higher to use this command!");
    return 1;
}
Reply
#2

never mind. this comment is useless
Reply
#3

pawn Код:
if(dini_Int(file, "X") == 0 || dini_Int(file, "Y") == 0 || dini_Int(file, "Z") == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "You do not have /saveplace!, /saveplace first!");
        }
At this point, your 'file' variable is an empty string. Therefore dini can't open it and it will always fail.
Reply
#4

Quote:
Originally Posted by JamesC
Посмотреть сообщение
pawn Код:
if(dini_Int(file, "X") == 0 || dini_Int(file, "Y") == 0 || dini_Int(file, "Z") == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "You do not have /saveplace!, /saveplace first!");
        }
At this point, your 'file' variable is an empty string. Therefore dini can't open it and it will always fail.
so what should i do? i also try dini_Float but it didn't work either...
Reply
#5

pawn Код:
CMD:loadplace(playerid, params[])
{
    new pname[MAX_PLAYER_NAME],file[256];
    new Float:PX, Float:PY, Float:PZ;
    GetPlayerPos(playerid, PX, PY, PZ);
    GetPlayerName(playerid, pname, sizeof(pname));
    format(file, sizeof(file), "ServerFiles/Users/%s.ini", pname);
    if(PlayerInfo[playerid][Admin] > 1)
    {
        if(dini_Float(file, "X") == 0 || dini_Float(file, "Y") == 0 || dini_Float(file, "Z") == 0)
        {
            SendClientMessage(playerid, COLOR_RED, "You do not have /saveplace!, /saveplace first!");
        }
        else
        {
            PlayerInfo[playerid][PlX] = dini_Float(file, "X");
            PlayerInfo[playerid][PlY] = dini_Float(file, "Y");
            PlayerInfo[playerid][PlZ] = dini_Float(file, "Z");
            PlayerInfo[playerid][InteriorP] = dini_Int(file, "Interior");
            PlayerInfo[playerid][World] = dini_Int(file, "World");
            SetPlayerPos(playerid, PlayerInfo[playerid][PlX], PlayerInfo[playerid][PlY], PlayerInfo[playerid][PlZ]);
            SetPlayerInterior(playerid, PlayerInfo[playerid][InteriorP]);
            SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][World]);
            SendClientMessage(playerid, COLOR_GREEN, "| - You load your place location! - |");
        }
    }
    else return SendClientMessage(playerid, COLOR_RED, "You must be Administrator Level 1 or higher to use this command!");
    return 1;
}
Try this.
Reply
#6

Change
pawn Код:
if(dini_Int(file, "X") == 0 || dini_Int(file, "Y") == 0 || dini_Int(file, "Z") == 0)
>
pawn Код:
if(dini_Float(file, "X") == 0 || dini_Float(file, "Y") == 0 || dini_Float(file, "Z") == 0)
Because you're updating lines in the file as float, and you're checking it as integers.
Reply
#7

Quote:
Originally Posted by BaubaS
Посмотреть сообщение
Change
pawn Код:
if(dini_Int(file, "X") == 0 || dini_Int(file, "Y") == 0 || dini_Int(file, "Z") == 0)
>
pawn Код:
if(dini_Float(file, "X") == 0 || dini_Float(file, "Y") == 0 || dini_Float(file, "Z") == 0)
Because you're updating lines in the file as float, and you're checking it as integers.
Yup, but he also didn't specify what "File" is.
Reply
#8

Quote:
Originally Posted by BaubaS
Посмотреть сообщение
Change
pawn Код:
if(dini_Int(file, "X") == 0 || dini_Int(file, "Y") == 0 || dini_Int(file, "Z") == 0)
>
pawn Код:
if(dini_Float(file, "X") == 0 || dini_Float(file, "Y") == 0 || dini_Float(file, "Z") == 0)
Because you're updating lines in the file as float, and you're checking it as integers.
yo, thanks bro. +rep for you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)