Don't get the same number!
#10

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
Reply


Messages In This Thread
Don't get the same number! - by The Woody - 22.06.2011, 14:47
Re: Don't get the same number! - by Jeffry - 22.06.2011, 14:50
Re: Don't get the same number! - by The Woody - 22.06.2011, 14:56
Re: Don't get the same number! - by Jeffry - 22.06.2011, 15:04
Re: Don't get the same number! - by The Woody - 22.06.2011, 15:19
Re: Don't get the same number! - by Jeffry - 22.06.2011, 15:23
Re: Don't get the same number! - by Babul - 22.06.2011, 15:40
Re: Don't get the same number! - by Jeffry - 22.06.2011, 15:44
Re: Don't get the same number! - by The Woody - 22.06.2011, 16:01
Re: Don't get the same number! - by Jeffry - 22.06.2011, 17:13

Forum Jump:


Users browsing this thread: 1 Guest(s)