24.03.2013, 20:03
I made a stock which sets the player number to a random one, but first it would check if someone else has in inside the database,
It sets my number, but when I print it, it shows the old number not the new one.
Here is an example:
pawn Код:
stock SetPlayerNumber(playerid)
{
new number = randomEx(123456, 999999);
new query[256];
format(query, sizeof(query), "SELECT `number` FROM `users` WHERE `number` = %d", number);
mysql_function_query(dbHandle, query, true, "CheckNumber", "ii", playerid, number);
}
CheckNumber:
public CheckNumber(playerid, number)
{
new rows, fields;
cache_get_data(rows, fields);
if(rows)
{
SetPlayerNumber(playerid); //Have to set player number again, if it has been found already.
}
else
{
PlayerInfo[playerid][pNumber] = number;
}
return 1;
}
Here is an example:
pawn Код:
case 0:
{
if(GetCash(playerid) < CELLPRICE) return NoCashMSG(playerid);
BizInfo[BizEntered[playerid]][bizCash] += CELLPRICE;
PlayerInfo[playerid][pCellPhone] = 1;
SetPlayerNumber(playerid);
GiveCash(playerid, -CELLPRICE);
SCM(playerid, COLOR_GRAD4, "Cellphone Purchased.");
format(string, sizeof(string), "Your new phone number is: %d", PlayerInfo[playerid][pNumber]);
SCM(playerid, COLOR_INFO, string);
SCM(playerid, COLOR_WHITE, "HINT: /cellhelp");
}