29.08.2011, 10:45
Hey guys,
so i have this problem that it generates the number fine. but it doesent save it .. heres the code:
Thx for help
so i have this problem that it generates the number fine. but it doesent save it .. heres the code:
pawn Код:
forward NumberExists(numb);
public NumberExists(numb)
{
new value;
new string[256];
CheckMySQL();
format(string, sizeof(string), "SELECT * FROM numbers WHERE number = '%d'",numb);
mysql_query(string);
mysql_store_result();
if(mysql_num_rows())value = 0;
else value = 1;
return value;
}
forward MakePNumber(playerid,p);
public MakePNumber(playerid,p)
{
new number2 = Random(56000000,78000000);
if(NumberExists(number2) == 1)
{
MakePNumber(playerid,p);
print("Number already exists");
}
else if(NumberExists(number2) == 2)
{
new s[255];
UserStats[playerid][number] = number2;
UserStats[playerid][phone] = p;
CheckMySQL();
format(s, sizeof(s), "INSERT INTO numbers (number) VALUES ('%d')",number2);
mysql_query(s);
SavePlayer(playerid);
print("New number!");
}
return 1;
}