PDA

View Full Version : Cellphone


Dan_Barocu
08/05/2012, 09:30 PM
how can i make so if i get a phonebook all numbers start with 750XXXXXXX?all numbers?so at start i dont want a phonebook but if i buy a phone book i get a number 750XXXXXXX..this is the buy..


if (item == 1 && GetPlayerCash(playerid) > 500)
{
if(PlayerInfo[playerid][pTraderPerk] > 0)
{
new skill = 500 / 100;
new price = (skill)*(PlayerInfo[playerid][pTraderPerk]);
new payout = 500 - price;
format(string, sizeof(string), "~r~-$%d", payout);
GameTextForPlayer(playerid, string, 5000, 1);
GivePlayerCash(playerid,- payout);
SBizzInfo[9][sbTill] += payout;
ExtortionSBiz(9, payout);
}
else
{
format(string, sizeof(string), "~r~-$%d", 500);
GameTextForPlayer(playerid, string, 5000, 1);
GivePlayerCash(playerid,-500);
SBizzInfo[9][sbTill] += 500;
ExtortionSBiz(9, 500);
}
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
new randphone = 1000000 + random(8999999);//minimum 1000 max 9999
PlayerInfo[playerid][pPnumber] = randphone;
format(string, sizeof(string), " Mobile Phone Purchased your new Number is %d", randphone);
SendClientMessage(playerid, COLOR_GRAD4, string);
SendClientMessage(playerid, COLOR_GRAD5, "You can check this anytime by Typing /stats");
SendClientMessage(playerid, COLOR_WHITE, "HINT: You can now type /help to see your cell phone commands.");
return 1;
}

ReneG
08/05/2012, 10:03 PM
Math.

750000+random(999)

Dan_Barocu
08/05/2012, 10:12 PM
just that?:O

ReneG
08/05/2012, 10:17 PM
Just that.

Dan_Barocu
09/05/2012, 04:08 PM
Math.

750000+random(999)



but it gave me a number of 750XXXX?i want the total of 10 numbers..

TzAkS.
09/05/2012, 04:12 PM
A little bit biger but..
7500000000+random(9999999)
Maxim number will be 7509999999

Dan_Barocu
09/05/2012, 04:37 PM
A little bit biger but..
7500000000 + random(9999999)
Maxim number will be 7509999999

like this?
new randphone = 7500000000 + random(9999999);//minimum 1000 max 9999

TzAkS.
09/05/2012, 04:40 PM
Yes,will make a random for 0000000 and 750 will be intact.

Dan_Barocu
09/05/2012, 04:42 PM
the phone number gives me an -323423423 a phone number :O

Dan_Barocu
09/05/2012, 06:07 PM
no work..i get 10000000 big numbers..

Dan_Barocu
09/05/2012, 06:11 PM
i tried like this to i have 9 but doesent start with 750..

new randphone = random(750000000);//minimum 1000 max 9999

john_jenkins
09/05/2012, 06:35 PM
the big number is the number of the phone

Dan_Barocu
09/05/2012, 06:40 PM
can you show me how it is normaly?start with 750000000!but randomly with these 9 and starting with 750.

Joe Staff
09/05/2012, 06:58 PM
You can't have a number larger than 0x7FFFFFFF (2,147,483,647)

Since all phone number are going to be 750, why not just worry about the XXX-XXXX part? Or if you're too lazy to make that, just use a string.

Dan_Barocu
09/05/2012, 08:05 PM
what do you mean show me an example.

Joe Staff
09/05/2012, 08:19 PM
stock CreateNumber(string,length=sizeof string)
{
string="";
strcat(string,"750");
for(new cell=strlen(string);cell<length; cell++)strcat(string,random('9'+1)-'0');
}

public OnGameModeInit()
{
new string[11];
print(CreateNumber(string);
}


SHOULd print this

"7501234567"

Jonny5
09/05/2012, 08:37 PM
want me create it just do to me reputation me
sad you beg for rep,
make the fix and see if it works then let them decide to give you rep~

i see this is not the first place you demand rep before youll help,




edit: joe's got a good soluition
Mind if i use this also?

8)

milanosie
09/05/2012, 10:04 PM
there is a number limit on integers I believe.

Dan_Barocu
10/05/2012, 02:11 PM
do i do anything here?

if (item == 1 && GetPlayerCash(playerid) > 500)
{
if(PlayerInfo[playerid][pTraderPerk] > 0)
{
new skill = 500 / 100;
new price = (skill)*(PlayerInfo[playerid][pTraderPerk]);
new payout = 500 - price;
format(string, sizeof(string), "~r~-$%d", payout);
GameTextForPlayer(playerid, string, 5000, 1);
GivePlayerCash(playerid,- payout);
SBizzInfo[9][sbTill] += payout;
ExtortionSBiz(9, payout);
}
else
{
format(string, sizeof(string), "~r~-$%d", 500);
GameTextForPlayer(playerid, string, 5000, 1);
GivePlayerCash(playerid,-500);
SBizzInfo[9][sbTill] += 500;
ExtortionSBiz(9, 500);
}
PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
new randphone = 1000 + random(8999);//minimum 1000 max 9999
PlayerInfo[playerid][pPnumber] = randphone;
format(string, sizeof(string), " Mobile Phone Purchased your new Number is %d", randphone);
SendClientMessage(playerid, COLOR_GRAD4, string);
SendClientMessage(playerid, COLOR_GRAD5, "You can check this anytime by Typing /stats");
SendClientMessage(playerid, COLOR_WHITE, "HINT: You can now type /help to see your cell phone commands.");
return 1;
}