Ok, something here:
you better make it as Babul said.
I will make some parts for you:
where you buy the number:
pawn Код:
new string[128], Number;
NEWNUMBER:
Number = 940+random(699);
new numberstr[50];
format(numberstr, sizeof(numberstr), "/Numbers/%d.txt", Number); //Create a folder called 'Numbers'.
if(fexist(numberstr)) //Checks if the number is already created
{
goto NEWNUMBER;
//Will get a new number, in case the current ones does already exist.
}
else
{
//Creates the file for the corresponding number:
new File:num;
num=fopen(numberstr, io_readwrite);
//Use 'fwrite' here to write something into the file.
fclose(num);
Player[playerid][PhoneN] = Number;
}
format( string, sizeof( string ), "You have purchased a cellphone. Your number is %d.", Player[playerid][PhoneN]);
SendClientMessage( playerid, WHITE, string);
!!: You have to create a folder in scriptfiles called: Numbers
If you have any more questions, feel free to ask.
Btw, you can also make it, that the player has to enter the number he/she wishes into a dialog and check then if the number exists. Would look like this:
pawn Код:
//DialogResponse...
new string[128], Number;
Number = strval(inputtext);
if(Number > 2000000000 || Number < 10000) return SendClientMessage(playerid, RED, "ERROR: Invalid number.");
new numberstr[50];
format(numberstr, sizeof(numberstr), "/Numbers/%d.txt", Number); //Create a folder called 'Numbers'.
if(fexist(numberstr)) //Checks if the number is already created
{
return SendClientMessage(playerid, RED, "ERROR: Number already in use, take another..");
}
else
{
... same as obove
You have to create the folder here too.
So, if you have any more questions, feel free to ask.
Greetings,
Jeffry