SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 06/04/2012, 06:28 PM   #1
HarrySidwell
Big Clucker
 
Join Date: Nov 2011
Posts: 69
Reputation: 0
Default 2 Questions.

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:
Code:
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.
HarrySidwell is offline   Reply With Quote
Old 06/04/2012, 06:29 PM   #2
nmader
Gangsta
 
Join Date: Jul 2011
Posts: 625
Reputation: 50
Default Re: 2 Questions.

I would personally check the tutorial section, I have seen multiple tutorials for it.
__________________
Country Side Roleplay
Server IP: samp.countryside-rp.com
Teamspeak: ts.countryside-rp.com
Website: countryside-rp.com
nmader is offline   Reply With Quote
Old 06/04/2012, 06:30 PM   #3
HarrySidwell
Big Clucker
 
Join Date: Nov 2011
Posts: 69
Reputation: 0
Default Re: 2 Questions.

I have looked and can;t see any :/.
HarrySidwell is offline   Reply With Quote
Old 06/04/2012, 06:30 PM   #4
Jack.7331
Big Clucker
 
Join Date: Mar 2012
Posts: 164
Reputation: 3
Default Re: 2 Questions.

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 Code:
public OnPlayerConnect(playerid) {
    if(playerVariables[playerid][pNewbie] == 0)
    {
    SetPlayerCheckpoint()
    }
Jack.7331 is offline   Reply With Quote
Old 06/04/2012, 06:53 PM   #5
HarrySidwell
Big Clucker
 
Join Date: Nov 2011
Posts: 69
Reputation: 0
Default Re: 2 Questions.

Quote:
Originally Posted by Jack.7331 View Post
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 Code:
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):
Code:
                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:
Code:
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:
Code:
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 (c) 1997-2006, ITB CompuPhase


2 Errors.
(289) is the pNewbie line
HarrySidwell is offline   Reply With Quote
Old 06/04/2012, 06:39 PM   #6
Kitten
High-roller
 
Kitten's Avatar
 
Join Date: Jul 2010
Location: Canada
Posts: 2,344
Reputation: 242
Default Re: 2 Questions.

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 Code:
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 Code:
public OnPlayerEnterCheckpoint(playerid)
{
     if(Logged[playerid] == 1)
     {
          // accesses the checkpoint
     }
     else
     {
          SendClientMessage(playerid,-1,"You are not registered");
     }
     return 1;
}
__________________

DayZ SA:MP on going Development via PGA Gaming https://www.youtube.com/watch?v=JUrEvAuTwSw
Kitten is offline   Reply With Quote
Old 06/04/2012, 06:59 PM   #7
Kindred
High-roller
 
Kindred's Avatar
 
Join Date: Aug 2011
Location: The Netherlands
Posts: 1,365
Reputation: 256
Default Re: 2 Questions.

pawn Code:
PlayerInfo[playerid][pNewbie] += 1);

Considering the fact you have a random ) in between the 1 and the ;, just remove it.

pawn Code:
PlayerInfo[playerid][pNewbie] += 1;

Should work, if not incorrect.
__________________
[17:36:08] Brad: remember how stuartd got fired from his own server twice
Kindred is offline   Reply With Quote
Old 06/04/2012, 07:18 PM   #8
HarrySidwell
Big Clucker
 
Join Date: Nov 2011
Posts: 69
Reputation: 0
Default Re: 2 Questions.

Thanks, how would I set a Var for it like pCheckpoint = 1; then I got to OnPlayerEnterCheckpoint case 1: blahh ?
HarrySidwell is offline   Reply With Quote
Old 06/04/2012, 07:25 PM   #9
Kitten
High-roller
 
Kitten's Avatar
 
Join Date: Jul 2010
Location: Canada
Posts: 2,344
Reputation: 242
Default Re: 2 Questions.

@HarrySidwell

pawn Code:
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.
__________________

DayZ SA:MP on going Development via PGA Gaming https://www.youtube.com/watch?v=JUrEvAuTwSw
Kitten is offline   Reply With Quote
Old 06/04/2012, 07:42 PM   #10
HarrySidwell
Big Clucker
 
Join Date: Nov 2011
Posts: 69
Reputation: 0
Default Re: 2 Questions.

No one get's me...
I have defined this in the Enum;
Code:
[pCheckpoint]
Now if I go to OnPlayerConnect:
Code:
    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)
HarrySidwell is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A few questions ... Danny Help Archive 1 03/11/2010 02:55 PM
questions Black_Sun1 Help Archive 4 31/10/2010 06:02 PM
Two questions Crayon Help Archive 4 20/10/2010 10:27 PM


All times are GMT. The time now is 06:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.