#1

PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    switch(
dialogid)
    {
        case 
DIALOG_REGISTER:
        {
            if(!
response)
            {
                
SendClientMessageEx(playeridCOLOR_WHITE"SERVER: You have been kicked out of the server because you failed to respond.");
                
Kick(playerid);
            }
            if(!
IsValidPassword(inputtext))
            {
                
SendClientMessageEx(playeridCOLOR_RED"SERVER: The password you entered is invalid. Please use only alphabets and numbers in the password." );
                return 
ShowPlayerDialogEx(playeridDIALOG_REGISTERDIALOG_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) < || strlen(inputtext) > 24)
            {
                
SendClientMessageEx(playeridCOLOR_RED"SERVER: The password you entered is invalid. The length of the password should be between 3-24 characters" );
                return 
ShowPlayerDialogEx(playeridDIALOG_REGISTERDIALOG_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(szQuerysizeof(szQuery), "INSERT INTO Accounts (Username, Password) VALUES ('%s', '%s')"DB_Escape(PlayerInfo[playerid][pUsername]), DB_Escape(HashInput(inputtext)));
            
db_query(DatabaseszQuery);
        }
        case 
DIALOG_LOGIN:
        {
            if(!
response)
            {
                
SendClientMessageEx(playeridCOLOR_WHITE"SERVER: You have been kicked out of the server because you failed to respond.");
                
Kick(playerid);
            }
            new 
DBResult:dbresultszQuery[256];
            
format(szQuerysizeof(szQuery), "SELECT * FROM Accounts WHERE Username = '%s' AND Password = '%s'"DB_Escape(PlayerInfo[playerid][pUsername]), DB_Escape(HashInput(inputtext)));
            
dbresult db_query(DatabaseszQuery);
            if(
db_num_rows(dbresult) > 0)
            {
                   
SetPVarInt(playerid"gLogged"1);
                if(
LoadPlayerAccount(playerid)) SendClientMessageEx(playeridCOLOR_WHITE"SERVER: You have successfully logged into your account.");
                else if(
PlayerInfo[playerid][pBanned])
                {
                       new 
string[128];
                    if(
gettime() - PlayerInfo[playerid][pBanExpiry] > 0)
                    {
                        
SendClientMessageEx(playeridCOLOR_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(stringsizeof(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(playeridDIALOG_BANINFODIALOG_STYLE_MSGBOX"{FF0000}"SERVER_NAME" - Ban"string"Exit","");
                        
Kick(playerid);
                    }
                }
                else
                {
                    
DeletePVar(playerid"FailedLoginAttempt");
                    
TogglePlayerSpectating(playeridfalse);
                    new 
score = (gettime() - PlayerInfo[playerid][pRegistered])/86400;
                    
floatround(scorefloatround_round);
                    
SetPlayerScore(playeridscore);
                    if(
PermissionCheck(playerid1))
                    {
                        new 
string[128];
                        
format(stringsizeof(string), "SERVER: You are logged in as a %s."GetAdminRank(playerid));
                        
SendClientMessageEx(playeridCOLOR_WHITEstring);
                        
format(stringsizeof(string), "SERVER: %s has logged in as a %s."GetPlayerNameEx(playerid), GetAdminRank(playerid));
                        
SendAdminMessage(COLOR_WHITE4string);
                    }
                }
            }
            else
            {
                if(
GetPVarInt(playerid"FailedLoginAttempt") == 0)
                {
                    
SetPVarInt(playerid"FailedLoginAttempt"1);
                    
SendClientMessageEx(playeridCOLOR_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(playeridCOLOR_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(playeridCOLOR_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(playeridCOLOR_RED"SERVER: You have used up all your login attempts, and hence got kicked.");
                    
Kick(playerid);
                }
                
ShowPlayerDialogEx(playeridDIALOG_LOGINDIALOG_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(playeridfalse);
            
// 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 002only a single statement (or expressioncan follow each "case"
(1833) : error 017undefined symbol "string"
(1833) : warning 215expression has no effect
(1833) : error 001expected token";"but found "]"
(1833) : fatal error 107too many error messages on one line
Compilation aborted
.Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
4 Errors

Reply
#2

What line is 1833? Single it out please.
Reply
#3

When you make a local variable, it means that you can use it only within the block where it was declared.So here you cannot use string in another block since it was declared in some other code block.Variable 'strings' scope is limited to else if(PlayerInfo[playerid][pBanned]) code block.

Code Block here means: { //code }

The solution is to move your 'new string[128]' to the top of the callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)