12.10.2010, 00:24
Hi guys. How could I change all of that into an array?
What about the saving and loading?
pawn Код:
enum PlayerData
{
pWeapon1, pAmmo1,
pWeapon2, pAmmo2,
pWeapon3, pAmmo3,
pWeapon4, pAmmo4,
pWeapon5, pAmmo5,
pWeapon6, pAmmo6,
pWeapon7, pAmmo7,
pWeapon8, pAmmo8,
pWeapon9, pAmmo9,
pWeapon10, pAmmo10,
pWeapon11, pAmmo11,
pWeapon12, pAmmo12,
}
pawn Код:
stock SavePlayerWeapons(playerid)
{
if(PlayerStatistics[playerid][pAuth] == 1)
{
GetPlayerWeaponData(playerid, 1, PlayerStatistics[playerid][pWeapon1], PlayerStatistics[playerid][pAmmo1]);
GetPlayerWeaponData(playerid, 2, PlayerStatistics[playerid][pWeapon2], PlayerStatistics[playerid][pAmmo2]);
GetPlayerWeaponData(playerid, 3, PlayerStatistics[playerid][pWeapon3], PlayerStatistics[playerid][pAmmo3]);
GetPlayerWeaponData(playerid, 4, PlayerStatistics[playerid][pWeapon4], PlayerStatistics[playerid][pAmmo4]);
GetPlayerWeaponData(playerid, 5, PlayerStatistics[playerid][pWeapon5], PlayerStatistics[playerid][pAmmo5]);
GetPlayerWeaponData(playerid, 6, PlayerStatistics[playerid][pWeapon6], PlayerStatistics[playerid][pAmmo6]);
GetPlayerWeaponData(playerid, 7, PlayerStatistics[playerid][pWeapon7], PlayerStatistics[playerid][pAmmo7]);
GetPlayerWeaponData(playerid, 8, PlayerStatistics[playerid][pWeapon8], PlayerStatistics[playerid][pAmmo8]);
GetPlayerWeaponData(playerid, 9, PlayerStatistics[playerid][pWeapon9], PlayerStatistics[playerid][pAmmo9]);
GetPlayerWeaponData(playerid, 10, PlayerStatistics[playerid][pWeapon10], PlayerStatistics[playerid][pAmmo10]);
GetPlayerWeaponData(playerid, 11, PlayerStatistics[playerid][pWeapon11], PlayerStatistics[playerid][pAmmo11]);
GetPlayerWeaponData(playerid, 12, PlayerStatistics[playerid][pWeapon12], PlayerStatistics[playerid][pAmmo12]);
format(Query, sizeof(Query), "UPDATE `Accounts` SET `Weapon1` = '%d', `Weapon2` = '%d', `Weapon3` = '%d', `Weapon4` = '%d', `Weapon5` = '%d', `Weapon6` = '%d' WHERE `UserID` = '%d'", PlayerStatistics[playerid][pWeapon1], PlayerStatistics[playerid][pWeapon2], PlayerStatistics[playerid][pWeapon3], PlayerStatistics[playerid][pWeapon4], PlayerStatistics[playerid][pWeapon5], PlayerStatistics[playerid][pWeapon6], PlayerStatistics[playerid][pDatabaseID]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `Accounts` SET `Weapon7` = '%d', `Weapon8` = '%d', `Weapon9` = '%d', `Weapon10` = '%d', `Weapon11` = '%d', `Weapon12` = '%d' WHERE `UserID` = '%d'", PlayerStatistics[playerid][pWeapon7], PlayerStatistics[playerid][pWeapon8], PlayerStatistics[playerid][pWeapon9], PlayerStatistics[playerid][pWeapon10], PlayerStatistics[playerid][pWeapon11], PlayerStatistics[playerid][pWeapon12], PlayerStatistics[playerid][pDatabaseID]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `Accounts` SET `Ammo1` = '%d', `Ammo2` = '%d', `Ammo3` = '%d', `Ammo4` = '%d', `Ammo5` = '%d', `Ammo6` = '%d' WHERE `UserID` = '%d'", PlayerStatistics[playerid][pAmmo1], PlayerStatistics[playerid][pAmmo2], PlayerStatistics[playerid][pAmmo3], PlayerStatistics[playerid][pAmmo4], PlayerStatistics[playerid][pAmmo5], PlayerStatistics[playerid][pAmmo6], PlayerStatistics[playerid][pDatabaseID]);
mysql_query(Query);
format(Query, sizeof(Query), "UPDATE `Accounts` SET `Ammo7` = '%d', `Ammo8` = '%d', `Ammo9` = '%d', `Ammo10` = '%d', `Ammo11` = '%d', `Ammo12` = '%d' WHERE `UserID` = '%d'", PlayerStatistics[playerid][pAmmo7], PlayerStatistics[playerid][pAmmo8], PlayerStatistics[playerid][pAmmo9], PlayerStatistics[playerid][pAmmo10], PlayerStatistics[playerid][pAmmo11], PlayerStatistics[playerid][pAmmo12], PlayerStatistics[playerid][pDatabaseID]);
mysql_query(Query);
}
return 1;
}
stock GivePlayerSavedWeapons(playerid)
{
if(PlayerStatistics[playerid][pAuth] == 1)
{
SetPlayerArmedWeapon(playerid, 0);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon1], PlayerStatistics[playerid][pAmmo1]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon2], PlayerStatistics[playerid][pAmmo2]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon3], PlayerStatistics[playerid][pAmmo3]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon4], PlayerStatistics[playerid][pAmmo4]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon5], PlayerStatistics[playerid][pAmmo5]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon6], PlayerStatistics[playerid][pAmmo6]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon7], PlayerStatistics[playerid][pAmmo7]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon8], PlayerStatistics[playerid][pAmmo8]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon9], PlayerStatistics[playerid][pAmmo9]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon10], PlayerStatistics[playerid][pAmmo10]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon11], PlayerStatistics[playerid][pAmmo11]);
GivePlayerWeapon(playerid, PlayerStatistics[playerid][pWeapon12], PlayerStatistics[playerid][pAmmo12]);
}
return 1;
}