30.03.2017, 10:53
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
Accepting the application
Getting the players ID from the players name to check if they are online or not.
Start reviewing the application
PHP код:
case ApplicationPick:
{
if(!response)
{
SendClientMessage(playerid, COLOR_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(str, sizeof(str), "Server: %s has started to review %s application.", PlayerInfo[playerid][Name], ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
SendAdminMessage(COLOR_ORANGE, str);
format(str, sizeof(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(playerid, ApplicationReview, DIALOG_STYLE_MSGBOX, "Reviewing application", str, "Next", "Cancel");
SetPVarInt(playerid, "Questions", 1);
if(IsPlayerConnected(id)) {
format(str, sizeof(str), "Server: %s has started to review your application.", PlayerInfo[playerid][AdminName]);
SendClientMessage(id, 0x42F3F198, str);
}
}
PHP код:
case ApplicationReview:
{
if(!response)
{
if(GetPVarInt(playerid, "Questions") < 3)
{
SendClientMessage(playerid, COLOR_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(mysql, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
mysql_pquery(mysql, query);
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
new str[256];
format(str, sizeof(str), "Server: %s has denied your application, Please re-submit with better answers.", PlayerInfo[playerid][Name]);
SendClientMessage(id, 0x42F3F198, str);
AdminsOnline(id);
SetPVarInt(playerid, "Questions", 0);
SetPVarInt(id, "Questions", 1);
SetPVarInt(id, "AppMade", 0);
}
else {
new query[128];
mysql_format(mysql, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
mysql_pquery(mysql, query);
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
}
}
}
if(GetPVarInt(playerid, "Questions") == 1)
{
new str[956];
format(str, sizeof(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(playerid, ApplicationReview, DIALOG_STYLE_MSGBOX, "Reviewing application", str, "Next", "Cancel");
SetPVarInt(playerid, "Questions", 2);
return 1;
}
if(GetPVarInt(playerid, "Questions") == 2)
{
new str[956];
format(str, sizeof(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(playerid, ApplicationReview, DIALOG_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(str, sizeof(str), "Server: %s has accepted your application.", PlayerInfo[playerid][Name]);
SendClientMessage(id, 0x42F3F198, str);
SetPVarInt(id, "PassedRPTest", 1);
ShowCreateCharacterMenu(id);
OnPlayerAccountSave(id);
new query[128];
mysql_format(mysql, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
mysql_pquery(mysql, query);
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
SetPVarInt(playerid, "Questions", 0);
return 1;
}
else {
new query[128];
mysql_format(mysql, query, sizeof(query), "DELETE FROM `applications` WHERE `Name`= '%e'", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
mysql_pquery(mysql, query);
ApplicationInfo[ReviewingApplicationID[playerid]][ID] = 0;
ApplicationInfo[ReviewingApplicationID[playerid]][SentIn] = 0;
new str[256];
format(str, sizeof(str), "Server: %s is offline, When they come back on they will have passed.", ApplicationInfo[ReviewingApplicationID[playerid]][Name]);
SendClientMessage(playerid, 0x42F3F198, str);
new querylist[256];
mysql_format(mysql, querylist, sizeof(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(mysql, querylist);
SetPVarInt(playerid, "Questions", 0);
return 1;
}
}
}
PHP код:
stock GetPlayerIdFromName(playername[])
{
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
new playername2[MAX_PLAYER_NAME];
GetPlayerName(i, playername2, sizeof(playername2));
if(strcmp(playername2, playername, true, strlen(playername)) == 0)
{
return i;
}
}
}
return -1;
}