PHP код:
stock SavePlayerAccount(playerid) {
new Float:Pos[4],TempWorld,TempInt,Float:tmpHP,Float:tmpArmour;
GetPlayerHealth(playerid,tmpHP);
GetPlayerArmour(playerid, tmpArmour);
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
TempWorld = GetPlayerVirtualWorld(playerid);
TempInt = GetPlayerInterior(playerid);
GetPlayerFacingAngle(playerid,Pos[3]);
GetPlayerWeaponData(playerid, 0, AccInfo[playerid][Weapon1], AccInfo[playerid][Weapon1Ammo]);
GetPlayerWeaponData(playerid, 1, AccInfo[playerid][Weapon2], AccInfo[playerid][Weapon2Ammo]);
GetPlayerWeaponData(playerid, 2, AccInfo[playerid][Weapon3], AccInfo[playerid][Weapon3Ammo]);
GetPlayerWeaponData(playerid, 3, AccInfo[playerid][Weapon4], AccInfo[playerid][Weapon4Ammo]);
GetPlayerWeaponData(playerid, 4, AccInfo[playerid][Weapon5], AccInfo[playerid][Weapon5Ammo]);
GetPlayerWeaponData(playerid, 5, AccInfo[playerid][Weapon6], AccInfo[playerid][Weapon6Ammo]);
GetPlayerWeaponData(playerid, 6, AccInfo[playerid][Weapon7], AccInfo[playerid][Weapon7Ammo]);
GetPlayerWeaponData(playerid, 7, AccInfo[playerid][Weapon8], AccInfo[playerid][Weapon8Ammo]);
GetPlayerWeaponData(playerid, 8, AccInfo[playerid][Weapon9], AccInfo[playerid][Weapon9Ammo]);
GetPlayerWeaponData(playerid, 9, AccInfo[playerid][Weapon10], AccInfo[playerid][Weapon10Ammo]);
GetPlayerWeaponData(playerid, 10, AccInfo[playerid][Weapon11], AccInfo[playerid][Weapon11Ammo]);
GetPlayerWeaponData(playerid, 11, AccInfo[playerid][Weapon12], AccInfo[playerid][Weapon12Ammo]);
if(AdminDuty[playerid] == 1) {
AccInfo[playerid][SavedHealth] = 100.00;
AccInfo[playerid][SavedArmour] = 100.00;
}
new query[2000] = "UPDATE `players` SET `Admin`=%d, `VIPLevel`=%d";
strcat(query,",`CharactersCreated`=%i,`PocketMoney`=%i,`HouseOwner`=%i,`EnteredHouse`=%i,\
`PlayerWorld`=%i,`PlayerInterior`=%i,`PositionX`=%f,`PositionY`=%f,`PositionZ`=%f");
strcat(query,",`PositionA`=%f,`Age`=%i,`Gender`=%i,`BankMoney`=%i,\
`SkinID`=%i,`VehiclesOwned`=%i,`Health`=%f,`Armour`=%f,`Banned`=%i,`EnteredHQ`=%i,`FactionID`=%i,`FishCaught`=%f,\
`FishingBait`=%i,`FishingRod`=%i,`FactionRank`=%i,`Leader`=%i");
strcat(query,",`Job`=%i,`Parts`=%i,`PlayerMods`=%i,`StartedAssembling`=%i,`AssemblingPart`=%i,\
`BannedWhen`=%i,`TimeOfBan`=%i,`DaysBanned`=%i,`AdminJailTime`=%i,`AdminJailed`=%i,`AdminJailedWhen`=%i,\
`EnteredBiz`=%i,`PlayerBusiness`=%i,`MP3`=%i,`Dice`=%i,`Cards`=%i,`Soda`=%i,\
`Energy`=%i,`ReportsCalled`=%i,`Apples`=%i,`Muted`=%i,`Tickets`=%i,`Crimes`=%i");
strcat(query,",`WeaponLicense`=%i,`NameChangeTokens`=%i,`Warnings`=%i,`Weed`=%i,\
`DriversLicense`=%i,`UniqueID`=%i,`PhoneNumber`=%i,\
`PhoneCredits`=%i,`Cocaine`=%i,`RightHandStatus`=%i,`LeftHandStatus`=%i,\
`LeftLegStatus`=%i,`RightLegStatus`=%i,`Food`=%i,`SpareSkin`=%i,`JoinedJob`=%i,`PaycheckClaimed`=%i");
strcat(query,",`Weapon1`=%i,`Weapon1Ammo`=%i,`Weapon2`=%i,`Weapon2Ammo`=%i,`Weapon3`=%i,`Weapon3Ammo`=%i,\
`Weapon4`=%i,`Weapon4Ammo`=%i,`Weapon5`=%i,`Weapon5Ammo`=%i,`Weapon6`=%i,`Weapon6Ammo`=%i,\
`Weapon7`=%i,`Weapon7Ammo`=%i,`Weapon8`=%i,`Weapon8Ammo`=%i,`Weapon9`=%i,`Weapon9Ammo`=%i,\
`Weapon10`=%i,`Weapon10Ammo`=%i");
strcat(query,",`Weapon11`=%i,`Weapon11Ammo`=%i,`Weapon12`=%i,`Weapon12Ammo`=%i,\
`BadgeNumber`=%i,`SpareHouseKey`=%i,`Crowbar`=%i,`Wanted`=%i,`WantedReason`='%q',`SecretCode`=%i,\
`CodeObtained`=%i,`SmuggledWhen`=%i,`PoliceJailed`=%i,`PoliceJailedWhen`=%i,`PaycheckPrice`=%i,\
`Watch`=%i,`Sandwich`=%i WHERE `Username`='%q'");
format(query, sizeof(query), query, AccInfo[playerid][Admin], AccInfo[playerid][VIPLevel],
AccInfo[playerid][CharsCreated],GetPlayerMoney(playerid),AccInfo[playerid][HouseOwner],
AccInfo[playerid][EnteredHouse],TempWorld,TempInt,Pos[0],Pos[1],Pos[2],Pos[3],AccInfo[playerid][Age],
AccInfo[playerid][Gender],AccInfo[playerid][BankMoney],
AccInfo[playerid][SkinID],AccInfo[playerid][vOwnedTotal],
tmpHP,tmpArmour,AccInfo[playerid][Banned],
AccInfo[playerid][EnteredFaction],AccInfo[playerid][PlayerFaction],AccInfo[playerid][FishCaught],
AccInfo[playerid][FishingBait],AccInfo[playerid][FishingRod],
AccInfo[playerid][PlayerRank],AccInfo[playerid][PlayerLeader],
AccInfo[playerid][PlayerJob],AccInfo[playerid][PlayerParts],
AccInfo[playerid][PlayerMods],AccInfo[playerid][StartedAssembling],
AccInfo[playerid][AssemblingPart],
AccInfo[playerid][BannedTime],AccInfo[playerid][BannedNow],
AccInfo[playerid][DaysBanned],AccInfo[playerid][AdminJailTime],AccInfo[playerid][AdminJailed],
AccInfo[playerid][AdminJailedWhen],AccInfo[playerid][EnteredBiz],
AccInfo[playerid][PlayerBusiness],AccInfo[playerid][PlayerMP3],
AccInfo[playerid][PlayerDice],AccInfo[playerid][PlayerCards],
AccInfo[playerid][PlayerSoda],AccInfo[playerid][PlayerEnergy],AccInfo[playerid][CalledReports],
AccInfo[playerid][ApplesPicked],AccInfo[playerid][Muted],AccInfo[playerid][PlayerTickets],
AccInfo[playerid][Crimes],AccInfo[playerid][WeaponLicense],AccInfo[playerid][NameToken],
AccInfo[playerid][Warnings],AccInfo[playerid][PlayerWeed],
AccInfo[playerid][DriversLicense],AccInfo[playerid][UniqueID],AccInfo[playerid][PhoneNumber],
AccInfo[playerid][PhoneCredits],AccInfo[playerid][PlayerCocaine],
AccInfo[playerid][RightHandStatus],AccInfo[playerid][LeftHandStatus],
AccInfo[playerid][LeftLegStatus],AccInfo[playerid][RightLegStatus],
AccInfo[playerid][PlayerFood],AccInfo[playerid][SpareSkin],AccInfo[playerid][JoinedJobWhen],AccInfo[playerid][ClaimedPaycheck],
AccInfo[playerid][Weapon1],AccInfo[playerid][Weapon1Ammo],
AccInfo[playerid][Weapon2],AccInfo[playerid][Weapon2Ammo],
AccInfo[playerid][Weapon3],AccInfo[playerid][Weapon3Ammo],
AccInfo[playerid][Weapon4],AccInfo[playerid][Weapon4Ammo],
AccInfo[playerid][Weapon5], AccInfo[playerid][Weapon5Ammo],
AccInfo[playerid][Weapon6], AccInfo[playerid][Weapon6Ammo],
AccInfo[playerid][Weapon7], AccInfo[playerid][Weapon7Ammo],
AccInfo[playerid][Weapon8], AccInfo[playerid][Weapon8Ammo],
AccInfo[playerid][Weapon9], AccInfo[playerid][Weapon9Ammo],
AccInfo[playerid][Weapon10], AccInfo[playerid][Weapon10Ammo],
AccInfo[playerid][Weapon11], AccInfo[playerid][Weapon11Ammo],
AccInfo[playerid][Weapon12], AccInfo[playerid][Weapon12Ammo],
AccInfo[playerid][PlayerBadge],AccInfo[playerid][SpareHouseKey],
AccInfo[playerid][PlayerCrowbar],AccInfo[playerid][PlayerWanted],
AccInfo[playerid][WantedReason],AccInfo[playerid][SecretCode],AccInfo[playerid][SecretCodeWhen],
AccInfo[playerid][SmuggledWhen],AccInfo[playerid][PoliceJailed],AccInfo[playerid][PoliceJailedWhen],
AccInfo[playerid][PlayerCheck],AccInfo[playerid][PlayerWatch],AccInfo[playerid][PlayerSandwich],GetName(playerid));
mysql_tquery(mysql, query, "", "");
print(query);
return true;
}
PHP код:
public OnAccountLoad(playerid)
{
AccInfo[playerid][ID] = cache_get_field_content_int(0, "ID");
AccInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin");
AccInfo[playerid][VIPLevel] = cache_get_field_content_int(0, "VIPLevel");
AccInfo[playerid][PocketMoney] = cache_get_field_content_int(0, "PocketMoney");
AccInfo[playerid][HouseOwner] = cache_get_field_content_int(0, "HouseOwner");
AccInfo[playerid][EnteredHouse] = cache_get_field_content_int(0, "EnteredHouse");
AccInfo[playerid][PlayerWorld] = cache_get_field_content_int(0, "PlayerWorld");
AccInfo[playerid][PlayerInterior] = cache_get_field_content_int(0, "PlayerInterior");
AccInfo[playerid][PositionX] = cache_get_field_content_float(0, "PositionX");
AccInfo[playerid][PositionY] = cache_get_field_content_float(0, "PositionY");
AccInfo[playerid][PositionZ] = cache_get_field_content_float(0, "PositionZ");
AccInfo[playerid][Angle] = cache_get_field_content_float(0, "PositionA");
AccInfo[playerid][Age] = cache_get_field_content_int(0, "Age");
AccInfo[playerid][Gender] = cache_get_field_content_int(0, "Gender");
AccInfo[playerid][BankMoney] = cache_get_field_content_int(0, "BankMoney");
AccInfo[playerid][SkinID] = cache_get_field_content_int(0, "SkinID");
AccInfo[playerid][vOwnedTotal] = cache_get_field_content_int(0,"VehiclesOwned");
AccInfo[playerid][SavedHealth] = cache_get_field_content_int(0,"Health");
AccInfo[playerid][SavedArmour] = cache_get_field_content_int(0,"Armour");
AccInfo[playerid][EnteredFaction] = cache_get_field_content_int(0, "EnteredHQ");
AccInfo[playerid][PlayerFaction] = cache_get_field_content_int(0,"FactionID");
AccInfo[playerid][FishCaught] = cache_get_field_content_float(0,"FishCaught");
AccInfo[playerid][FishingBait] = cache_get_field_content_int(0,"FishingBait");
AccInfo[playerid][FishingRod] = cache_get_field_content_int(0,"FishingRod");
AccInfo[playerid][PlayerRank] = cache_get_field_content_int(0, "FactionRank");
AccInfo[playerid][PlayerLeader] = cache_get_field_content_int(0, "Leader");
AccInfo[playerid][PlayerJob] = cache_get_field_content_int(0, "Job");
AccInfo[playerid][PlayerParts] = cache_get_field_content_int(0, "Parts");
AccInfo[playerid][PlayerMods] = cache_get_field_content_int(0,"PlayerMods");
AccInfo[playerid][StartedAssembling] = cache_get_field_content_int(0,"StartedAssembling");
AccInfo[playerid][AssemblingPart] = cache_get_field_content_int(0,"AssemblingPart");
AccInfo[playerid][BannedTime] = cache_get_field_content_int(0,"BannedWhen");
AccInfo[playerid][BannedNow] = cache_get_field_content_int(0,"TimeOfBan");
AccInfo[playerid][DaysBanned] = cache_get_field_content_int(0,"DaysBanned");
AccInfo[playerid][AdminJailTime] = cache_get_field_content_int(0,"AdminJailTime");
AccInfo[playerid][AdminJailed] = cache_get_field_content_int(0,"AdminJailed");
AccInfo[playerid][AdminJailedWhen] = cache_get_field_content_int(0,"AdminJailedWhen");
AccInfo[playerid][EnteredBiz] = cache_get_field_content_int(0,"EnteredBiz");
AccInfo[playerid][PlayerBusiness] = cache_get_field_content_int(0,"PlayerBusiness");
AccInfo[playerid][PlayerMP3] = cache_get_field_content_int(0,"MP3");
AccInfo[playerid][PlayerDice] = cache_get_field_content_int(0,"Dice");
AccInfo[playerid][PlayerCards] = cache_get_field_content_int(0,"Cards");
AccInfo[playerid][PlayerSoda] = cache_get_field_content_int(0,"Soda");
AccInfo[playerid][PlayerEnergy] = cache_get_field_content_int(0,"Energy");
AccInfo[playerid][CalledReports] = cache_get_field_content_int(0,"ReportsCalled");
AccInfo[playerid][ApplesPicked] = cache_get_field_content_int(0,"Apples");
AccInfo[playerid][Muted] = cache_get_field_content_int(0,"Muted");
AccInfo[playerid][PlayerTickets] = cache_get_field_content_int(0,"Tickets");
AccInfo[playerid][Crimes] = cache_get_field_content_int(0,"Crimes");
AccInfo[playerid][WeaponLicense] = cache_get_field_content_int(0,"WeaponLicense");
AccInfo[playerid][NameToken] = cache_get_field_content_int(0,"NameChangeTokens");
AccInfo[playerid][Warnings] = cache_get_field_content_int(0,"Warnings");
AccInfo[playerid][PlayerWeed] = cache_get_field_content_int(0,"Weed");
AccInfo[playerid][DriversLicense] = cache_get_field_content_int(0,"DriversLicense");
AccInfo[playerid][UniqueID] = cache_get_field_content_int(0,"UniqueID");
AccInfo[playerid][PhoneNumber] = cache_get_field_content_int(0,"PhoneNumber");
AccInfo[playerid][PhoneCredits] = cache_get_field_content_int(0,"PhoneCredits");
AccInfo[playerid][PlayerCocaine] = cache_get_field_content_int(0,"Cocaine");
AccInfo[playerid][RightHandStatus] = cache_get_field_content_int(0,"RightHandStatus");
AccInfo[playerid][LeftHandStatus] = cache_get_field_content_int(0,"LeftHandStatus");
AccInfo[playerid][LeftLegStatus] = cache_get_field_content_int(0,"LeftLegStatus");
AccInfo[playerid][RightLegStatus] = cache_get_field_content_int(0,"RightLegStatus");
AccInfo[playerid][PlayerFood] = cache_get_field_content_int(0,"Food");
AccInfo[playerid][SpareSkin] = cache_get_field_content_int(0,"SpareSkin");
AccInfo[playerid][JoinedJobWhen] = cache_get_field_content_int(0,"JoinedJob");
AccInfo[playerid][ClaimedPaycheck] = cache_get_field_content_int(0,"PaycheckClaimed");
AccInfo[playerid][Weapon1] = cache_get_field_content_int(0,"Weapon1");
AccInfo[playerid][Weapon1Ammo] = cache_get_field_content_int(0,"Weapon1Ammo");
AccInfo[playerid][Weapon2] = cache_get_field_content_int(0,"Weapon2");
AccInfo[playerid][Weapon2Ammo] = cache_get_field_content_int(0,"Weapon2Ammo");
AccInfo[playerid][Weapon3] = cache_get_field_content_int(0,"Weapon3");
AccInfo[playerid][Weapon3Ammo] = cache_get_field_content_int(0,"Weapon3Ammo");
AccInfo[playerid][Weapon4] = cache_get_field_content_int(0,"Weapon4");
AccInfo[playerid][Weapon4Ammo] = cache_get_field_content_int(0,"Weapon4Ammo");
AccInfo[playerid][Weapon5] = cache_get_field_content_int(0,"Weapon5");
AccInfo[playerid][Weapon5Ammo] = cache_get_field_content_int(0,"Weapon5Ammo");
AccInfo[playerid][Weapon6] = cache_get_field_content_int(0,"Weapon6");
AccInfo[playerid][Weapon6Ammo] = cache_get_field_content_int(0,"Weapon6Ammo");
AccInfo[playerid][Weapon7] = cache_get_field_content_int(0,"Weapon7");
AccInfo[playerid][Weapon7Ammo] = cache_get_field_content_int(0,"Weapon7Ammo");
AccInfo[playerid][Weapon8] = cache_get_field_content_int(0,"Weapon8");
AccInfo[playerid][Weapon8Ammo] = cache_get_field_content_int(0,"Weapon8Ammo");
AccInfo[playerid][Weapon9] = cache_get_field_content_int(0,"Weapon9");
AccInfo[playerid][Weapon9Ammo] = cache_get_field_content_int(0,"Weapon9Ammo");
AccInfo[playerid][Weapon10] = cache_get_field_content_int(0,"Weapon10");
AccInfo[playerid][Weapon10Ammo] = cache_get_field_content_int(0,"Weapon10Ammo");
AccInfo[playerid][Weapon11] = cache_get_field_content_int(0,"Weapon11");
AccInfo[playerid][Weapon11Ammo] = cache_get_field_content_int(0,"Weapon11Ammo");
AccInfo[playerid][Weapon12] = cache_get_field_content_int(0,"Weapon12");
AccInfo[playerid][Weapon12Ammo] = cache_get_field_content_int(0,"Weapon12Ammo");
AccInfo[playerid][PlayerBadge] = cache_get_field_content_int(0,"BadgeNumber");
AccInfo[playerid][SpareHouseKey] = cache_get_field_content_int(0,"SpareHouseKey");
AccInfo[playerid][PlayerCrowbar] = cache_get_field_content_int(0,"Crowbar");
AccInfo[playerid][PlayerWanted] = cache_get_field_content_int(0,"Wanted");
AccInfo[playerid][SecretCode] = cache_get_field_content_int(0,"SecretCode");
AccInfo[playerid][SecretCodeWhen] = cache_get_field_content_int(0,"CodeObtained");
AccInfo[playerid][SmuggledWhen] = cache_get_field_content_int(0,"SmuggledWhen");
AccInfo[playerid][PoliceJailed] = cache_get_field_content_int(0,"PoliceJailed");
AccInfo[playerid][PoliceJailedWhen] = cache_get_field_content_int(0,"PoliceJailedWhen");
AccInfo[playerid][PlayerCheck] = cache_get_field_content_int(0,"PaycheckPrice");
AccInfo[playerid][PlayerWatch] = cache_get_field_content_int(0,"Watch");
AccInfo[playerid][PlayerSandwich] = cache_get_field_content_int(0,"Sandwich");
Msg(playerid, -1, "Successfully logged in");
SetTimerEx("SpawnPlayerFromLogin",2000,false,"i",playerid);
new string[64];
format(string,sizeof(string),"{00FF00}Welcome back {C0A9FF}%s",GetRoleplayName(playerid));
Msg(playerid,COLOR_GREEN,string);
Msg(playerid,COLOR_GREEN,"{00FF00}Please wait while we load your account from the database.");
IsSpawned[playerid] = 1;
GivePlayerMoney(playerid,AccInfo[playerid][PocketMoney]);
cache_get_field_content(0, "NickName", TestNick[playerid], mysql, 64);
cache_get_field_content(0, "WantedReason", AccInfo[playerid][WantedReason], mysql, 64);
return 1;
}
public OnAccountRegister(playerid)
{
AccInfo[playerid][ID] = cache_insert_id(mysql);
printf("New account registered. ID: %d", AccInfo[playerid][ID]);
return 1;
}