mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "UPDATE users SET phone = %i WHERE uid = %i", PlayerInfo[playerid][pPhone], PlayerInfo[playerid][pID]); mysql_tquery(connectionID, queryBuffer);
createphone(){
new number[6];
for(new i=0, j=6; i<j; i++){
random(9+1); // this will give you a number from 1 to 9 it can be used like this
number[i] = random(9+1); // This might work or might not, haven't tested it yet
}
return number;
}
new phonenumber[6]; phonenumber[0] = rand(8)+1; // sets the first number from 1 to 9 for(new i=i; i<sizeof(phonenumber);i++) { phonenumber[i]=rand(9); // sets the rest of the numbers from 0 to 9 }
new query[256]
// select all the phone numbers that match the phone number you want
mysql_format(yourDatabase, query, sizeof query, "SELECT * FROM `yourTable` WHERE `phonenumber` = '%i' LIMIT1", thePhoneNumberYouGotFromTheCommand )
mysql_query(yourDatabase, query, callbackFunction, parameterType, parameter );
forward yourCallbackFunction(parameter);
public yourCallbackFunction(parameter)
{
if(cache_num_rows() > 0) // if the phone number is found in the database
{
// do something
}
}
CMD:number(playerid, params[])
{
if(pInfo[playerid][Telefon] == 0)
{
new string[220], number = randomEx(1000,99999999);
pInfo[playerid][Telefon] = number;
format(string, sizeof(string), "Your phonenumber is: %i",pInfo[playerid][Telefon]);
SendClientMessage(playerid,-1,string);
SaveStats(playerid);
}
else {
SendClientMessage(playerid,-1,""chat" You already have an phone number !");
}
return 1;
}
Hi, I did this way
PHP код:
|
You should do : "randomEx(111111,999999);" It will give you a random number without a zero and in range of 6 digits.
|