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(playerid, dREGISTER, DIALOG_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], 129, inputtext); //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(str, sizeof(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(mysql, str);
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(playerid, 50000);
format(joinMsg, sizeof(joinMsg), "02[%d] 03*** 11,12* Player %s has registered new at ZoneX (Zx)",playerid, GetName(playerid));
IRC_GroupSay(groupID, IRC_CHANNEL, joinMsg);
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(mysql, query, sizeof(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(mysql, query);
}
}
RegisterDate: 0000-00-00