PDA

View Full Version : How to check if a player is new?


Jamcraftadam
11/08/2013, 11:53 AM
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 :)

DobbysGamertag
11/08/2013, 12:58 PM
Add a boolean to your script :)



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

Misiur
11/08/2013, 12:59 PM
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

RajatPawar
11/08/2013, 01:41 PM
If a player is new - that means he's just registered. Add whatever you want to do after that!

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)

Jamcraftadam
11/08/2013, 02:15 PM
Add a boolean to your script :)



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 ;)