My Position Resets [Help!]
#1

Here is my code: http://pastebin.com/Jab9UYK3

If anyone can fix this so it won't spawn me back in my spawn when I log on and take me to where I was located when I logged off, that would be awesome and I would appriciate it.

Reply
#2

That`s funny )
Have you tried to do something with this?
Try to do it and if you have problems post here.
Save the x,y,z when player disconects and then spawn the player at that x,y,z.
Reply
#3

Quote:
Originally Posted by TzAkS.
Посмотреть сообщение
That`s funny )
Have you tried to do something with this?
Try to do it and if you have problems post here.
Save the x,y,z when player disconects and then spawn the player at that x,y,z.
How?
Reply
#4

enum
PHP код:
pLastx
plLasty
pLastz
then on loading player 
Ini_float lastx 
 Ini_float lasty
 Ini_float lastz
then to save it 
do getplayerposition(playeridlastxlastylastz)
and 
write it to enum
ini_writefloat lastx 
etc
etc 
Sorry writing from phone , if you need better explained say it and i will do it tomorrow.
Reply
#5

Quote:
Originally Posted by caki
Посмотреть сообщение
enum
PHP код:
pLastx
plLasty
pLastz
then on loading player 
Ini_float lastx 
 Ini_float lasty
 Ini_float lastz
then to save it 
do getplayerposition(playeridlastxlastylastz)
and 
write it to enum
ini_writefloat lastx 
etc
etc 
Sorry writing from phone , if you need better explained say it and i will do it tomorrow.
Put the exact code tomorrow and tell me where to put it, if it works Ill +REP you
Reply
#6

pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    Float:pX,
    Float:pY,
    Float:pZ,
    Float:pZr
}

new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
        INI_Int("Password",PlayerInfo[playerid][pPass]);
        INI_Int("Cash",PlayerInfo[playerid][pCash]);
        INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
        INI_Int("Kills",PlayerInfo[playerid][pKills]);
        INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
        INI_Float("XPos",PlayerInfo[playerid][pX]);
        INI_Float("YPos",PlayerInfo[playerid][pY]);
        INI_Float("ZPos",PlayerInfo[playerid][pZ]);
        INI_Float("Angle",PlayerInfo[playerid][pZr]);
        return 1;
}
public OnPlayerSpawn(playerid)
{
 SetPlayerPos(playerid,PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ]);
 SetPlayerFacingAngle(playerid,PlayerInfo[playerid][pZr]);
 SetCameraBehindPlayer(playerid);
 return 1;
}

public OnPlayerDeath(playerid,killerid,reason)
{
 PlayerInfo[playerid][pX] = 0;//Regular Spawnpoint (X)
 PlayerInfo[playerid][pY] = 0;//Regular Spawnpoint (Y)
 PlayerInfo[playerid][pZ] = 0;//Regular Spawnpoint (Z)
 PlayerInfo[playerid][pZr] = 0;//Regular Spawnpoint (Angle)
 PlayerInfo[killerid][pKills]++;
 PlayerInfo[playerid][pDeaths]++;
 return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
 switch(GetPlayerState(playerid)){ case 1..6:
 {
  GetPlayerPos(playerid,PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ]);
  GetPlayerFacingAngle(playerid,PlayerInfo[playerid][pZr]);
 }}
 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,"Kills",PlayerInfo[playerid][pKills]);
 INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
 INI_WriteFloat(File,"XPos",PlayerInfo[playerid][pX]);
 INI_WriteFloat(File,"YPos",PlayerInfo[playerid][pY]);
 INI_WriteFloat(File,"ZPos,PlayerInfo[playerid][pZ]);
 INI_WriteFloat(File,"
Angle",PlayerInfo[playerid][pZr]);
 INI_Close(File);
 return 1;
}
Reply
#7

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pX,
    pY,
    pZ,
    pZr
}


public LoadUser_data(playerid,name[],value[])
{
        INI_Int("Password",PlayerInfo[playerid][pPass]);
        INI_Int("Cash",PlayerInfo[playerid][pCash]);
        INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
        INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
        return 1;
}
Replaced:

Код:
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
	INI_Int("Password",PlayerInfo[playerid][pPass]);
	INI_Int("Cash",PlayerInfo[playerid][pCash]);
	INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
	INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
 	return 1;
}
with

Код:
enum pInfo
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    pX,
    pY,
    pZ,
    pZr
}


public LoadUser_data(playerid,name[],value[])
{
        INI_Int("Password",PlayerInfo[playerid][pPass]);
        INI_Int("Cash",PlayerInfo[playerid][pCash]);
        INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
        INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
        return 1;
}
stock UserPath(playerid)
and got

Код:
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(38) : warning 235: public function lacks forward declaration (symbol "LoadUser_data")
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(40) : error 017: undefined symbol "PlayerInfo"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(40) : warning 215: expression has no effect
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(40) : error 001: expected token: ";", but found "]"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(40) : error 029: invalid expression, assumed zero
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(40) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#8

Try again, edited my code
Reply
#9

Quote:
Originally Posted by RedFusion
Посмотреть сообщение
Try again, edited my code
Nope

Replaced

Код:
/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
	new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
public OnPlayerConnect(playerid)
{
	if(fexist(UserPath(playerid)))
	{
		INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
	}
	else
	{
 		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
	}
	return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Welcome to OrbzGaming! Please RELOG to join the rest of the world!","Ok","");
			}
        }
with

Код:
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    Float:pX,
    Float:pY,
    Float:pZ,
    Float:pZr
}

new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
        INI_Int("Password",PlayerInfo[playerid][pPass]);
        INI_Int("Cash",PlayerInfo[playerid][pCash]);
        INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
        INI_Int("Kills",PlayerInfo[playerid][pKills]);
        INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
        INI_Float("XPos",PlayerInfo[playerid][pX]);
        INI_Float("YPos",PlayerInfo[playerid][pY]);
        INI_Float("ZPos",PlayerInfo[playerid][pZ]);
        INI_Float("Angle",PlayerInfo[playerid][pZr]);
        return 1;
}
public OnPlayerSpawn(playerid)
{
 SetPlayerPos(playerid,PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ]);
 SetPlayerFacingAngle(playerid,PlayerInfo[playerid][pZr]);
 SetCameraBehindPlayer(playerid);
 return 1;
}

public OnPlayerDeath(playerid)
{
 PlayerInfo[playerid][pX] = 0;//Regular Spawnpoint (X)
 PlayerInfo[playerid][pY] = 0;//Regular Spawnpoint (Y)
 PlayerInfo[playerid][pZ] = 0;//Regular Spawnpoint (Z)
 PlayerInfo[playerid][pZr] = 0;//Regular Spawnpoint (Angle)
 PlayerInfo[killerid][pKills]++;
 PlayerInfo[playerid][pDeaths]++;
 return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
 switch(GetPlayerState(playerid)){ case 1..6:
 {
  GetPlayerPos(playerid,PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ]);
  GetPlayerFacingAngle(playerid,PlayerInfo[playerid][pZr]);
 }}
 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,"Kills",PlayerInfo[playerid][pKills]);
 INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
 INI_WriteFloat(File,"XPos",PlayerInfo[playerid][pX]);
 INI_WriteFloat(File,"YPos",PlayerInfo[playerid][pY]);
 INI_WriteFloat(File,"ZPos,PlayerInfo[playerid][pZ]);
 INI_WriteFloat(File,"Angle",PlayerInfo[playerid][pZr]);
 INI_Close(File);
 return 1;
}

        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]);
					ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Got

Код:
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(66) : error 017: undefined symbol "killerid"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(78) : error 017: undefined symbol "UserPath"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : error 037: invalid string (possibly non-terminated string)
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : error 017: undefined symbol "ZPos"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : error 029: invalid expression, assumed zero
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Reply
#10

Quote:
Originally Posted by xXRealLegitXx
Посмотреть сообщение
Nope

Replaced

Код:
/*Credits to Dracoblue*/
stock udb_hash(buf[]) {
	new length=strlen(buf);
    new s1 = 1;
    new s2 = 0;
    new n;
    for (n=0; n<length; n++)
    {
       s1 = (s1 + buf[n]) % 65521;
       s2 = (s2 + s1)     % 65521;
    }
    return (s2 << 16) + s1;
}
public OnPlayerConnect(playerid)
{
	if(fexist(UserPath(playerid)))
	{
		INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  		ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit");
	}
	else
	{
 		ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
	}
	return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch( dialogid )
    {
        case DIALOG_REGISTER:
        {
            if (!response) return Kick(playerid);
            if(response)
            {
                if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
                new INI:File = INI_Open(UserPath(playerid));
                INI_SetTag(File,"data");
                INI_WriteInt(File,"Password",udb_hash(inputtext));
                INI_WriteInt(File,"Cash",0);
                INI_WriteInt(File,"Admin",0);
                INI_WriteInt(File,"Kills",0);
                INI_WriteInt(File,"Deaths",0);
                INI_Close(File);

                SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
                SpawnPlayer(playerid);
                ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Welcome to OrbzGaming! Please RELOG to join the rest of the world!","Ok","");
			}
        }
with

Код:
{
    pPass,
    pCash,
    pAdmin,
    pKills,
    pDeaths,
    Float:pX,
    Float:pY,
    Float:pZ,
    Float:pZr
}

new PlayerInfo[MAX_PLAYERS][pInfo];
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
        INI_Int("Password",PlayerInfo[playerid][pPass]);
        INI_Int("Cash",PlayerInfo[playerid][pCash]);
        INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
        INI_Int("Kills",PlayerInfo[playerid][pKills]);
        INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
        INI_Float("XPos",PlayerInfo[playerid][pX]);
        INI_Float("YPos",PlayerInfo[playerid][pY]);
        INI_Float("ZPos",PlayerInfo[playerid][pZ]);
        INI_Float("Angle",PlayerInfo[playerid][pZr]);
        return 1;
}
public OnPlayerSpawn(playerid)
{
 SetPlayerPos(playerid,PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ]);
 SetPlayerFacingAngle(playerid,PlayerInfo[playerid][pZr]);
 SetCameraBehindPlayer(playerid);
 return 1;
}

public OnPlayerDeath(playerid)
{
 PlayerInfo[playerid][pX] = 0;//Regular Spawnpoint (X)
 PlayerInfo[playerid][pY] = 0;//Regular Spawnpoint (Y)
 PlayerInfo[playerid][pZ] = 0;//Regular Spawnpoint (Z)
 PlayerInfo[playerid][pZr] = 0;//Regular Spawnpoint (Angle)
 PlayerInfo[killerid][pKills]++;
 PlayerInfo[playerid][pDeaths]++;
 return 1;
}

public OnPlayerDisconnect(playerid,reason)
{
 switch(GetPlayerState(playerid)){ case 1..6:
 {
  GetPlayerPos(playerid,PlayerInfo[playerid][pX],PlayerInfo[playerid][pY],PlayerInfo[playerid][pZ]);
  GetPlayerFacingAngle(playerid,PlayerInfo[playerid][pZr]);
 }}
 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,"Kills",PlayerInfo[playerid][pKills]);
 INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
 INI_WriteFloat(File,"XPos",PlayerInfo[playerid][pX]);
 INI_WriteFloat(File,"YPos",PlayerInfo[playerid][pY]);
 INI_WriteFloat(File,"ZPos,PlayerInfo[playerid][pZ]);
 INI_WriteFloat(File,"Angle",PlayerInfo[playerid][pZr]);
 INI_Close(File);
 return 1;
}

        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]);
					ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
                }
                else
                {
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
                }
                return 1;
            }
        }
    }
    return 1;
}
Got

Код:
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(66) : error 017: undefined symbol "killerid"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(78) : error 017: undefined symbol "UserPath"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : error 037: invalid string (possibly non-terminated string)
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : error 017: undefined symbol "ZPos"
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : error 029: invalid expression, assumed zero
C:\Users\Cody\Desktop\OrbzGaming\SAMP\Server\gamemodes\grandlarc.pwn(86) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


6 Errors.
Can you give me your entire Y_INI code? And ill edit the things I want edited?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)