14.02.2014, 11:15
I made it so that you cannot spawn if you're still at the register/login screen by adding the following to the OnPlayerSpawn callback:
If the player succesfully registers or logs in the IsLoggedIn gets set to 1.
This works, however now if you log in or register, and you press spawn it doesn't work, you first need to select a different class before the spawn button works again..
I tried this at OnPlayerRequestSpawn:
But that doesn't work either.
Here is my log in/register system:
LOG IN/REGISTER:
DIALOGS:
Код HTML:
if (IsLoggedIn[playerid] == 0) { ForceClassSelection(playerid); TogglePlayerSpectating(playerid, true); TogglePlayerSpectating(playerid, false); }
This works, however now if you log in or register, and you press spawn it doesn't work, you first need to select a different class before the spawn button works again..
I tried this at OnPlayerRequestSpawn:
Код HTML:
if (IsLoggedIn[playerid] == 1) { SpawnPlayer(playerid) }
Here is my log in/register system:
LOG IN/REGISTER:
Код HTML:
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; }
Код HTML:
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;
}