Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

RegisterDate

$
0
0
PHP Code:

        case dREGISTER//register dialog
        
{
            if(!
response) return Kick(playerid); //if they clicked Quit, we will kick them
            
if(strlen(inputtext) < 6) return ShowPlayerDialog(playeriddREGISTERDIALOG_STYLE_INPUT"Register""In order to play, you need to register.\nYour password must be at least 6 characters long!""Register""Quit");
            
//strlen checks a lenght of a string. so if player types their password that is lower than 6, we tell them; Your password must be at least 6 characters long!
                
WP_Hash(pData[playerid][Password], 129inputtext); //hashing inputtext
                
new str[800];
        new 
hour,minute,year,day,month;
        
gettime(hour,minute);
        
getdate(day,month,year);
                
format(pData[playerid][RegisterDate], 3000,"%d:%d %d-%d-%d",hour,minute,year,month,day);
                 
format(strsizeof(str), "INSERT INTO `players`(`Username`, `Password`, `IP`,`RegisterDate`, `Admin`, `VIP`, `Kills`, `Cookies`, `Cakes`, `Icecream`, `Deaths`, `Score`, `Money`, `Hours`, `Minutes`,`RaceWon`) VALUES ('%s','%s','%s','%s',0,0,0,0,0,0,0,0,0,0,0,0)"GetName(playerid), pData[playerid][Password], IP[playerid], pData[playerid][RegisterDate]);
                
mysql_query(mysqlstr);
                
pData[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
                
printf("New account registered. ID: %d"pData[playerid][ID]); //just for debugging.
                
pData[playerid][Money] = 50000;
                
GivePlayerMoney(playerid50000);
                
format(joinMsgsizeof(joinMsg), "02[%d] 03*** 11,12* Player %s has registered new at ZoneX (Zx)",playeridGetName(playerid));
                
IRC_GroupSay(groupIDIRC_CHANNELjoinMsg);
             
pData[playerid][Admin] = 1;
             
pData[playerid][RaceWon] = 0;
             
SavePlayerData(playerid);
            
//let's execute the query
        
}
        } 

PHP Code:

forward SavePlayerData(playerid);
public 
SavePlayerData(playerid)
{
        if(
IsPlayerConnected(playerid))
        {
    new 
query[150+1000];
    
mysql_format(mysqlquerysizeof(query), "UPDATE `players` SET `IP` = '%e', `Admin` = %d, `VIP` = %d, `Kills` = %d,`Cookies` = %d,`Cakes` = %d,`Icecream` = %d, `Deaths` = %d, `Score` = %d, `Money` = %d, `Hours` = %d,\
     `Minutes` = %d, `RaceWon` = %d, `RegisterDate` = %s, WHERE `ID` = %d"
,
    
IP[playerid], pData[playerid][Admin], pData[playerid][VIP], pData[playerid][Kills],pData[playerid][Cookies],pData[playerid][Cakes],pData[playerid][Icecream], pData[playerid][Deaths], GetPlayerScore(playerid),\
     
GetPlayerMoney(playerid), pData[playerid][pHours], pData[playerid][pMinutes],pData[playerid][RaceWon],pData[playerid][RegisterDate],pData[playerid][ID]);
    
mysql_query(mysqlquery);
        }


When player register and i go in the database it shows

RegisterDate: 0000-00-00

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>