How to spawn a player at a saved location?
#1

This part, which will be below, will save the players location, but is there any way to make the player spawn at the saved location? I'm not sure how to make such a script so instead I just made a script where the player keeps spawning at the same place over and over again.

Код:
public OnPlayerDisconnect(playerid, reason)
{
	/* Reason of quiting */
    new
        szString[64],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid, name, MAX_PLAYER_NAME);

    switch(reason)
    {
        case 0: format(szString, sizeof szString, "%s left the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, "%s left the server. (Quit)", name);
        case 2: format(szString, sizeof szString, "%s left the server. (Kicked/Banned)", name);
    }
	/* Reason of quiting END */
	
    SendClientMessageToAll(0xC4C4C4FF, szString);

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteInt(File,"Sex", PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Skin", PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Location", PlayerInfo[playerid][pLocation]);
    INI_Close(File);
    return 1;
}
This is what makes the player spawn at the location when joining, I think.

Код:
        case DIALOG_LOCATION:
        {
			if(!response) return Kick(playerid);
            if(response)
            {
                if(listitem == 0)
                {
                     PlayerInfo[playerid][pLocation] = 0;
                     SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 942.0000,-4630.0000,2.2887,359.7559, 0, 0, 0, 0, 0, 0);
                     SpawnPlayer(playerid);
				}
   }
        }
        case DIALOG_LOGIN:
        {
            if ( !response ) return Kick ( playerid );
            if( response )
            {
                if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
                {
                    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
                    GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
                    SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 942.0000,-4630.0000,2.2887,359.7559, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                }
                else
                {
                    Kick(playerid);
                }
                return 1;
            }
        }
    }
    return 1;
I'm sorry for posting this same topic a second time, but the last one got too messy due to all my "BUMP"s.
Reply
#2

you need to change your cords of last spawning of that player

add somewhere

saveplayer(playerid)

stock it

define it ,
Good luck
Reply
#3

okay
pawn Код:
public OnPlayerDisconnect(playerid)
{
    new Float:x, Float:y, Float:z;
        new pname[MAX_PLAYER_NAME];
        new string[128];
        new file[60];
    GetPlayerPos(playerid, x, y, z);
        GetPlayerName(playerid,pname,sizeof(pname));
        format(file,sizeof(file),"/Users/%s.ini",pname);
        new INI:File = INI_Open(file);
        INI_WriteFloat(File,"posX", x);
        INI_WriteFloat(File,"posY", y);
        INI_WriteFloat(File,"posZ", z);
        INI_Close(File);
        return 1;
}
Reply
#4

Quote:
Originally Posted by MCZOFT
Посмотреть сообщение
you need to change your cords of last spawning of that player

add somewhere

saveplayer(playerid)

stock it

define it ,
Good luck
I'm not sure what you mean, I'm sorry.

Quote:
Originally Posted by Vanter
Посмотреть сообщение
okay
pawn Код:
public OnPlayerDisconnect(playerid)
{
    new Float:x, Float:y, Float:z;
        new pname[MAX_PLAYER_NAME];
        new string[128];
        new file[60];
    GetPlayerPos(playerid, x, y, z);
        GetPlayerName(playerid,pname,sizeof(pname));
        format(file,sizeof(file),"/Users/%s.ini",pname);
        new INI:File = INI_Open(file);
        INI_WriteFloat(File,"posX", x);
        INI_WriteFloat(File,"posY", y);
        INI_WriteFloat(File,"posZ", z);
        INI_Close(File);
        return 1;
}
Thanks Vanter for your help, but isn't that and this the same thing..-?

Код:
public OnPlayerDisconnect(playerid, reason)
{
	/* Reason of quiting */
    new
        szString[64],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid, name, MAX_PLAYER_NAME);

    switch(reason)
    {
        case 0: format(szString, sizeof szString, "%s left the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, "%s left the server. (Quit)", name);
        case 2: format(szString, sizeof szString, "%s left the server. (Kicked/Banned)", name);
    }
	/* Reason of quiting END */
	
    SendClientMessageToAll(0xC4C4C4FF, szString);

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteInt(File,"Sex", PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Skin", PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Location", PlayerInfo[playerid][pLocation]);
    INI_Close(File);
    return 1;
}
Oh and by the way can you please explain what you did so I kind of learn something from it? Thanks in advance!
Reply
#5

You're saving normal information, edit what I posted with the axis
new Float......
and GetPlayerPos(playerid, x, y, z);

then copy the INI_WriteFloat below your INI_WriteInt
then check the player file, you'll see the last coordinates the player was at
Reply
#6

Hmm..- I still don't seem to get it. Where do I add your code? And what do I do with this current one..-?

Код:
public OnPlayerDisconnect(playerid, reason)
{
	/* Reason of quiting */
    new
        szString[64],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid, name, MAX_PLAYER_NAME);

    switch(reason)
    {
        case 0: format(szString, sizeof szString, "%s left the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, "%s left the server. (Quit)", name);
        case 2: format(szString, sizeof szString, "%s left the server. (Kicked/Banned)", name);
    }
	/* Reason of quiting END */
	
    SendClientMessageToAll(0xC4C4C4FF, szString);

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteInt(File,"Sex", PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Skin", PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Location", PlayerInfo[playerid][pLocation]);
    INI_Close(File);
    return 1;
}
And I still don't understand how they aren't the same thing.
Reply
#7

Bump?
Reply
#8

BUMP
Reply
#9

Код:
public OnPlayerDisconnect(playerid, reason)
{
	/* Reason of quiting */
    new
        szString[64],
        name[MAX_PLAYER_NAME];

    GetPlayerName(playerid, name, MAX_PLAYER_NAME);

    switch(reason)
    {
        case 0: format(szString, sizeof szString, "%s left the server. (Timed Out/Crashed)", name);
        case 1: format(szString, sizeof szString, "%s left the server. (Quit)", name);
        case 2: format(szString, sizeof szString, "%s left the server. (Kicked/Banned)", name);
    }
	/* Reason of quiting END */
	
    SendClientMessageToAll(0xC4C4C4FF, szString);

	/* Saving Last Player Position*/
	new
		Float:PosX;
		Float:PosY;
		Float:PosZ;

	GetPlayerPos(playerid, PosX, PosY, PosZ);

    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File,"data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Age",PlayerInfo[playerid][pAge]);
    INI_WriteInt(File,"Sex",PlayerInfo[playerid][pSex]);
    INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
    INI_WriteInt(File,"Location",PlayerInfo[playerid][pLocation]);
    INI_WriteFloat(File,"LastPosX",PosX);
    INI_WriteFloat(File,"LastPosX",PosY);
    INI_WriteFloat(File,"LastPosX",PosZ);
    INI_Close(File);
    return 1;
}
Don't forget to fetch the data again and set him to the position when he comes back to the server.
Reply
#10

Thanks a lot Manyula, I kind of understand that. How do I fetch the data though? REP +
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)