25.09.2016, 07:05
Hey guys, I have a VIP system however whenever I relog the columns of VIPJoinDate and VIPExpireDate go blank. But VIP stays at 1. Probably sounds a bit confusing but when you set a member VIP it stores the VIP level, what the date is that the player got set VIP and the time that the VIP is set to expire. However for some reason it doesn't load properly. If I give myself VIP stay in the server check the database the date is there. However as soon as I relog and go back into the server I still have VIP but VIPJoinDate and VIPExpireDate have gone back to blank. I checked the MYSQL log and no erros, no debug codes. Here is my setvip command, save callback, and load callback.
PHP код:
enum pInfo
{
uID,
pPass[129],
pIP[16],
pCash,
pAdmin,
Float:pXPos,
Float:pYPos,
Float:pZPos,
Float:pAPos,
Interior,
pSkin,
SpecID,
Support,
pUCAdmin,
TotalTime,
VIP,
VIPJoinDate[80],
VIPExpireDate[80],
muted,
mutedTime,
PlayedHours,
hours,
minutes,
seconds,
Score,
pDriverLicense,
WantedLvl,
pInJail,
pInJailTime,
pBanned,
pBannedBy[50],
Vehicle,
pReason[128],
OrgID,
OrgTier,
OrgRank[30]
}
public SaveAccountStats(playerid)
{
new query1[1024],query2[1024],query3[1024],Float:pos[4],cash;
cash=GetPlayerMoney(playerid);
if(LoggedIn[playerid] == 1)
{
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
mysql_format(ServerMySQL,query1,sizeof(query1),"UPDATE `Users` SET Name ='%s',pIP='%s',pCash = %d,pAdmin=%d, pXPos = %f, pYPos = %f, pZPos = %f, pAPos = %f,Interior=%d WHERE Name = '%s'",GetName(playerid),playerip[playerid],cash,PlayerInfo[playerid][pAdmin], pos[0], pos[1], pos[2], pos[3],PlayerInfo[playerid][Interior],GetName(playerid));
mysql_tquery(ServerMySQL, query1, "", "");
mysql_format(ServerMySQL,query2,sizeof(query2),"UPDATE `Users` SET pSkin=%d,Support=%d,VIP=%d, VIPJoinDate='%s', VIPExpireDate='%s', muted=%d, pUCAdmin=%d, pBanned=%d WHERE Name='%s'",PlayerInfo[playerid][pSkin],PlayerInfo[playerid][Support],PlayerInfo[playerid][VIP], PlayerInfo[playerid][VIPJoinDate],PlayerInfo[playerid][VIPExpireDate], PlayerInfo[playerid][muted], PlayerInfo[playerid][pUCAdmin], PlayerInfo[playerid][pBanned],GetName(playerid));
mysql_tquery(ServerMySQL,query2,"","");
mysql_format(ServerMySQL,query3,sizeof(query3),"UPDATE `Users` SET pBannedBy='%s', pReason='%s', Vehicle = %d, TotalTime = %d, Score = %d WHERE Name= '%s'", PlayerInfo[playerid][pBannedBy], PlayerInfo[playerid][pReason],PlayerInfo[playerid][Vehicle], PlayerInfo[playerid][TotalTime], PlayerInfo[playerid][Score], GetName(playerid));
mysql_tquery(ServerMySQL,query3,"","");
}
return 1;
}
public OnAccountLoad(playerid)
{
PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "pAdmin");
cache_get_field_content(0,"pIP",PlayerInfo[playerid][pIP]);
PlayerInfo[playerid][pCash] = cache_get_field_content_int(0,"pCash");
PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0,"pAdmin");
PlayerInfo[playerid][pXPos] = cache_get_field_content_float(0,"pXPos");
PlayerInfo[playerid][pYPos] = cache_get_field_content_float(0,"pYPos");
PlayerInfo[playerid][pZPos] = cache_get_field_content_float(0,"pZPos");
PlayerInfo[playerid][pAPos] = cache_get_field_content_float(0,"pAPos");
PlayerInfo[playerid][Interior] = cache_get_field_content_int(0,"Interior");
PlayerInfo[playerid][pSkin] = cache_get_field_content_int(0,"pSkin");
PlayerInfo[playerid][Support]= cache_get_field_content_int(0,"Support");
PlayerInfo[playerid][pUCAdmin] = cache_get_field_content_int(0,"pUCAdmin");
PlayerInfo[playerid][TotalTime] = cache_get_field_content_int(0,"TotalTime");
PlayerInfo[playerid][Score] = cache_get_field_content_int(0,"Score");
PlayerInfo[playerid][PlayedHours] = cache_get_field_content_int(0,"PlayedHours");
PlayerInfo[playerid][VIP]= cache_get_field_content_int(0,"VIP");
cache_get_field_content(0,"VIPJoinDate",PlayerInfo[playerid][VIPJoinDate]);
cache_get_field_content(0,"VIPExpireDate",PlayerInfo[playerid][VIPExpireDate]);
PlayerInfo[playerid][muted]= cache_get_field_content_int(0,"muted");
PlayerInfo[playerid][pDriverLicense] = cache_get_field_content_int(0,"pDriverLicense");
PlayerInfo[playerid][WantedLvl] = cache_get_field_content_int(0,"WantedLvl");
PlayerInfo[playerid][pInJail] = cache_get_field_content_int(0,"pInJail");
PlayerInfo[playerid][pInJailTime] = cache_get_field_content_int(0,"pInJailTime");
PlayerInfo[playerid][pBanned] = cache_get_field_content_int(0,"pBanned");
PlayerInfo[playerid][Vehicle] = cache_get_field_content_int(0,"Vehicle");
cache_get_field_content(0,"pBannedBy", PlayerInfo[playerid][pBannedBy]);
cache_get_field_content(0,"pReason",PlayerInfo[playerid][pReason]);
PlayerInfo[playerid][OrgID] = cache_get_field_content_int(0,"OrgID");
PlayerInfo[playerid][OrgTier] = cache_get_field_content_int(0,"OrgTier");
cache_get_field_content(0,"OrgRank",PlayerInfo[playerid][OrgRank]);
GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]);
if(PlayerInfo[playerid][pBanned] == 1)
{
SendClientMessage(playerid, -1, "You have been banned from this server.");
Kick(playerid);
}
LoggedIn[playerid] = 1; //Changes the value of our variable "Logged" to 1("true").
SendClientMessage(playerid, -1, "You have successfully logged in.");
if(PlayerInfo[playerid][pAdmin] != 0)
{
new msgID[128], msg[128];
if(PlayerInfo[playerid][pUCAdmin] == 0)
{
format(msgID, 32, "Administration Level - %d", PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid, COLOR_ADMIN, msgID);
if(PlayerInfo[playerid][pAdmin] >= 6)
{
format(msg,sizeof(msg), "* %s (ID%d) has logged in as Administrator Level 5.", GetName(playerid), playerid);
}
else
{
format(msg, sizeof(msg), "* %s (ID%d) has logged in as Administrator Level %d.", GetName(playerid), playerid, PlayerInfo[playerid][pAdmin]);
}
ABroadCast(COLOR_ADMIN, msg, 1);
}
else
{
format(msgID, 64, "Administration Level - %d (Undercover)", PlayerInfo[playerid][pAdmin]);
SendClientMessage(playerid, COLOR_ADMIN, msgID);
}
}
if(PlayerInfo[playerid][Support] != 0)
{
new msg[128];
if(PlayerInfo[playerid][Support] == 1)
{
SendClientMessage(playerid, COLOR_WSUPPORT, "Support Member");
format(msg,sizeof(msg), "* %s (ID%d) has logged in as Support Member", GetName(playerid), playerid);
}
else if(PlayerInfo[playerid][Support] == 2)
{
SendClientMessage(playerid, COLOR_SSUPPORT, "Senior Support Member");
format(msg, sizeof(msg), "* %s (ID%d) has logged in as Senior Support Member", GetName(playerid), playerid);
}
SendMsgToSupport(msg, COLOR_SUPPORT);
}
if(PlayerInfo[playerid][muted] == 1)
{
new string[128];
format(string,sizeof(string), "[AutoMute] %s has joined the server and has been auto-muted!", GetName(playerid));
SendClientMessageToAll(0xFFFFFF, string);
SetTimerEx("AutoUnMute",AutoUnmuteTime*60000,false,"i",playerid);
}
if(PlayerInfo[playerid][VIP] == 1)
{
SendClientMessage(playerid, COLOR_VIP2, "Vip Level - Donator");
if(PlayerInfo[playerid][VIP] == 1)
{
new year, month, day;
getdate(year, month, day);
new spyear[32], spmonth[32], spday[32];
strmid(spyear, PlayerInfo[playerid][VIPExpireDate], 6, 10, 32);
strmid(spmonth, PlayerInfo[playerid][VIPExpireDate], 0, 2, 32);
strmid(spday, PlayerInfo[playerid][VIPExpireDate], 3, 5, 32);
new pyear = strval(spyear);
new pmonth = strval(spmonth);
new pday = strval(spday);
if(pyear == 2016 && pmonth == 1)
{
format(PlayerInfo[playerid][VIPExpireDate], 32, "%02d/%02d/%d", pmonth, pday, pyear +1);
}
if(year > pyear && month == pmonth && day > pday)
{
SendClientMessage(playerid, COLOR_ORANGE, "Sorry, your VIP has expired. Please donate to get it restored.");
RemoveVIP(playerid);
}
if(month == pmonth && day > pday)
{
SendClientMessage(playerid, COLOR_ORANGE, "Sorry, your VIP has expired. Please donate to get it restored.");
RemoveVIP(playerid);
}
format(amsg, sizeof(amsg), "* %s (ID%d) has logged in as an VIP Member", GetName(playerid), playerid);
SendVIPChatMessage(COLOR_VIP2, amsg);
}
}
SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
return 1;
}
CMD:setvip(playerid,params[])
{
new ID, string[250], str[300], length;
if(PlayerInfo[playerid][pAdmin] < 5) return 0;
{
if(sscanf(params, "ud", ID, length)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /setvip [PlayerID] [Length 0, 1, 6, 12]");
{
if(IsPlayerConnected(ID))
{
if(length == 1)
{
if(PlayerInfo[ID][VIP] == 1)return SendClientMessage(playerid, COLOR_RED, "Error: Player is already VIP.");
PlayerInfo[ID][VIP] = 1;
SendClientMessage(ID, COLOR_VIP2, "You have been promoted to VIP. Thank you for supporting the server.");
format(string,sizeof(string), "[Admin Log]: %s has given %s VIP for 1 month.", GetName(playerid), GetName(ID));
ABroadCast(COLOR_ADMIN, string, 1);
new Year, Month, Day;
getdate(Year, Month, Day);
format(str,32,"%02d/%02d/%02d", Month, Day, Year);
strmid(PlayerInfo[ID][VIPJoinDate], str, 0, strlen(str), 255);
format(str, 32, "%02d/%02d/%d", Month +1, Day, Year);
strmid(PlayerInfo[ID][VIPExpireDate], str, 0, strlen(str), 255);
if(Month == 12)
{
format(PlayerInfo[ID][VIPExpireDate], 32, "%02d/%02d/%d", 1, Day, Year +1);
}
format(str, sizeof(str), "[M/D/Y] Join Date: %s | Expire Date: %s", PlayerInfo[ID][VIPJoinDate], PlayerInfo[ID][VIPExpireDate]);
SendClientMessage(ID, COLOR_VIP1, str);
SendClientMessage(playerid, COLOR_ORANGE, str);
}
if(length == 6)
{
if(PlayerInfo[ID][VIP] == 1)return SendClientMessage(playerid, COLOR_RED, "Error: Player is already VIP.");
PlayerInfo[ID][VIP] = 1;
SendClientMessage(playerid, COLOR_VIP2, "You have been promoted to VIP. Thank you for supporting the server.");
format(string,sizeof(string), "[Admin Log]: %s has given %s VIP for 6 months.", GetName(playerid), GetName(ID));
ABroadCast(COLOR_ADMIN, string, 1);
new Year, Month, Day;
getdate(Year, Month, Day);
format(str,32,"%02d/%02d/%02d", Month, Day, Year);
strmid(PlayerInfo[ID][VIPJoinDate], str, 0, strlen(str), 255);
format(str, 32, "%02d/%02d/%d", Month +6, Day, Year);
strmid(PlayerInfo[ID][VIPExpireDate], str, 0, strlen(str), 255);
if(Month == 12)
{
format(PlayerInfo[ID][VIPExpireDate], 32, "%02d/%02d/%d", 1, Day, Year +1);
}
format(str, sizeof(str), "[M/D/Y] Join Date: %s | Expire Date: %s", PlayerInfo[ID][VIPJoinDate], PlayerInfo[ID][VIPExpireDate]);
SendClientMessage(ID, COLOR_VIP1, str);
SendClientMessage(playerid, COLOR_ORANGE, str);
}
if(length == 12)
{
if(PlayerInfo[ID][VIP] == 1)return SendClientMessage(playerid, COLOR_RED, "Error: Player is already VIP.");
PlayerInfo[ID][VIP] = 1;
SendClientMessage(playerid, COLOR_VIP2, "You have been promoted to VIP. Thank you for supporting the server.");
format(string,sizeof(string), "[Admin Log]: %s has given %s VIP for 1 year.", GetName(playerid), GetName(ID));
ABroadCast(COLOR_ADMIN, string, 1);
new Year, Month, Day;
getdate(Year, Month, Day);
format(str,32,"%02d/%02d/%02d", Month, Day, Year);
strmid(PlayerInfo[ID][VIPJoinDate], str, 0, strlen(str), 255);
format(str, 32, "%02d/%02d/%d", Month, Day, Year +1);
strmid(PlayerInfo[ID][VIPExpireDate], str, 0, strlen(str), 255);
if(Month == 12)
{
format(PlayerInfo[ID][VIPExpireDate], 32, "%02d/%02d/%d", 1, Day, Year +1);
}
format(str, sizeof(str), "[M/D/Y] Join Date: %s | Expire Date: %s", PlayerInfo[ID][VIPJoinDate], PlayerInfo[ID][VIPExpireDate]);
SendClientMessage(ID, COLOR_VIP1, str);
SendClientMessage(playerid, COLOR_ORANGE, str);
}
if(length == 0)
{
PlayerInfo[ID][VIP] = 0;
SendClientMessage(ID, COLOR_VIP2, "Your VIP has been removed by an Administrator");
format(string,sizeof(string), "[Admin Log]: %s has removed %s VIP.", GetName(playerid), GetName(ID));
ABroadCast(COLOR_ADMIN, string, 1);
}
SaveAccountStats(ID);
}
else
{
SendClientMessage(playerid, COLOR_RED, "Error: Player not found");
}
}
}
return 1;
}