How to check if a player is new?
#1

Hello, I have created my login system, and I want to check if a player is new to the server, after registering. How is that done? (I prefer OnPlayerSpawn if possible ), I have searched but I cannot find a topic like the situation I am after. Thank you in advance
Reply
#2

Add a boolean to your script

pawn Код:
new bool:IsNew[MAX_PLAYERS];

//somewhere you check if they've registered. EG, showing a register dialog.

IsNew[playerid]=true;

//Actually adding the account, or making them "not new".

IsNew[playerid]=false;

//example
public OnPlayerSpawn(playerid)
{
    if(IsNew[playerid]==true)
    {
        SendClientMessage(playerid,-1,"Welcome.");
        IsNew[playerid]=false;
    }
    return 1;
}
Hope it helped
Reply
#3

Well, if you have login system, this means that you already implemented some kind of storage system. Check if file for this user exists and based on that you can tell that he already registered.

#e: Oh, after registering - you need to store this information in file/database then load it and check it
Reply
#4

If a player is new - that means he's just registered. Add whatever you want to do after that!
pawn Код:
public OnPlayerRegister(playerid)
{
         register_player_account(playerid..);
         Do_Whatever_with_him_because_he's_new( playerid );
}
Because obviously - a player registers only once! (Unless, a faulty login system)
Reply
#5

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Add a boolean to your script

pawn Код:
new bool:IsNew[MAX_PLAYERS];

//somewhere you check if they've registered. EG, showing a register dialog.

IsNew[playerid]=true;

//Actually adding the account, or making them "not new".

IsNew[playerid]=false;

//example
public OnPlayerSpawn(playerid)
{
    if(IsNew[playerid]==true)
    {
        SendClientMessage(playerid,-1,"Welcome.");
        IsNew[playerid]=false;
    }
    return 1;
}
Hope it helped
Alrighty, I'll give this one try, Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)