public OnPlayerConnect(playerid)
{
new nname[MAX_PLAYER_NAME];
GetPlayerName(playerid, nname, 24);
if(strfind(nname, "[GTA]", true) != -1)
{
if(PlayerInfo[playerid][Accepted] == 1)
{
SendClientMessage(playerid, 0x00A1A9FF, "Congratulations! You are part of our Community [GTA]. Be proud to use our tag!");
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot use our [GTA] tag. You're not a member. Apply on forums to get this tag");
Kick(playerid);
}
}
return 1;
}
Well... The value is set when the player registers in server.
I thought if I don't set a value for "Accepted" automatically will be 0. |
Is there any way to check if player is not "Accepted" when he connects?
Or Is there any way to check if Is the first time the player joins in the server? |
public OnPlayerConnect(playerid)
{
new string[256];
if(fexist(Path(playerid)))
{
INI_ParseFile(Path(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
format(string, 256, "Welcome back {1580EA}%s. {D4D4D4}This account is registered. \nInsert your password to login to your account", Name(playerid));
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login",string,"Login","Quit");
}
else
{
PlayerInfo[playerid][Accepted] = 0;
format(string, sizeof(string), "Welcome! {1580EA}%s. {D4D4D4}This account is not registered.\nEnter your own password to create a new account.", Name(playerid));
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register",string,"Register","Quit");
return 1;
}
new nname[MAX_PLAYER_NAME];
GetPlayerName(playerid, nname, 24);
if(strfind(nname, "[GTA]", true) != -1)
{
if(PlayerInfo[playerid][Accepted] == 1)
{
SendClientMessage(playerid, 0x00A1A9FF, "Congratulations! You are part of our Community [GTA]. Be proud to use our tag!");
}
if(PlayerInfo[playerid][Accepted] == 0)
{
SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot use our [GTA] tag. You're not a member. Apply on forums to get this tag");
Kick(playerid);
}
}
return 1;
}
if(dialogid == DIALOG_REGISTER)
{
if(!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Welcome! This account is not registered.\nEnter your own password to create a new account.\nPlease enter the password!","Register","Quit");
return 1;
}
new hashpass[129];
WP_Hash(hashpass,sizeof(hashpass),inputtext);
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file,"Player's Data");
INI_WriteString(file,"Password",hashpass);
INI_WriteInt(file,"MemberAccepted",0);//here it's writing the value to 0.
INI_Close(file);
SendClientMessage(playerid,-1,"You are now registered on this server");
return 1;
}
}