Onplayerconnect ExistAccount(playerid);
stock ExistAccount(playerid)
{
#if USE_MYSQL == true
new query[128];
format(query, sizeof(query), "SELECT * FROM `"#MYSQL_TABLE"` WHERE `PlayerName` = '%s'", GetName(playerid));
if(mysql_ping(gSQL))
{
mysql_query(query, _THREAD_ACCOUNT_EXIST, playerid, gSQL);
}
#else
new file[128];
format(file, sizeof(file), "/%s/%s.ini", DINI_PATH, GetName(playerid));
if(dini_Exists(file))
{
if(IsPlayerDiniBanned(playerid))
{
new string[128];
format(string, sizeof(string), ""red"Your account has been banned!"white"\n\nBanned by:\t %s\nReason:\t %s\nBan Date:\t %s", dini_Get(file, "BannedBy"), dini_Get(file, "BanReason"), dini_Get(file, "BanDate"));
ShowPlayerDialog(playerid, BAN_DIALOG, DIALOG_STYLE_MSGBOX, " ", string, "OK", "");
KickEx(playerid);
}
else
{
#if USE_AUTO_LOGIN == true
new lastusedIP[16], IP[16];
GetPlayerIp(playerid, IP, sizeof(IP));
format(lastusedIP, sizeof(lastusedIP), "%s", dini_Get(file, "LastIP"));
if(!strcmp(IP, lastusedIP, true))
{
SendClientMessage(playerid, GREEN, "SERVER: You will get auto logged in now");
LoadPlayer(playerid);
LogPlayerIn(playerid);
SendClientMessage(playerid, GREEN, "You have been automatically logged in");
}else ShowPlayerLoginDialog(playerid);
#else
ShowPlayerLoginDialog(playerid);
#endif
}
}
else
{
ShowPlayerRegisterDialog(playerid);
}
#endif
return 1;
}
: error 017: undefined symbol "Now"|
It will have if you don't fix it. It's going to check if the account exists everytime a player re-spawns.
Honestly though, using it in OnPlayerSpawn seems very bad. Just set a timer after few seconds a player connects to show the dialog. Until the timer will be called, OnPlayerRequestClass would normally have been called. |
stock ShowPlayerRegisterDialog(playerid)
{
new string[256];
format(string, sizeof(string), ""white"Welcome to "blue""#SERVER_NAME""white","gold"\n"white"Your name "gold" %s "white"is not registered.\n\nPlease enter a password for your new account:", GetName(playerid), GetName(playerid));
ShowPlayerDialog(playerid, REGISTER_DIALOG, DIALOG_STYLE_PASSWORD, "Registration", string, "Register", "");
return 1;
}
|
kons I tried to put ExitAccount under OnPlayerRequestSpawn everytime I choose a character or the ">" its show "You have been successfully created!" again and again (very bad idea) [..]
|
|
I didn't mean IN the callback, a timer that until the time OnPlayerRequestClass will be called (5 seconds after a player connects).
So set a timer when a player connects with repeat to false and after 5 seconds it will check if the account exists. EDIT: Yes, it is. |