pawn Код:
forward AccountExists(playerid); // Checks if the master account is already registered.
public AccountExists(playerid)
{
if(IsPlayerConnected(playerid))
{
new str[128];
format(str, sizeof(str), "SELECT `mID` FROM `MasterAccount` WHERE `mID` = '%s'", PlayerName(playerid));
mysql_query(gHandle, str);
if(cache_num_rows() >=1)
{
return true;
}
}
return false;
}
forward MasterAccountLogin(playerid, password[]); // Login to an existing master account.
public MasterAccountLogin(playerid, password[])
{
if(IsPlayerConnected(playerid))
{
if(AccountExists(playerid))
{
if(strlen(password) >= 1 && strlen(password) <= 20)
{
if(MasterAccount[playerid][mLoggedIn])
{
new rows, fields;
new value[128];
new query[128];
format(query, sizeof(query), "SELECT * FROM `MasterAccount` WHERE `username` = '%s' AND `mPassword` = '%s'", MasterAccount[playerid][mOriginalUsername] , MasterAccount[playerid][mPassword]);
cache_get_data(rows, fields);
if(rows >=1)
{
SetPlayerColor(playerid, COLOR_LIGHTGREEN);
MasterAccount[playerid][mLoggedIn] = true;
cache_get_field_content(0, "password", MasterAccount[playerid][mPassword], 20);
cache_get_field_content(0, "email_address", MasterAccount[playerid][mEmailAddress], 30);
cache_get_field_content(0, "ip_address", MasterAccount[playerid][mOld_IP], 20);
cache_get_field_content(0, "super_admin", value, 5); MasterAccount[playerid][mSuperAdmin] = strval(value);
cache_get_field_content(0, "id", value, 15); MasterAccount[playerid][mID] = strval(value);
ShowMenuDialog(playerid);
printf("Password: %s, Email Address: %s, Last IP Used: %s, Super Admin: %d, ID: %d.", MasterAccount[playerid][mPassword], MasterAccount[playerid][mEmailAddress], MasterAccount[playerid][mOld_IP], MasterAccount[playerid][mSuperAdmin], MasterAccount[playerid][mID]);
return true;
}
else
{
SetPVarInt(playerid, "LOGIN_ATTEMPTS", GetPVarInt(playerid, "LOGIN_ATTEMPTS") + 1);
switch(GetPVarInt(playerid, "LOGIN_ATTEMPTS"))
{
case 1: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
case 2: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
case 3: ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","The password you entered is incorrect.","Login","Cancel");
case 4: Kick(playerid);
}
}
}
}
else
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","Account already registered, please enter your password to continue.","Login","Cancel");
}
}
}
return false;
}
forward MasterAccountRegister(playerid); // Register a new Master Account if name not already in use.
public MasterAccountRegister(playerid)
{
if(!AccountExists(playerid))
{
new Query[300];
mysql_format(0, Query, sizeof (Query), "INSERT INTO Master (username,password,email_address,ip_address,super_admin,old_ip) VALUES ('%e' , '%e', '%e', '%e', 0, 'UNKNOWN')", PlayerName(playerid), GetPVarStringEx(playerid, "TEMP_PASSWORD"), GetPVarStringEx(playerid, "TEMP_EMAIL"), GetPlayerIPEx(playerid));
mysql_tquery(0, Query, "", "");
DeletePVar(playerid,"TEMP_EMAIL");
DeletePVar(playerid,"TEMP_PASSWORD");
return true;
}
return false;
}
forward ShowMenuDialog(playerid);
public ShowMenuDialog(playerid)
{
new count = 0; // , CharacterName[MAX_PLAYER_NAME];
format(MasterAccount[playerid][mCharacterString], 128, ""); // Resetting Character list string, because reading text from list is impossible.
if(MasterAccount[playerid][mLoggedIn])
{
new str[128];
format(str, sizeof(str), "SELECT * FROM `PlayerCharacter` WHERE ( `owner_id` = '%d' )", MasterAccount[playerid][mID]);
mysql_query(1, str);
if(cache_num_rows() >=1)
{
ShowPlayerDialog(playerid, DIALOG_MAIN_MENU, DIALOG_STYLE_LIST, "Main Menu - Character Selection", "No characters available.", "Spawn", "Options");
}
for(new a;a<count;a++)
{
new test[128];
cache_get_field_content(0, "name", test); //CharacterName, MAX_PLAYER_NAME);
format( MasterAccount[playerid][mCharacterString], 128, "%s\n ", MasterAccount[playerid][mCharacterString]); /*RemoveUnderScore(CharacterName)*//*%s*/
//db_next_row(qresult);
}
if(strlen(MasterAccount[playerid][mCharacterString]) >= 1) { ShowPlayerDialog(playerid, DIALOG_MAIN_MENU, DIALOG_STYLE_LIST, "Main Menu - Character Selection", MasterAccount[playerid][mCharacterString], "Spawn", "Options"); }
}
}
public OnPlayerConnect(playerid)
{
new query[128];
GetPlayerName(playerid, Player_Name[playerid], MAX_PLAYER_NAME);
GetPlayerIp(playerid, Player_Ip[playerid], 16);
mysql_format(1, query, sizeof(query),"SELECT `mPassword`, `ID` FROM `MainAccount` WHERE `mOriginalUsername` = '%e' LIMIT 1", Player_Name[playerid]);
mysql_tquery(1, query, "OnAccountCheck", "i", playerid);
// -------------------------- [ RESETTING VARIABLES ] ----------------------------
ResetPlayerCharacterVariables(playerid);
ResetMasterAccountVariables(playerid);
//-----------------------------[STARTUP CAMERA POS]-------------------------------
SetPlayerColor(playerid, COLOR_DARKGREY);
SetPlayerCameraPos(playerid, 2126.0251,1283.9984,63.0858);
SetPlayerCameraLookAt(playerid,92178.8748,1285.5367,39.5399);
if(AccountExists(playerid))
{
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Master Account - Login","Account already registered, please enter your password to continue.","Login","Cancel");
}
else
{
ShowPlayerDialog(playerid,DIALOG_REGISTER_PASSWORD,DIALOG_STYLE_INPUT,"Master Account Registration - Step One","Password:\n( No more or less than 20 characters )","Continue","Cancel");
}
ClearScreen(playerid);
SendClientMessage(playerid, COLOR_WHITE, "Welcome!");
return 1;
}
forward StartTimer(playerid);
public StartTimer(playerid)
{
new Text:JoinText;
new joinmsg[256];
if(MasterAccount[playerid][mLoggedIn] && Character[playerid][cAdminLevel] >= 1)
{
format(joinmsg, sizeof(joinmsg), "%s has joined the Server. {FFFFFF}IP: -To be done- ID: %d.", RemoveUnderScore(playerid), playerid); /*{FFFFFF}IP: %s GetIP(playerid), */
SendToAdmins(COLOR_RED, joinmsg, 0);
SendToAdmins(COLOR_RED, joinmsg, 1);
}
TextDrawHideForPlayer(playerid, JoinText);
// if(Player[playerid][RegistrationStep] == 0)
{
if(Character[playerid][SpawnPoint] == 1) //North Caravan Park
{
TogglePlayerSpectating(playerid, false);
if(Character[playerid][ClothesUsed] == 1)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 2)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 3)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 765.9069,361.9311,20.8550,174.3097, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
if(Character[playerid][Faction] == 3)
{
GivePlayerWeapon(playerid, 43, 20);
}
SetPlayerArmedWeapon(playerid, 0);
}
}
else if(Character[playerid][SpawnPoint] == 2) //Blueberry Caravan Park
{
TogglePlayerSpectating(playerid, false);
if(Character[playerid][ClothesUsed] == 1)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 252.1177,-310.5331,1.5836,52.7107, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 2)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 252.1177,-310.5331,1.5836,52.7107, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 3)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 252.1177,-310.5331,1.5836,52.7107, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
SetPlayerVirtualWorld(playerid, 0);
}
else if(Character[playerid][SpawnPoint] == 3) //Palomino Creek Caravan Park
{
TogglePlayerSpectating(playerid, false);
if(Character[playerid][ClothesUsed] == 1)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 2266.2488,27.3444,26.4328,4.8782, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SetPlayerVirtualWorld(playerid, 0);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 2)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 2266.2488,27.3444,26.4328,4.8782, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SetPlayerVirtualWorld(playerid, 0);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 3)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 2266.2488,27.3444,26.4328,4.8782, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
SetPlayerVirtualWorld(playerid, 0);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
}
else if(Character[playerid][SpawnPoint] == 4) //Montgomery Caravan Park
{
TogglePlayerSpectating(playerid, false);
if(Character[playerid][ClothesUsed] == 1)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], 1284.0914,168.3455,20.4620,354.0366, 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 2)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], 1284.0914,168.3455,20.4620,354.0366, 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 3)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], 1284.0914,168.3455,20.4620,354.0366, 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
}
else if(Character[playerid][SpawnPoint] == 5) //Owned Home
{
TogglePlayerSpectating(playerid, false);
if(Character[playerid][ClothesUsed] == 1)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], Houses[Character[playerid][HouseKey]][HouseExteriorX], Houses[Character[playerid][HouseKey]][HouseExteriorY], Houses[Character[playerid][HouseKey]][HouseExteriorZ], 90.0, 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 2)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], Houses[Character[playerid][HouseKey]][HouseExteriorX], Houses[Character[playerid][HouseKey]][HouseExteriorY], Houses[Character[playerid][HouseKey]][HouseExteriorZ], 90.0, 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 3)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], Houses[Character[playerid][HouseKey]][HouseExteriorX], Houses[Character[playerid][HouseKey]][HouseExteriorY], Houses[Character[playerid][HouseKey]][HouseExteriorZ], 90.0, 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
}
else if(Character[playerid][SpawnPoint] == 6) //Faction Spawn
{
TogglePlayerSpectating(playerid, false);
if(Character[playerid][ClothesUsed] == 1)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes1], Factions[Character[playerid][Faction]][fSpawnX], Factions[Character[playerid][Faction]][fSpawnY], Factions[Character[playerid][Faction]][fSpawnZ], Factions[Character[playerid][Faction]][fSpawnA], 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 2)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes2], Factions[Character[playerid][Faction]][fSpawnX], Factions[Character[playerid][Faction]][fSpawnY], Factions[Character[playerid][Faction]][fSpawnZ], Factions[Character[playerid][Faction]][fSpawnA], 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
else if(Character[playerid][ClothesUsed] == 3)
{
SetSpawnInfo(playerid, 0, Character[playerid][Clothes3], Factions[Character[playerid][Faction]][fSpawnX], Factions[Character[playerid][Faction]][fSpawnY], Factions[Character[playerid][Faction]][fSpawnZ], Factions[Character[playerid][Faction]][fSpawnA], 0, 0, 0, 0, 0, 0);
SetPlayerVirtualWorld(playerid, 0);
SpawnPlayer(playerid);
if(Character[playerid][Faction] == 1)
{
SetPlayerArmour(playerid, 100);
}
if(Character[playerid][Faction] == 2)
{
GivePlayerWeapon(playerid, 42, 99999);
}
SetPlayerArmedWeapon(playerid, 0);
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}