accept application messing up if players offline
#1

So when a player is offline it says the Server: %s has started to review your application, for the player reviewing the application though the players not online, Also when I get to the accept application part it takes the one who is reviewing the application to the character creation screen.

Start reviewing the application
PHP код:
case ApplicationPick:
        {
            if(!
response)
            {
                
SendClientMessage(playeridCOLOR_ORANGE"Server: You have closed the application viewer, you shouldn't keep players waiting.");
                return 
1;
            }
            new 
str[956];
            new 
id GetPlayerIdFromName(ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
            
ReviewingApplicationID[playerid] = PlayerSelect[playerid][listitem];
            
format(strsizeof(str), "Server: %s has started to review %s application."PlayerInfo[playerid][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
            
SendAdminMessage(COLOR_ORANGEstr);
            
format(strsizeof(str), "{0099FF}Application by %s\n\nQuestion 1:{FFFFFF}What does OOC and IC stand for?\n\
            {0099FF}Answer: %s\nQuestion 2:{FFFFFF}What is Revenge killing?\n{0099FF}Answer: %s"
ApplicationInfo[ReviewingApplicationID[playerid]][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Question1], ApplicationInfo[ReviewingApplicationID[playerid]][Question2]);
            
ShowPlayerDialog(playeridApplicationReviewDIALOG_STYLE_MSGBOX"Reviewing application"str"Next""Cancel");
            
SetPVarInt(playerid"Questions"1);
            if(
IsPlayerConnected(id)) {
                
format(strsizeof(str), "Server: %s has started to review your application."PlayerInfo[playerid][AdminName]);
                
SendClientMessage(id0x42F3F198str);
            }
        } 
Accepting the application
PHP код:
case ApplicationReview:
        {
            if(!
response)
            {
                if(
GetPVarInt(playerid"Questions") < 3)
                {
                    
SendClientMessage(playeridCOLOR_ORANGE"Server: You have closed the application viewer, you shouldn't keep players waiting.");
                    return 
1;
                }
                else {
                    new 
id GetPlayerIdFromName(ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                    if(
IsPlayerConnected(id)) {
                        new 
query[128];
                        
mysql_format(mysqlquerysizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'"ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                        
mysql_pquery(mysqlquery);
                        
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
                        
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
                        new 
str[256];
                        
format(strsizeof(str), "Server: %s has denied your application, Please re-submit with better answers."PlayerInfo[playerid][Name]);
                        
SendClientMessage(id0x42F3F198str);
                        
AdminsOnline(id);
                        
SetPVarInt(playerid"Questions"0);
                        
SetPVarInt(id"Questions"1);
                        
SetPVarInt(id"AppMade"0);
                    }
                    else {
                        new 
query[128];
                        
mysql_format(mysqlquerysizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'"ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                        
mysql_pquery(mysqlquery);
                        
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
                        
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
                    }
                }
            }
            if(
GetPVarInt(playerid"Questions") == 1)
            {
                new 
str[956];
                
format(strsizeof(str), "{0099FF}Application by %s\n\nQuestion 3:{FFFFFF}Give us an example of a /me command\n\
                {0099FF}Answer: %s\nQuestion 4:{FFFFFF}Give us an example of a /do command\n{0099FF}Answer: %s"
ApplicationInfo[ReviewingApplicationID[playerid]][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Question3], ApplicationInfo[ReviewingApplicationID[playerid]][Question4]);
                
ShowPlayerDialog(playeridApplicationReviewDIALOG_STYLE_MSGBOX"Reviewing application"str"Next""Cancel");
                
SetPVarInt(playerid"Questions"2);
                return 
1;
            }
            if(
GetPVarInt(playerid"Questions") == 2)
            {
                new 
str[956];
                
format(strsizeof(str), "{0099FF}Application by %s\n\nQuestion 5:{FFFFFF}What do you do when you spot a hacker?\n\
                {0099FF}Answer: %s\nQuestion 6:{FFFFFF}What is pg or powergaming?\n{0099FF}Answer: %s"
ApplicationInfo[ReviewingApplicationID[playerid]][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Question5], ApplicationInfo[ReviewingApplicationID[playerid]][Question6]);
                
ShowPlayerDialog(playeridApplicationReviewDIALOG_STYLE_MSGBOX"Reviewing application"str"Accept""Deny");
                
SetPVarInt(playerid"Questions"3);
                return 
1;
            }
            if(
GetPVarInt(playerid"Questions") == 3)
            {
                new 
id GetPlayerIdFromName(ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                if(
IsPlayerConnected(id)) {
                    new 
str[256];
                    
format(strsizeof(str), "Server: %s has accepted your application."PlayerInfo[playerid][Name]);
                    
SendClientMessage(id0x42F3F198str);
                    
SetPVarInt(id"PassedRPTest"1);
                    
ShowCreateCharacterMenu(id);
                    
OnPlayerAccountSave(id);
                    new 
query[128];
                    
mysql_format(mysqlquerysizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'"ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                    
mysql_pquery(mysqlquery);
                    
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
                    
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
                    
SetPVarInt(playerid"Questions"0);
                    return 
1;
                }
                else {
                    new 
query[128];
                    
mysql_format(mysqlquerysizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'"ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                    
mysql_pquery(mysqlquery);
                    
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
                    
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
                    new 
str[256];
                    
format(strsizeof(str), "Server: %s is offline, When they come back on they will have passed."ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                    
SendClientMessage(playerid0x42F3F198str);
                    new 
querylist[256];
                    
mysql_format(mysqlquerylistsizeof(querylist), "UPDATE `accounts` SET `Admin` = %d, `PassedRPTest` = %d, `CharactersMade` = %d, `AppMade` = %d WHERE `name` = '%e'" GetPVarInt(playerid"Admin"), GetPVarInt(playerid"PassedRPTest"), GetPVarInt(playerid"CharactersMade"), GetPVarInt(playerid"AppMade"), ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
                    
mysql_query(mysqlquerylist);
                    
SetPVarInt(playerid"Questions"0);
                    return 
1;
                }
            }
        } 
Getting the players ID from the players name to check if they are online or not.
PHP код:
stock GetPlayerIdFromName(playername[])
{
  for(new 
0<= MAX_PLAYERSi++)
  {
    if(
IsPlayerConnected(i))
    {
      new 
playername2[MAX_PLAYER_NAME];
      
GetPlayerName(iplayername2sizeof(playername2));
      if(
strcmp(playername2playernametruestrlen(playername)) == 0)
      {
        return 
i;
      }
    }
  }
  return -
1;

Reply
#2

Can't you just save his unique ID from mysql in a variable so you can also accept or deny the application while he is offline?
Reply
#3

Quote:
Originally Posted by AndreiWow
Посмотреть сообщение
Can't you just save his unique ID from mysql in a variable so you can also accept or deny the application while he is offline?
That was easier thanks man.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)