2 Questions.
#1

Hello,
(This is a blank gamemode)

1) I am using Y_INI for the Saving System, how would I make it load a players Last coords? I have the floats defined:
Код:
enum pInfo
{
// Other enum's
	float:pPosX,
	float:pPosY,
	float:pPosZ,
}
2) How would I make a checkpoint for people that have only just registered?
Do I need to define justLogged and stuff like that? Can someone give me an example please.
Reply
#2

I would personally check the tutorial section, I have seen multiple tutorials for it.
Reply
#3

I have looked and can;t see any :/.
Reply
#4

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 Код:
public OnPlayerConnect(playerid) {
    if(playerVariables[playerid][pNewbie] == 0)
    {
    SetPlayerCheckpoint()
    }
Reply
#5

1.

Not using y_ini you can convert it by you're self (i'm not a y_ini person (file functions or dini )

pawn Код:
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);
EDIT:

2.

Get you're defines/variables to registration system.

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
     if(Logged[playerid] == 1)
     {
          // accesses the checkpoint
     }
     else
     {
          SendClientMessage(playerid,-1,"You are not registered");
     }
     return 1;
}
Reply
#6

Quote:
Originally Posted by Jack.7331
Посмотреть сообщение
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 Код:
public OnPlayerConnect(playerid) {
    if(playerVariables[playerid][pNewbie] == 0)
    {
    SetPlayerCheckpoint()
    }
I took on your advice, defined the pNewbie and when a new player registered(under the register Dialog):
Код:
                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);
This is my OnPlayerConnect:
Код:
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;
}
And I get these errors:
Код:
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.
(289) is the pNewbie line
Reply
#7

pawn Код:
PlayerInfo[playerid][pNewbie] += 1);
Considering the fact you have a random ) in between the 1 and the ;, just remove it.

pawn Код:
PlayerInfo[playerid][pNewbie] += 1;
Should work, if not incorrect.
Reply
#8

Thanks, how would I set a Var for it like pCheckpoint = 1; then I got to OnPlayerEnterCheckpoint case 1: blahh ?
Reply
#9

@HarrySidwell

pawn Код:
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.
Reply
#10

No one get's me...
I have defined this in the Enum;
Код:
[pCheckpoint]
Now if I go to OnPlayerConnect:
Код:
    if(PlayerInfo[playerid][pNewbie] == 1)
    {
        SetPlayerCheckpoint(playerid, -2737.3635,-2414.0317,5.2657, 3.0);
        PlayerInfo[playerid][pCheckpoint] = 1; // defined here
    }
Now if I go to OnPlayerEnterCheckpoint and use
Case 1:
{
// stuff here
}

Why does it not work? (Im new to the checkpoint stuff)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)