enum pInfo { // Other enum's float:pPosX, float:pPosY, float:pPosZ, }
public OnPlayerConnect(playerid) {
if(playerVariables[playerid][pNewbie] == 0)
{
SetPlayerCheckpoint()
}
enum E_POSITION_DATA
{
Float:e_fLastX,
Float:e_fLastY,
Float:e_fLastZ,
Float:e_fLastAngle,
e_iLastWorld,
e_iLastInt,
};
new PositionData[MAX_PLAYERS][E_POSITION_DATA];
stock SaveLastPos(playerid)
{
new
File:PosFile,
fOutput[64],
FileDest[MAX_PLAYER_NAME + 64];
GetPlayerPos(playerid, PositionData[playerid][e_fLastX], PositionData[playerid][e_fLastY], PositionData[playerid][e_fLastZ]);
GetPlayerFacingAngle(playerid, PositionData[playerid][e_fLastAngle]);
PositionData[playerid][e_iLastWorld] = GetPlayerVirtualWorld(playerid);
PositionData[playerid][e_iLastWorld] = GetPlayerInterior(playerid);
format(fOutput, sizeof(fOutput), "%f|%f|%f|%f|%d|%d",
PositionData[playerid][e_fLastX],
PositionData[playerid][e_fLastY],
PositionData[playerid][e_fLastZ],
PositionData[playerid][e_fLastAngle],
PositionData[playerid][e_iLastWorld],
PositionData[playerid][e_iLastInt]
);
GetPlayerName(playerid, FileDest, MAX_PLAYER_NAME);
format(FileDest, sizeof(FileDest), "lastpos/%s.txt", FileDest);
PosFile = fopen(FileDest, io_write);
fwrite(PosFile, fOutput);
fclose(PosFile);
}
stock LoadLastPos(playerid)
{
new
File:PosFile,
PosData[MAX_PLAYER_NAME + 64];
GetPlayerName(playerid, PosData, MAX_PLAYER_NAME);
format(PosData, sizeof(PosData), "lastpos/%s.txt", PosData);
if(fexist(PosData))
{
PosFile = fopen(PosData, io_read);
fread(PosFile, PosData);
fclose(PosFile);
sscanf(PosData, "p<|>ffffdd",
PositionData[playerid][e_fLastX],
PositionData[playerid][e_fLastY],
PositionData[playerid][e_fLastZ],
PositionData[playerid][e_fLastAngle],
PositionData[playerid][e_iLastWorld],
PositionData[playerid][e_iLastInt]
);
SetPlayerPos(playerid, PositionData[playerid][e_fLastX], PositionData[playerid][e_fLastY], PositionData[playerid][e_fLastZ]);
SetPlayerFacingAngle(playerid, PositionData[playerid][e_fLastAngle]);
SetPlayerVirtualWorld(playerid, PositionData[playerid][e_iLastWorld]);
SetPlayerInterior(playerid, PositionData[playerid][e_iLastInt]);
SetCameraBehindPlayer(playerid);
}
else
{
SetPlayerPos(playerid,x,y,z); // If they don't have a position saved they'll spawn here
}
}
public OnPlayerDisconnect(playerid) return SaveLastPos(playerid);
public OnPlayerSpawn(playerid) return LoadLastPos(playerid);
public OnPlayerEnterCheckpoint(playerid)
{
if(Logged[playerid] == 1)
{
// accesses the checkpoint
}
else
{
SendClientMessage(playerid,-1,"You are not registered");
}
return 1;
}
1) Not sure
2) You could have a variable pNewbie, so when they're new, the pNewbie is 0, if it's 0, then a checkpoint is forced. For example pawn Код:
|
ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COLOR_WHITE"Success!",""COLOR_GREEN"Congratulations, you have successfully made an account!\nNow you will begin to start your adventure!","Ok",""); SpawnPlayer(playerid); PlayerInfo[playerid][pNewbie] += 1);
public OnPlayerConnect(playerid) { if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,""COLOR_WHITE"Login",""COLOR_WHITE"Type your password below to login.","Login","Quit"); SpawnPlayer(playerid); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,""COLOR_WHITE"Registering...",""COLOR_WHITE"Type your password below to register a new account.","Register","Quit"); SpawnPlayer(playerid); } if(PlayerInfo[playerid][pNewbie] == 1) { SetPlayerCheckpoint(playerid, -2737.3635,-2414.0317,5.2657, 3.0); } return 1; }
C:\Users\Jordan\Desktop\0.3e Server\gamemodes\Gamemode.pwn(289) : error 001: expected token: ";", but found ")" C:\Users\Jordan\Desktop\0.3e Server\gamemodes\Gamemode.pwn(289) : error 029: invalid expression, assumed zero C:\Users\Jordan\Desktop\0.3e Server\gamemodes\Gamemode.pwn(289) : warning 215: expression has no effect Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 2 Errors.
PlayerInfo[playerid][pNewbie] += 1);
PlayerInfo[playerid][pNewbie] += 1;
new pCheckpoint[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
if(Logged[playerid] == true)
{
pCheckpoint[playerid] = true;
}
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(pCheckpoint[playerid] == true)
{
// etc...
}
return 1;
}
// you can replace true to 1.
[pCheckpoint]
if(PlayerInfo[playerid][pNewbie] == 1) { SetPlayerCheckpoint(playerid, -2737.3635,-2414.0317,5.2657, 3.0); PlayerInfo[playerid][pCheckpoint] = 1; // defined here }