Not loading properly?
#1

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(playeridpos[0], pos[1], pos[2]); 
        
GetPlayerFacingAngle(playeridpos[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(ServerMySQLquery1""""); 
        
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(playeridPlayerInfo[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(msgID32"Administration Level - %d"PlayerInfo[playerid][pAdmin]);
            
SendClientMessage(playeridCOLOR_ADMINmsgID);
            if(
PlayerInfo[playerid][pAdmin] >= 6)
            {
                
format(msg,sizeof(msg), "* %s (ID%d) has logged in as Administrator Level 5."GetName(playerid), playerid);
            }
            else
            {
                
format(msgsizeof(msg), "* %s (ID%d) has logged in as Administrator Level %d."GetName(playerid), playeridPlayerInfo[playerid][pAdmin]);
            }
            
ABroadCast(COLOR_ADMINmsg1);
        }
        else
        {
            
format(msgID64"Administration Level - %d (Undercover)"PlayerInfo[playerid][pAdmin]);
            
SendClientMessage(playeridCOLOR_ADMINmsgID);
        }
    }
    if(
PlayerInfo[playerid][Support] != 0)
    {
        new 
msg[128];
        if(
PlayerInfo[playerid][Support] == 1)
        {
            
SendClientMessage(playeridCOLOR_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(playeridCOLOR_SSUPPORT"Senior Support Member");
            
format(msgsizeof(msg), "* %s (ID%d) has logged in as Senior Support Member"GetName(playerid), playerid);
        }
        
SendMsgToSupport(msgCOLOR_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(0xFFFFFFstring);
        
SetTimerEx("AutoUnMute",AutoUnmuteTime*60000,false,"i",playerid);
    }
    if(
PlayerInfo[playerid][VIP] == 1)
    {
        
SendClientMessage(playeridCOLOR_VIP2"Vip Level - Donator");
        if(
PlayerInfo[playerid][VIP] == 1)
        {
            new 
yearmonthday;
            
getdate(yearmonthday);
            new 
spyear[32], spmonth[32], spday[32];
            
strmid(spyearPlayerInfo[playerid][VIPExpireDate], 61032);
            
strmid(spmonthPlayerInfo[playerid][VIPExpireDate], 0232);
            
strmid(spdayPlayerInfo[playerid][VIPExpireDate], 3532);
            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"pmonthpdaypyear +1);
            }
            if(
year pyear && month == pmonth && day pday)
            {
                
SendClientMessage(playeridCOLOR_ORANGE"Sorry, your VIP has expired. Please donate to get it restored.");
                
RemoveVIP(playerid);
            }
            if(
month == pmonth && day pday)
            {
                
SendClientMessage(playeridCOLOR_ORANGE"Sorry, your VIP has expired. Please donate to get it restored.");
                
RemoveVIP(playerid);
            }
            
format(amsgsizeof(amsg), "* %s (ID%d) has logged in as an VIP Member"GetName(playerid), playerid);
            
SendVIPChatMessage(COLOR_VIP2amsg);
        }
    }
    
SetPlayerScore(playeridPlayerInfo[playerid][Score]);
    return 
1
}
CMD:setvip(playerid,params[])
{
    new 
IDstring[250], str[300], length;
    if(
PlayerInfo[playerid][pAdmin] < 5) return 0;
    {
        if(
sscanf(params"ud"IDlength)) return SendClientMessage(playeridCOLOR_WHITE"Usage: /setvip [PlayerID] [Length 0, 1, 6, 12]");
        {
            if(
IsPlayerConnected(ID))
            {
                if(
length == 1)
                {
                    if(
PlayerInfo[ID][VIP] == 1)return SendClientMessage(playeridCOLOR_RED"Error: Player is already VIP.");
                    
PlayerInfo[ID][VIP] = 1;
                    
SendClientMessage(IDCOLOR_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_ADMINstring1);
                    new 
YearMonthDay;
                    
getdate(YearMonthDay);
                    
format(str,32,"%02d/%02d/%02d"MonthDayYear);
                    
strmid(PlayerInfo[ID][VIPJoinDate], str0strlen(str), 255);
                    
format(str32"%02d/%02d/%d"Month +1DayYear);
                    
strmid(PlayerInfo[ID][VIPExpireDate], str0strlen(str), 255);    
                    if(
Month == 12)
                    {
                        
format(PlayerInfo[ID][VIPExpireDate], 32"%02d/%02d/%d"1DayYear +1);
                    }
                    
format(strsizeof(str), "[M/D/Y] Join Date: %s | Expire Date: %s"PlayerInfo[ID][VIPJoinDate], PlayerInfo[ID][VIPExpireDate]);
                    
SendClientMessage(IDCOLOR_VIP1str);
                    
SendClientMessage(playeridCOLOR_ORANGEstr);
                }
                if(
length == 6)
                {
                    if(
PlayerInfo[ID][VIP] == 1)return SendClientMessage(playeridCOLOR_RED"Error: Player is already VIP.");
                    
PlayerInfo[ID][VIP] = 1;
                    
SendClientMessage(playeridCOLOR_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_ADMINstring1);
                    new 
YearMonthDay;
                    
getdate(YearMonthDay);
                    
format(str,32,"%02d/%02d/%02d"MonthDayYear);
                    
strmid(PlayerInfo[ID][VIPJoinDate], str0strlen(str), 255);
                    
format(str32"%02d/%02d/%d"Month +6DayYear);
                    
strmid(PlayerInfo[ID][VIPExpireDate], str0strlen(str), 255);
                    if(
Month == 12)
                    {
                        
format(PlayerInfo[ID][VIPExpireDate], 32"%02d/%02d/%d"1DayYear +1);
                    }
                    
format(strsizeof(str), "[M/D/Y] Join Date: %s | Expire Date: %s"PlayerInfo[ID][VIPJoinDate], PlayerInfo[ID][VIPExpireDate]);
                    
SendClientMessage(IDCOLOR_VIP1str);
                    
SendClientMessage(playeridCOLOR_ORANGEstr);
                }
                if(
length == 12)
                {
                    if(
PlayerInfo[ID][VIP] == 1)return SendClientMessage(playeridCOLOR_RED"Error: Player is already VIP.");
                    
PlayerInfo[ID][VIP] = 1;
                    
SendClientMessage(playeridCOLOR_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_ADMINstring1);
                    new 
YearMonthDay;
                    
getdate(YearMonthDay);
                    
format(str,32,"%02d/%02d/%02d"MonthDayYear);
                    
strmid(PlayerInfo[ID][VIPJoinDate], str0strlen(str), 255);
                    
format(str32"%02d/%02d/%d"MonthDayYear +1);
                    
strmid(PlayerInfo[ID][VIPExpireDate], str0strlen(str), 255);
                    if(
Month == 12)
                    {
                        
format(PlayerInfo[ID][VIPExpireDate], 32"%02d/%02d/%d"1DayYear +1);
                    }
                    
format(strsizeof(str), "[M/D/Y] Join Date: %s | Expire Date: %s"PlayerInfo[ID][VIPJoinDate], PlayerInfo[ID][VIPExpireDate]);
                    
SendClientMessage(IDCOLOR_VIP1str);
                    
SendClientMessage(playeridCOLOR_ORANGEstr);
                }
                if(
length == 0)
                {
                    
PlayerInfo[ID][VIP] = 0;
                    
SendClientMessage(IDCOLOR_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_ADMINstring1);
                }
                
SaveAccountStats(ID);
            }
            else
            {
                
SendClientMessage(playeridCOLOR_RED"Error: Player not found");
            }            
        }
    }
    return 
1;

Reply
#2

https://sampwiki.blast.hk/wiki/MySQL/R33..._field_content

Read the important note.

About the expiration thing, if you are interested read about date and time functions so you can save them as unix timestamp through MySQL.
Reply
#3

I added this
PHP код:
    cache_get_field_content(0,"VIPJoinDate",PlayerInfo[playerid][VIPJoinDate], 80);
    
cache_get_field_content(0,"VIPExpireDate",PlayerInfo[playerid][VIPExpireDate], 80); 
But it still didn't work.
Reply
#4

Enable debug level in mysql_log function and post what it is written in mysql logs (after connecting and not retrieving the dates).
Reply
#5

Ummm I enabled the debug level in the HTML file but I got no codes or anything...
Reply
#6

pawn Код:
mysql_log(LOG_ALL);
mysql_connect(...);
Reply
#7

Код:
12:20:15	cache_get_field_content_int	OK	row: 0, field_name: "VIP", connection: 1
12:20:15	CMySQLResult::GetRowDataByName	OK	row: '0', field: "VIP", data: "0"
12:20:15	cache_get_field_content	OK	row: 0, field_name: "VIPJoinDate", connection: 80, max_len: 1
12:20:15	CMySQLResult::GetRowDataByName	OK	row: '0', field: "VIPJoinDate", data: ""
12:20:15	cache_get_field_content	OK	row: 0, field_name: "VIPExpireDate", connection: 80, max_len: 1
12:20:15	CMySQLResult::GetRowDataByName	OK	row: '0', field: "VIPExpireDate", data: ""
Reply
#8

4th parameter is the connection handle and the 5th (last) is the max_len.
Reply
#9

I got the wrong account information. I found this
Код:
12:35:22	cache_get_field_content	OK	row: 0, field_name: "VIPJoinDate", connection: 80, max_len: 1
12:35:22	CMySQLResult::GetRowDataByName	OK	row: '0', field: "VIPJoinDate", data: "09/25/2016"
12:35:22	cache_get_field_content	OK	row: 0, field_name: "VIPExpireDate", connection: 80, max_len: 1
12:35:22	CMySQLResult::GetRowDataByName	OK	row: '0', field: "VIPExpireDate", data: "09/25/2017"
Reply
#10

connection is still 80 and max_len is still 1 according to the logs.

pawn Код:
cache_get_field_content(0,"VIPJoinDate",PlayerInfo[playerid][VIPJoinDate], ServerMySQL, 80);
cache_get_field_content(0,"VIPExpireDate",PlayerInfo[playerid][VIPExpireDate], ServerMySQL, 80);
A good way when debugging is to remove the old logs before trying to reproduce/test so it will be more convenient to look up the text.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)