12.12.2015, 14:46
PHP Code:
stock SavePlayerData(playerid)
{
if(Authenticated[playerid] == 1)
{
new
query[2000],
Float: pHealth,
Float: pArmour;//don't forget to change the "2" to "5" when enabling the last pos
GetPlayerHealth(playerid, pHealth);
GetPlayerArmour(playerid, pArmour);
format(query, sizeof(query), "UPDATE `Accounts` SET `Adminlevel` = %d, `Money` = %d, `Level` = %d, `LastOn` = %d, `Health` = %f, `Armour` = %f, `Skin` = %d, `Gender` = %d, `LastIP` = '%s', `Age` = %d, `Country` = '%s', `Test` = %d, `Faction` = %d, `FactionRank` = %d, `FactionRankName` = '%s', ",
Player[playerid][Adminlevel],
GetPlayerCash(playerid),
Player[playerid][Level],
Player[playerid][LastOn],
pHealth,
pArmour,
Player[playerid][Skin],
Player[playerid][Gender],
PlayerConnectedIP[playerid],
Player[playerid][Age],
Player[playerid][Country],
Player[playerid][Test],
Player[playerid][Faction],
Player[playerid][FactionRank],
Player[playerid][FactionRankName]);
format(query, sizeof(query), "%s`PrisonSelect` = %d, `PrisonTime` = %d, `AdminPrisonCount` = %d, `SecondsLoggedIn` = %d, `PlayingHours` = %d, `AdminCode` = %d, `PhoneN` = %d, `PhoneCredit` = %d, `PhoneBook` = %d, `House` = %d, `Hotel` = %d, `Hospitalized` = %d, ",
query,
Player[playerid][PrisonSelect],
Player[playerid][PrisonTime],
Player[playerid][AdminPrisonCount],
Player[playerid][SecondsLoggedIn],
Player[playerid][PlayingHours],
Player[playerid][AdminCode],
Player[playerid][PhoneN],
Player[playerid][PhoneCredit],
Player[playerid][PhoneBook],
Player[playerid][House],
Player[playerid][Hotel],
Player[playerid][Hospitalized]);
format(query, sizeof(query), "%s`OnDuty` = %d, `DutyClothes` = %d, `LastSkin` = %d, `LastX` = %f, `LastY` = %f, `LastZ` = %f, `LastA` = %f, `LastInt` = %d, `LastWorld` = %d, `InFactionHQ` = %d, `InHouse` = %d, ",
query,
0,
Player[playerid][DutyClothes],
Player[playerid][LastSkin],
Player[playerid][LastX],
Player[playerid][LastY],
Player[playerid][LastZ],
Player[playerid][LastA],
Player[playerid][LastInt],
Player[playerid][LastWorld],
Player[playerid][InFactionHQ],
Player[playerid][InHouse]);
format(query, sizeof(query), "%s`Helper` = %d, `Moderator` = %d, `BankPincode` = '%s', `BankNumber` = %d, `BankMoney` = %d, `ExperiencePoints` = %d, `ExperiencePointsNeeded` = %d, `Coins` = %d, `WalkieTalkie` = %d, `WalkieFrequency` = %d, ",
query,
Player[playerid][Helper],
Player[playerid][Moderator],
Player[playerid][BankPincode],
Player[playerid][BankNumber],
Player[playerid][BankMoney],
Player[playerid][ExperiencePoints],
Player[playerid][ExperiencePointsNeeded],
Player[playerid][Coins],
Player[playerid][WalkieTalkie],
Player[playerid][WalkieFrequency]);
format(query, sizeof(query), "%s`WeaponSlot0` = %d, `WeaponSlot1` = %d, `WeaponSlot2` = %d, `WeaponSlot3` = %d, `WeaponSlot4` = %d, `WeaponSlot5` = %d, `WeaponSlot6` = %d, `WeaponSlot7` = %d, `WeaponSlot8` = %d, `WeaponSlot9` = %d, `WeaponSlot10` = %d, `WeaponSlot11` = %d, ",
query,
Player[playerid][WeaponSlot0],
Player[playerid][WeaponSlot1],
Player[playerid][WeaponSlot2],
Player[playerid][WeaponSlot3],
Player[playerid][WeaponSlot4],
Player[playerid][WeaponSlot5],
Player[playerid][WeaponSlot6],
Player[playerid][WeaponSlot7],
Player[playerid][WeaponSlot8],
Player[playerid][WeaponSlot9],
Player[playerid][WeaponSlot10],
Player[playerid][WeaponSlot11]);
format(query, sizeof(query), "%s`WeaponSlot0Ammo` = %d, `WeaponSlot1Ammo` = %d, `WeaponSlot2Ammo` = %d, `WeaponSlot3Ammo` = %d, `WeaponSlot4Ammo` = %d, `WeaponSlot5Ammo` = %d, `WeaponSlot6Ammo` = %d, `WeaponSlot7Ammo` = %d, `WeaponSlot8Ammo` = %d, `WeaponSlot9Ammo` = %d, `WeaponSlot10Ammo` = %d, `WeaponSlot11Ammo` = %d WHERE `Username` = '%s'",
query,
Player[playerid][WeaponSlot0Ammo],
Player[playerid][WeaponSlot1Ammo],
Player[playerid][WeaponSlot2Ammo],
Player[playerid][WeaponSlot3Ammo],
Player[playerid][WeaponSlot4Ammo],
Player[playerid][WeaponSlot5Ammo],
Player[playerid][WeaponSlot6Ammo],
Player[playerid][WeaponSlot7Ammo],
Player[playerid][WeaponSlot8Ammo],
Player[playerid][WeaponSlot9Ammo],
Player[playerid][WeaponSlot10Ammo],
Player[playerid][WeaponSlot11Ammo],
GetName(playerid));
mysql_query(query);
format(query, sizeof(query), "UPDATE `Accounts` SET `DutyWeaponSlot0` = %d, `DutyWeaponSlot1` = %d, `DutyWeaponSlot2` = %d, `DutyWeaponSlot3` = %d, `DutyWeaponSlot4` = %d, `DutyWeaponSlot5` = %d, `DutyWeaponSlot6` = %d, `DutyWeaponSlot7` = %d, `DutyWeaponSlot8` = %d, `DutyWeaponSlot9` = %d, `DutyWeaponSlot10` = %d, `DutyWeaponSlot11` = %d, ",
Player[playerid][DutyWeaponSlot0],
Player[playerid][DutyWeaponSlot1],
Player[playerid][DutyWeaponSlot2],
Player[playerid][DutyWeaponSlot3],
Player[playerid][DutyWeaponSlot4],
Player[playerid][DutyWeaponSlot5],
Player[playerid][DutyWeaponSlot6],
Player[playerid][DutyWeaponSlot7],
Player[playerid][DutyWeaponSlot8],
Player[playerid][DutyWeaponSlot9],
Player[playerid][DutyWeaponSlot10],
Player[playerid][DutyWeaponSlot11]);
format(query, sizeof(query), "%s`DutyWeaponSlot0Ammo` = %d, `DutyWeaponSlot1Ammo` = %d, `DutyWeaponSlot2Ammo` = %d, `DutyWeaponSlot3Ammo` = %d, `DutyWeaponSlot4Ammo` = %d, `DutyWeaponSlot5Ammo` = %d, `DutyWeaponSlot6Ammo` = %d, `DutyWeaponSlot7Ammo` = %d, `DutyWeaponSlot8Ammo` = %d, `DutyWeaponSlot9Ammo` = %d, `DutyWeaponSlot10Ammo` = %d, `DutyWeaponSlot11Ammo` = %d, ",
query,
Player[playerid][DutyWeaponSlot0Ammo],
Player[playerid][DutyWeaponSlot1Ammo],
Player[playerid][DutyWeaponSlot2Ammo],
Player[playerid][DutyWeaponSlot3Ammo],
Player[playerid][DutyWeaponSlot4Ammo],
Player[playerid][DutyWeaponSlot5Ammo],
Player[playerid][DutyWeaponSlot6Ammo],
Player[playerid][DutyWeaponSlot7Ammo],
Player[playerid][DutyWeaponSlot8Ammo],
Player[playerid][DutyWeaponSlot9Ammo],
Player[playerid][DutyWeaponSlot10Ammo],
Player[playerid][DutyWeaponSlot11Ammo]);
format(query, sizeof(query), "%s`AntiCheatExemption` = %d, `Bans` = %d, `Kicks` = %d, `LastOnDate` = '%s', `Banned` = %d, `Email` = '%s', `Warns` = %d, `Badge` = %d, `Offline` = %d, `SecretWord` = '%s', `DisconnectReason` = %d, `Business` = %d, `FightStyle` = %d, `SpawnedPersonalCar` = %d WHERE `Username` = '%s'",
query,
Player[playerid][AntiCheatExemption],
Player[playerid][Bans],
Player[playerid][Kicks],
date(gettime()+3600, 1),
Player[playerid][Banned],
Player[playerid][Email],
Player[playerid][Warns],
Player[playerid][Badge],
Player[playerid][Offline],
Player[playerid][SecretWord],
Player[playerid][DisconnectReason],
Player[playerid][Business],
Player[playerid][FightStyle],
Player[playerid][SpawnedPersonalCar],
GetName(playerid));
mysql_query(query);
}
return 1;
}
PHP Code:
LoadPlayerData(playerid)
{
clearPlayerChat(playerid);
new Data[2048],Field[258],idx;
mysql_queryF("SELECT * FROM `Accounts` WHERE `Username` = '%s' LIMIT 1", GetName(playerid));
mysql_store_result();
if(mysql_num_rows() == 1){
mysql_fetch_rowEx(Data);
print(Data);
Field = strtuk( Data, idx, '|' );
for(new s = 0; s < 121; s++)
{
switch(s)
{
case 0: Player[playerid][UserID] = strval(Field);
case 2: strmid(Player[playerid][Password],Field,0,strlen(Field),129);
case 3: strmid(Player[playerid][LastIP],Field,0,strlen(Field),26);
case 4: Player[playerid][Adminlevel] = strval(Field);
case 5: Player[playerid][Money] = strval(Field);
case 6: Player[playerid][RegTime] = strval(Field);
case 7: Player[playerid][LastOn] = strval(Field);
case 8: Player[playerid][Level] = strval(Field);
case 9: Player[playerid][Gender] = strval(Field);
case 10: Player[playerid][Age] = strval(Field);
case 11: Player[playerid][Health] = floatstr(Field);
case 12: Player[playerid][Armour] = floatstr(Field);
case 13: Player[playerid][Skin] = strval(Field);
case 14: strmid(Player[playerid][Country],Field,0,strlen(Field),255);
case 15: Player[playerid][Test] = strval(Field);
case 16: Player[playerid][Faction] = strval(Field);
case 17: Player[playerid][FactionRank] = strval(Field);
case 18: strmid(Player[playerid][FactionRankName],Field,0,strlen(Field),255);
case 19: strmid(Player[playerid][Suspect], Field, 0, strlen(Field), 255);
case 20: Player[playerid][Arrest] = strval(Field);
case 21: Player[playerid][PrisonSelect] = strval(Field);
case 22: Player[playerid][PrisonTime] = strval(Field);
case 23: Player[playerid][AdminPrisonCount] = strval(Field);
case 24: Player[playerid][SecondsLoggedIn] = strval(Field);
case 25: Player[playerid][PlayingHours] = strval(Field);
case 26: Player[playerid][AdminCode] = strval(Field);
case 27: Player[playerid][PhoneN] = strval(Field);
case 28: Player[playerid][PhoneCredit] = strval(Field);
case 29: Player[playerid][PhoneBook] = strval(Field);
case 30: Player[playerid][House] = strval(Field);
case 31: Player[playerid][Hotel] = strval(Field);
case 32: Player[playerid][Hospitalized] = strval(Field);
case 33: Player[playerid][OnDuty] = strval(Field);
case 34: Player[playerid][DutyClothes] = strval(Field);
case 35: Player[playerid][LastSkin] = strval(Field);
case 36: Player[playerid][LastX] = floatstr(Field);
case 37: Player[playerid][LastY] = floatstr(Field);
case 38: Player[playerid][LastZ] = floatstr(Field);
case 39: Player[playerid][LastA] = floatstr(Field);
case 40: Player[playerid][LastInt] = strval(Field);
case 41: Player[playerid][LastWorld] = strval(Field);
case 42: Player[playerid][InFactionHQ] = strval(Field);
case 43: Player[playerid][InHouse] = strval(Field);
case 44: Player[playerid][Helper] = strval(Field);
case 45: Player[playerid][Moderator] = strval(Field);
case 46: strmid(Player[playerid][BankPincode],Field,0,strlen(Field),5);
case 47: Player[playerid][BankNumber] = strval(Field);
case 48: Player[playerid][BankMoney] = strval(Field);
case 49: Player[playerid][ExperiencePoints] = strval(Field);
case 50: Player[playerid][ExperiencePointsNeeded] = strval(Field);
case 51: Player[playerid][Coins] = strval(Field);
case 52: Player[playerid][WalkieTalkie] = strval(Field);
case 53: Player[playerid][WalkieFrequency] = strval(Field);
case 54: Player[playerid][HasMask] = strval(Field);
case 55: Player[playerid][Banned] = strval(Field);
case 56: Player[playerid][Bans] = strval(Field);
case 57: Player[playerid][Kicks] = strval(Field);
case 58: Player[playerid][WeaponSlot0] = strval(Field);
case 59: Player[playerid][WeaponSlot1] = strval(Field);
case 60: Player[playerid][WeaponSlot2] = strval(Field);
case 61: Player[playerid][WeaponSlot3] = strval(Field);
case 62: Player[playerid][WeaponSlot4] = strval(Field);
case 63: Player[playerid][WeaponSlot5] = strval(Field);
case 64: Player[playerid][WeaponSlot6] = strval(Field);
case 65: Player[playerid][WeaponSlot7] = strval(Field);
case 66: Player[playerid][WeaponSlot8] = strval(Field);
case 67: Player[playerid][WeaponSlot9] = strval(Field);
case 68: Player[playerid][WeaponSlot10] = strval(Field);
case 69: Player[playerid][WeaponSlot11] = strval(Field);
case 70: Player[playerid][WeaponSlot0Ammo] = strval(Field);
case 71: Player[playerid][WeaponSlot1Ammo] = strval(Field);
case 72: Player[playerid][WeaponSlot2Ammo] = strval(Field);
case 73: Player[playerid][WeaponSlot3Ammo] = strval(Field);
case 74: Player[playerid][WeaponSlot4Ammo] = strval(Field);
case 75: Player[playerid][WeaponSlot5Ammo] = strval(Field);
case 76: Player[playerid][WeaponSlot6Ammo] = strval(Field);
case 77: Player[playerid][WeaponSlot7Ammo] = strval(Field);
case 78: Player[playerid][WeaponSlot8Ammo] = strval(Field);
case 79: Player[playerid][WeaponSlot9Ammo] = strval(Field);
case 80: Player[playerid][WeaponSlot10Ammo] = strval(Field);
case 81: Player[playerid][WeaponSlot11Ammo] = strval(Field);
case 82: Player[playerid][DutyWeaponSlot0] = strval(Field);
case 83: Player[playerid][DutyWeaponSlot1] = strval(Field);
case 84: Player[playerid][DutyWeaponSlot2] = strval(Field);
case 85: Player[playerid][DutyWeaponSlot3] = strval(Field);
case 86: Player[playerid][DutyWeaponSlot4] = strval(Field);
case 87: Player[playerid][DutyWeaponSlot5] = strval(Field);
case 88: Player[playerid][DutyWeaponSlot6] = strval(Field);
case 89: Player[playerid][DutyWeaponSlot7] = strval(Field);
case 90: Player[playerid][DutyWeaponSlot8] = strval(Field);
case 91: Player[playerid][DutyWeaponSlot9] = strval(Field);
case 92: Player[playerid][DutyWeaponSlot10] = strval(Field);
case 93: Player[playerid][DutyWeaponSlot11] = strval(Field);
case 94: Player[playerid][DutyWeaponSlot0Ammo] = strval(Field);
case 95: Player[playerid][DutyWeaponSlot1Ammo] = strval(Field);
case 96: Player[playerid][DutyWeaponSlot2Ammo] = strval(Field);
case 97: Player[playerid][DutyWeaponSlot3Ammo] = strval(Field);
case 98: Player[playerid][DutyWeaponSlot4Ammo] = strval(Field);
case 99: Player[playerid][DutyWeaponSlot5Ammo] = strval(Field);
case 100: Player[playerid][DutyWeaponSlot6Ammo] = strval(Field);
case 101: Player[playerid][DutyWeaponSlot7Ammo] = strval(Field);
case 102: Player[playerid][DutyWeaponSlot8Ammo] = strval(Field);
case 103: Player[playerid][DutyWeaponSlot9Ammo] = strval(Field);
case 104: Player[playerid][DutyWeaponSlot10Ammo] = strval(Field);
case 105: Player[playerid][DutyWeaponSlot11Ammo] = strval(Field);
case 106: Player[playerid][AntiCheatExemption] = strval(Field);
case 107: strmid(Player[playerid][Email],Field,0,strlen(Field),128);
case 108: Player[playerid][Warns] = strval(Field);
case 109: Player[playerid][Badge] = strval(Field);
case 110: strmid(Player[playerid][SecretWord],Field,0,strlen(Field),128);
case 111: Player[playerid][DisconnectReason] = strval(Field);
case 112: Player[playerid][Business] = strval(Field);
case 113: Player[playerid][FightStyle] = strval(Field);
case 114: Player[playerid][SpawnedPersonalCar] = strval(Field);
}
Field = strtuk( Data, idx, '|' );
}
clearPlayerChat(playerid);
SPD(playerid, DIALOG_AUTHENTICATION);
TextDrawHideForPlayer(playerid, Text:LoadingTD);
//printf("%s",Player[playerid][SecretWord]);
//printf("%s",Player[playerid][LastIP]);
//printf("%s",PlayerConnectedIP[playerid]);
}else if(mysql_num_rows() == 0){
clearPlayerChat(playerid);
new playernamesplit[3][MAX_PLAYER_NAME], Name[MAX_PLAYER_NAME];
GetPlayerName(playerid, Name, sizeof(Name));
split2(Name, playernamesplit, '_');
if (!strlen(playernamesplit[0]) || !strlen(playernamesplit[1]))
{
KickWithMessage(playerid, COLOR_WHITE, "Unfortunately, your name is not in the proper format! Please use the format of "#COL_EMB_LIGHTBLUE"\"Firstname_Lastname\""#COL_EMB_WHITE".");
}
else
{
SPD(playerid, DIALOG_REGISTER);
TextDrawHideForPlayer(playerid, Text:LoadingTD);
}
}
mysql_free_result();
}
MYSQL Server
UserID int(11)
Username varchar(255)
Password varchar(129)
LastIP varchar(16)
Adminlevel int(4)
Money int(10)
RegTime int(20)
LastOn int(20)
Level int(4)
Gender int(11)
Age int(3)
Health float
Armour float
Skin int(3)
Country varchar(255)
Test int(11)
Faction int(11)
FactionRank int(11)
FactionRankName varchar(255)
PrisonSelect int(6)
PrisonTime int(6)
AdminPrisonCount int(11)
SecondsLoggedIn int(11)
PlayingHours int(11)
AdminCode int(255)
PhoneN int(6)
PhoneCredit int(11)
PhoneBook int(11)
House int(11)
Hotel int(11)
Hospitalized int(11)
OnDuty int(11)
DutyClothes int(11)
LastSkin int(11)
LastX float
LastY float
LastZ float
LastA float
LastInt int(11)
LastWorld int(11)
InFactionHQ int(11)
InHouse int(11)
Helper int(11)
Moderator int(11)
BankPincode varchar(5)
BankNumber int(11)
BankMoney int(11)
ExperiencePoints int(11)
ExperiencePointsNeeded int(11)
Coins int(11)
WalkieTalkie int(11)
WalkieFrequency int(11)
HasMask int(11)
Banned int(11)
Bans int(11)
Kicks int(11)
WeaponSlot0 int(11)
WeaponSlot1 int(11)
WeaponSlot2 int(11)
WeaponSlot3 int(11)
WeaponSlot4 int(11)
WeaponSlot5 int(11)
WeaponSlot6 int(11)
WeaponSlot7 int(11)
WeaponSlot8 int(11)
WeaponSlot9 int(11)
WeaponSlot10 int(11)
WeaponSlot11 int(11)
WeaponSlot0Ammo int(11)
WeaponSlot1Ammo int(11)
WeaponSlot2Ammo int(11)
WeaponSlot3Ammo int(11)
WeaponSlot4Ammo int(11)
WeaponSlot5Ammo int(11)
WeaponSlot6Ammo int(11)
WeaponSlot7Ammo int(11)
WeaponSlot8Ammo int(11)
WeaponSlot9Ammo int(11)
WeaponSlot10Ammo int(11)
WeaponSlot11Ammo int(11)
DutyWeaponSlot0 int(11)
DutyWeaponSlot1 int(11)
DutyWeaponSlot2 int(11)
DutyWeaponSlot3 int(11)
DutyWeaponSlot4 int(11)
DutyWeaponSlot5 int(11)
DutyWeaponSlot6 int(11)
DutyWeaponSlot7 int(11)
DutyWeaponSlot8 int(11)
DutyWeaponSlot9 int(11)
DutyWeaponSlot10 int(11)
DutyWeaponSlot11 int(11)
DutyWeaponSlot0Ammo int(11)
DutyWeaponSlot1Ammo int(11)
DutyWeaponSlot2Ammo int(11)
DutyWeaponSlot3Ammo int(11)
DutyWeaponSlot4Ammo int(11)
DutyWeaponSlot5Ammo int(11)
DutyWeaponSlot6Ammo int(11)
DutyWeaponSlot7Ammo int(11)
DutyWeaponSlot8Ammo int(11)
DutyWeaponSlot9Ammo int(11)
DutyWeaponSlot10Ammo int(11)
DutyWeaponSlot11Ammo int(11)
AntiCheatExemption int(11)
Email varchar(255)
Warns int(11)
Badge int(11)
LastOnDate varchar(255)
Offline int(11)
SecretWord varchar(12
DisconnectReason int(11)
Business int(11)
FightStyle int(11)
SpawnedPersonalCar int(11)
The server doesnt give any error's so can you tell me why its loading wrong?