[Help] Saving Positions
#1

I want it so that it saves the players last known position and when they relog in they go to their last known position.

This is my disconnecting code:
Code:
public OnPlayerDisconnect(playerid, reason)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(gPlayerLogged[playerid] == 1)
{
new pCashs; //Player Money
pCashs = GetPlayerMoney(playerid); //gets the amount of playercash
dini_IntSet(file, "Money",pCashs); // puts it into file under "Money"
new pSkins; //Player Skins
pSkins = GetPlayerSkin(playerid); //Gets the player's skins
dini_IntSet(file, "Skin",pSkins); //Puts it into file under "Skin"
new pScores; //Player Score/Level
pScores = GetPlayerScore(playerid); //Gets the player's score
dini_IntSet(file, "Score",pScores); //Puts it into file under "Score"
new pPosition; //Player Position
pPosition = GetPlayerPos(playerid); //Gets the Player's score
dini_IntSet(file, "Position",pPosition); //Puts it into file under "Position"
}
gPlayerLogged[playerid] = 0;
return 1;
}
But it doesn't work and I get warnings .

Here is my Login code:
Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if (dialogid == 1)
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Account Not Registered", "Account Not Registered, Please Type A Password Below:", "Register", "Leave");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "AdminLevel",PlayerInfo[playerid][pAdminLevel] = 0);
dini_IntSet(file, "Money",PlayerInfo[playerid][pCash] = 500);
dini_IntSet(file, "Score",PlayerInfo[playerid][pScore] = 0);
dini_IntSet(file, "Health",PlayerInfo[playerid][pHealth] = 100);
dini_IntSet(file, "Armour",PlayerInfo[playerid][pArmour] = 0);
dini_IntSet(file, "Skin",PlayerInfo[playerid][pSkin] = 2);
format(string, 128, "[SYSTEM]: Account Successfully Registered", name, inputtext);
SendClientMessage(playerid, COLOR_GREEN, string);
gPlayerLogged[playerid] = 1;
}
if (dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if (!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account Already Registered", "Welcome Back, Type Your Password Below:", "Login", "Leave");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) != tmp) {
SendClientMessage(playerid, COLOR_RED, "The Password Which Was Entered Was Incorrect");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Account Already Registered", "Welcome Back, Type Your Password Below:", "Login", "Leave");
}
else
{
gPlayerLogged[playerid] = 1;
PlayerInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
SetPlayerScore(playerid, dini_Int(file, "Score"));
SetPlayerArmour(playerid, dini_Int(file, "Armour"));
SetPlayerHealth(playerid, dini_Int(file, "Health"));
SetPlayerSkin(playerid, dini_Int(file, "Skin"));
GivePlayerMoney(playerid, dini_Int(file, "Money")-GetPlayerMoney(playerid));
SendClientMessage(playerid,COLOR_GREEN, "[SYSTEM]: Successfully logged in!");
}
}
return 1;
}
Here is the warnings I get:
Code:
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining.pwn(153) : warning 202: number of arguments does not match definition
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining.pwn(153) : warning 202: number of arguments does not match definition
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining.pwn(153) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Here is line 153:
Code:
pPosition = GetPlayerPos(playerid); //Gets the Player's score
Reply
#2

I really am not sure what you mean? How can I create a array and where do I put it? Please Help Me and thanks.
Reply
#3

GetPlayerPos has 3 parameters look at the wiki
https://sampwiki.blast.hk/wiki/GetPlayerPos
Reply
#4

My Login/Registeration System was here:
https://sampforum.blast.hk/showthread.php?tid=167937

If anyone knows what I am doing wrong please tell me!
Reply
#5

Do what iggy told you to do,

pawn Code:
new Float:X,Float:Y,Float:Z;

        GetPlayerPos( playerid, X, Y, Z);
                dini_IntSet(file, "Position",X,Y,Z)
Then onplayerspawn
pawn Code:
SetPlayerPos(playerid, dini_Int(file, "Position"))
I THINK, maybe it might work now.
Reply
#6

Well it may work but I get these warnings:
Code:
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining bup.pwn(205) : warning 213: tag mismatch
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining bup.pwn(205) : warning 202: number of arguments does not match definition
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining bup.pwn(205) : warning 202: number of arguments does not match definition
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining bup.pwn(472) : warning 202: number of arguments does not match definition
C:\Users\SoSu\Desktop\SAMP Server\gamemodes\roleplaytraining bup.pwn(472) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


5 Warnings.
The Lines:
Line 205
Code:
dini_IntSet(file,"Position",X,Y,Z);
Line 472
Code:
SetPlayerPos(playerid, dini_Int(file, "Position"));
Reply
#7

205
pawn Code:
dini_FloatSet(file, "PositionX", X);
dini_FloatSet(file, "PositionY", Y);
dini_FloatSet(file, "PositionZ", Z);
472
pawn Code:
SetPlayerPos(playerid, dini_Float(file, "PositionX"), dini_Float(file, "PositionY"), dini_Float(file, "PositionZ"));
Reply
#8

I fixed this for her... and lorenc i fixed your login register system click my gamemode link its in it just grab what you need to repair yours..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)