//OnAccount check
ShowPlayerDialog(playerid, dREGISTER, DIALOG_STYLE_INPUT, "Register", "Welcome To ZoneX your Username is not founded in our Database Please Register.", "Register", "Quit");
On Dialog Response
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 Msg[130], str[800];
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(str, sizeof(str), "INSERT INTO `players`(`ID`, `Username`, `Password`, `IP`, `Admin`, `VIP`, `Kills`, `Cookies`, `Cakes`, `Icecream`, `Deaths`, `Score`, `Money`, `Hours`, `Minutes`) VALUES ('%d','%s','%s','%s',0,0,0,0,0,0,0,0,0,0,0)", pData[playerid][ID], GetName(playerid), pData[playerid][Password], IP[playerid]);
mysql_query(mysql, str);
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);
new rows, Cache:getCache;
getCache = mysql_query(mysql, "SELECT * FROM `players`");
cache_get_row_count(rows);
format(Msg, sizeof(Msg), "{00FF50}%s has registered at ZX {FF0000}[Total Registered Players: %i]",GetName(playerid), rows);
SendClientMessageToAll(playerid,Msg);
pData[playerid][Admin] = 1;
pData[playerid][RaceWon] = 0;
cache_delete(getCache);
//let's execute the query
}
Obviously you can't get the insert_id before the actual insert takes place. That's the point. It is the insert statement that generates the ID. This function merely returns that value. If the ID column is set to auto_increment then you can leave it out of the query. Alternatively you can specify the value as null, default or 0.
Also NEVER use row_count if the only thing you're interested in is a count of something. That is terribly inefficient. Use the aggregate COUNT() function. This always returns exactly one row and one column with the value being the count. Check the logs as well. |
You do not deserve a help if you don't even know a single bit of MySQL, go and start off with SQLite.
|