SA-MP Forums Archive
number format - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: number format (/showthread.php?tid=664425)



number format - Longover - 28.02.2019

randphonec:

Код:
new randphonec = 1000000 + random(8999999)
code:

Код:
new numberro[11];
					format(numberro, sizeof(numberro), "074%s", randphonec);
					PlayerInfo[playerid][pPnumber] = numberro[11];
I want to give a phone nr. in romanian format ex: (0742133531)

Error:

Код:
error 032: array index out of bounds (variable "numberro")
on the line:

Код:
PlayerInfo[playerid][pPnumber] = numberro[11];



Format phone number - Longover - 28.02.2019

Quote:
Originally Posted by Longover
Посмотреть сообщение
randphonec:

Код:
new randphonec = 1000000 + random(8999999)
code:

Код:
new numberro[11];
					format(numberro, sizeof(numberro), "074%s", randphonec);
					PlayerInfo[playerid][pPnumber] = numberro[11];
I want to give a phone nr. in romanian format ex: (0742133531)

Error:

Код:
error 032: array index out of bounds (variable "numberro")
on the line:

Код:
PlayerInfo[playerid][pPnumber] = numberro[11];
full code,changed:

Код:
if(listitem == 0)
			{
				if(GetPlayerCash(playerid) <= 319) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money.");
				if(PlayerInfo[playerid][pPhone] == 1) return SendClientMessage(playerid, COLOR_LIGHTGREEN3, "Ai deja un iPhone.");
			    new str[184];
			    GivePlayerCash(playerid,-320);
				BizzInfo[bid][bTill] += 320;
    			mysql_format(SQL,str,sizeof(str),"UPDATE `bizz` SET `Till`='%d' WHERE `ID`='%d'",BizzInfo[bid][bTill],bid);
				mysql_tquery(SQL,str,"","");
			    GameTextForPlayer(playerid, "~r~-320 de lei", 3000, 1);
				do
				{
					new numberro[11], randphonec = 1000000 + random(8999999);
					format(numberro, sizeof(numberro), "074%s", randphonec);
					PlayerInfo[playerid][pPnumber] = numberro[11];
				}
				while(NumberUsed(playerid));
			    format(string, sizeof(string), "Ai cumparat un telefon,numarul tau este: %d.", numberro);
			    SendClientMessage(playerid, COLOR_WHITE, string);
				mysql_format(SQL,str,sizeof(str),"UPDATE users SET `Money`='%d',`PhoneNr`='%d' WHERE `name`='%s'",GetPlayerCash(playerid),PlayerInfo[playerid][pPnumber],PlayerInfo[playerid][pNormalName]);
				mysql_tquery(SQL,str,"","");
			    return 1;
            }
Errors:

Код:
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear dupa un update\gamemodes\pear.pwn(53209) : error 032: array index out of bounds (variable "numberro")
C:\Program Files (x86)\Server_Samp\Gamemode-uri\Pear dupa un update\gamemodes\pear.pwn(53212) : error 017: undefined symbol "numberro"
on the lines:

Код:
PlayerInfo[playerid][pPnumber] = numberro[11];
and:

Код:
format(string, sizeof(string), "Ai cumparat un telefon,numarul tau este: %d.", numberro);
Код:
if(listitem == 0)
			{
				if(GetPlayerCash(playerid) <= 319) return SendClientMessage(playerid, COLOR_GREY, "You don't have enough money.");
				if(PlayerInfo[playerid][pPhone] == 1) return SendClientMessage(playerid, COLOR_LIGHTGREEN3, "Ai deja un iPhone.");
			    new str[184];
			    GivePlayerCash(playerid,-320);
				BizzInfo[bid][bTill] += 320;
    			mysql_format(SQL,str,sizeof(str),"UPDATE `bizz` SET `Till`='%d' WHERE `ID`='%d'",BizzInfo[bid][bTill],bid);
				mysql_tquery(SQL,str,"","");
			    GameTextForPlayer(playerid, "~r~-320 de lei", 3000, 1);
				do
				{
					new randphonec = 1000000 + random(8999999);
					format(PlayerInfo[playerid][pPnumber], 11, "074%d", randphonec);
				}
				while(NumberUsed(playerid));
			    format(string, sizeof(string), "Ai cumparat un telefon,numarul tau este: %d.", PlayerInfo[playerid][pPnumber]);
			    SendClientMessage(playerid, COLOR_WHITE, string);
				mysql_format(SQL,str,sizeof(str),"UPDATE users SET `Money`='%d',`PhoneNr`='%d' WHERE `name`='%s'",GetPlayerCash(playerid),PlayerInfo[playerid][pPnumber],PlayerInfo[playerid][pNormalName]);
				mysql_tquery(SQL,str,"","");
			    return 1;
            }
its ok? i didn't get errors.