21.02.2017, 18:20
PHP код:
//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
}