30.05.2015, 02:43
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_REGISTER:
{
if(!response)
{
SendClientMessageEx(playerid, COLOR_WHITE, "SERVER: You have been kicked out of the server because you failed to respond.");
Kick(playerid);
}
if(!IsValidPassword(inputtext))
{
SendClientMessageEx(playerid, COLOR_RED, "SERVER: The password you entered is invalid. Please use only alphabets and numbers in the password." );
return ShowPlayerDialogEx(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{00FF00}"SERVER_NAME" - Authentication", "{FFFFFF}Welcome "SERVER_NAME".\nPlease type in a password in the below field to register this account.", "Register", "Exit");
}
if(strlen(inputtext) < 3 || strlen(inputtext) > 24)
{
SendClientMessageEx(playerid, COLOR_RED, "SERVER: The password you entered is invalid. The length of the password should be between 3-24 characters" );
return ShowPlayerDialogEx(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "{00FF00}"SERVER_NAME" - Authentication", "{FFFFFF}Welcome "SERVER_NAME".\nPlease type in a password in the below field to register this account.", "Register", "Exit");
}
new szQuery[256];
format(szQuery, sizeof(szQuery), "INSERT INTO Accounts (Username, Password) VALUES ('%s', '%s')", DB_Escape(PlayerInfo[playerid][pUsername]), DB_Escape(HashInput(inputtext)));
db_query(Database, szQuery);
}
case DIALOG_LOGIN:
{
if(!response)
{
SendClientMessageEx(playerid, COLOR_WHITE, "SERVER: You have been kicked out of the server because you failed to respond.");
Kick(playerid);
}
new DBResult:dbresult, szQuery[256];
format(szQuery, sizeof(szQuery), "SELECT * FROM Accounts WHERE Username = '%s' AND Password = '%s'", DB_Escape(PlayerInfo[playerid][pUsername]), DB_Escape(HashInput(inputtext)));
dbresult = db_query(Database, szQuery);
if(db_num_rows(dbresult) > 0)
{
SetPVarInt(playerid, "gLogged", 1);
if(LoadPlayerAccount(playerid)) SendClientMessageEx(playerid, COLOR_WHITE, "SERVER: You have successfully logged into your account.");
else if(PlayerInfo[playerid][pBanned])
{
new string[128];
if(gettime() - PlayerInfo[playerid][pBanExpiry] > 0)
{
SendClientMessageEx(playerid, COLOR_WHITE, "Your ban date has passed and you have been unbanned from the server.");
PlayerInfo[playerid][pBanned] = 0;
format(PlayerInfo[playerid][pBanReason], 64, "(null)");
PlayerInfo[playerid][pBanExpiry] = 0;
}
else
{
format(string, sizeof(string), "{FFFFFF}Your account is banned!\nUsername: %s\nIP Address: %s\nBan Reason: %s\nExpires: %s\n\nIf you feel that this was a mistake and you wish to appeal,\nplease let us know at our website.", PlayerInfo[playerid][pUsername], PlayerInfo[playerid][pIP], PlayerInfo[playerid][pBanReason], gettimestamp(PlayerInfo[playerid][pBanExpiry], 3));
ShowPlayerDialogEx(playerid, DIALOG_BANINFO, DIALOG_STYLE_MSGBOX, "{FF0000}"SERVER_NAME" - Ban", string, "Exit","");
Kick(playerid);
}
}
else
{
DeletePVar(playerid, "FailedLoginAttempt");
TogglePlayerSpectating(playerid, false);
new score = (gettime() - PlayerInfo[playerid][pRegistered])/86400;
floatround(score, floatround_round);
SetPlayerScore(playerid, score);
if(PermissionCheck(playerid, 1))
{
new string[128];
format(string, sizeof(string), "SERVER: You are logged in as a %s.", GetAdminRank(playerid));
SendClientMessageEx(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "SERVER: %s has logged in as a %s.", GetPlayerNameEx(playerid), GetAdminRank(playerid));
SendAdminMessage(COLOR_WHITE, 4, string);
}
}
}
else
{
if(GetPVarInt(playerid, "FailedLoginAttempt") == 0)
{
SetPVarInt(playerid, "FailedLoginAttempt", 1);
SendClientMessageEx(playerid, COLOR_RED, "SERVER: The password you have entered is incorrect, please try again (1/3 attempts used).");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 1)
{
SetPVarInt(playerid, "FailedLoginAttempt", 2);
SendClientMessageEx(playerid, COLOR_RED, "SERVER: The password you have entered is incorrect, please try again (2/3 attempts used).");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 2)
{
SetPVarInt(playerid, "FailedLoginAttempt", 3);
SendClientMessageEx(playerid, COLOR_RED, "SERVER: The password you have entered is incorrect, please try again (3/3 attempts used).");
}
else if(GetPVarInt(playerid, "FailedLoginAttempt") == 3)
{
DeletePVar(playerid, "FailedLoginAttempt");
SendClientMessageEx(playerid, COLOR_RED, "SERVER: You have used up all your login attempts, and hence got kicked.");
Kick(playerid);
}
ShowPlayerDialogEx(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "{FF0000}"SERVER_NAME" - Authentication", "{FFFFFF}Welcome back to "SERVER_NAME".\nPlease type in your password in the below field to log in.", "Login", "Exit");
}
db_free_result(dbresult);
}
new string[128];
PlayerInfo[playerid][pSkin] = strval(inputtext);
SetPVarInt(playerid, "gLogged", 1);
TogglePlayerSpectating(playerid, false);
// First spawn parameters
PlayerInfo[playerid][pRegistered] = gettime();
PlayerInfo[playerid][pPositionX] = 1734.563;
PlayerInfo[playerid][pPositionY] = -1951.414;
PlayerInfo[playerid][pPositionZ] = 14.117;
PlayerInfo[playerid][pFacingAngle] = 0.000;
PlayerInfo[playerid][pInterior] = 0;
PlayerInfo[playerid][pVirtualWorld] = 0;
PlayerInfo[playerid][pHealth] = 100.0;
PlayerInfo[playerid][pArmour] = 0.0;
}
}
return 1;
}
PHP код:
1833) : error 002: only a single statement (or expression) can follow each "case"
(1833) : error 017: undefined symbol "string"
(1833) : warning 215: expression has no effect
(1833) : error 001: expected token: ";", but found "]"
(1833) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
4 Errors.