if (IsLoggedIn[playerid] == 0) { ForceClassSelection(playerid); TogglePlayerSpectating(playerid, true); TogglePlayerSpectating(playerid, false); }
if (IsLoggedIn[playerid] == 1) { SpawnPlayer(playerid) }
public OnPlayerRequestClass(playerid, classid) { /* if (GodMode[playerid] == 1) { SpawnPlayer(playerid); SetPlayerPos } else {*/ SetPlayerInterior(playerid,11); SetPlayerPos(playerid,508.7362,-87.4335,998.9609); SetPlayerFacingAngle(playerid,0.0); SetPlayerCameraPos(playerid,508.7362,-83.4335,998.9609); SetPlayerCameraLookAt(playerid,508.7362,-87.4335,998.9609); if (IsLoggedIn[playerid] == 0) { if(fexist(UserPath(playerid))) { INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit"); } else { ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit"); } } else { switch(classid) { case 105, 106, 107: { GameTextForPlayer(playerid, "~g~Grove", 3000, 3); } case 102, 103, 104: { GameTextForPlayer(playerid, "~g~Ballas", 3000, 3); } } } return 1; }
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch( dialogid )
{
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext))
{
return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
else if(strlen(inputtext) < 4)
{
return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"Your password needs to have atleast 4 characters.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
else if(strlen(inputtext) > 16)
{
return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"Your password can only have a maximum of 16 characters.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit");
}
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Password",udb_hash(inputtext));
INI_WriteInt(File,"PasswordLength",strlen(inputtext));
INI_WriteString(File,"PasswordDecrypted",inputtext);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Kills",0);
INI_WriteInt(File,"Deaths",0);
INI_Close(File);
IsLoggedIn[playerid] = 1;
SpawnPlayer(playerid);
ForceClassSelection(playerid);
TogglePlayerSpectating(playerid, true);
TogglePlayerSpectating(playerid, false);
new name[MAX_PLAYER_NAME+1], string[64+MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "%s has joined the server for the first time, be sure to welcome him/her!", name);
SendClientMessageToAll(0xC4C4C4FF, string);
}
}
case DIALOG_LOGIN:
{
if ( !response ) return Kick ( playerid );
if( response )
{
if(udb_hash(inputtext) == PlayerInfo[playerid][pPass])
{
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok","");
IsLoggedIn[playerid] = 1;
SpawnPlayer(playerid);
ForceClassSelection(playerid);
TogglePlayerSpectating(playerid, true);
TogglePlayerSpectating(playerid, false);
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit");
}
return 1;
}
}
}
return 1;
}
return 0 at OnPlayerRequestSpawn to prevent him from spawning, return 1 to allow him to spawn, you don't need to SpawnPlayer (which will bug if you haven't used SetSpawnInfo).
|
public OnPlayerRequestSpawn(playerid) { /*if (IsLoggedIn[playerid] == 0) { ForceClassSelection(playerid); TogglePlayerSpectating(playerid, true); TogglePlayerSpectating(playerid, false); }*/ if (IsLoggedIn[playerid] == 1) { return 1; } return 0; }
if (IsLoggedIn[playerid] == 0 { return 0; } else { return 1; }