Buying a phone crashes server - 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: Buying a phone crashes server (
/showthread.php?tid=572064)
Buying a phone crashes server -
ChromeAmazing - 25.04.2015
All this code pasted is extracted from a market dialog within the script.
PHP код:
if(PlayerInfo[playerid][HasPhone] == 1) return SendClientMessage(playerid, GREY, "You already have purchased this item before.");
new number = 100000 + random(899999);
GivePlayerMoney(playerid,-200);
BusinessInfo[InsideBiz[playerid]][bMoney] += 200;
PlayerInfo[playerid][PhoneNumber] = number;
SendClientMessage(playerid, LIBLUE, "Market: You have purchased a phone! You may now use all commands listed in [/help server]. Your number is %s.");
PlayerInfo[playerid][HasPhone] = 1;
return 1;
For some reason this code crashes my server.
Re: Buying a phone crashes server -
Lordzy - 25.04.2015
You must format the string before using it with SendClientMessage function since it has got specifiers.
pawn Код:
SendClientMessage(playerid, LIBLUE, "Market: You have purchased a phone! You may now use all commands listed in [/help server]. Your number is %s.");
//%s - it has to be formatted
Re: Buying a phone crashes server -
Shaktimaan - 25.04.2015
pawn Код:
if(PlayerInfo[playerid][HasPhone] == 1) return SendClientMessage(playerid, GREY, "You already have purchased this item before.");
new number = 100000 + random(899999);
GivePlayerMoney(playerid,-200);
BusinessInfo[InsideBiz[playerid]][bMoney] += 200;
PlayerInfo[playerid][PhoneNumber] = number;
new string[128];
format(string, sizeof(string), "Market: You have purchased a phone! You may now use all commands listed in [/help server]. Your number is %s.", number);
SendClientMessage(playerid, LIBLUE, string );
PlayerInfo[playerid][HasPhone] = 1;
return 1;
Re: Buying a phone crashes server -
Mencent - 25.04.2015
Quote:
Originally Posted by Shaktimaan
pawn Код:
if(PlayerInfo[playerid][HasPhone] == 1) return SendClientMessage(playerid, GREY, "You already have purchased this item before."); new number = 100000 + random(899999); GivePlayerMoney(playerid,-200); BusinessInfo[InsideBiz[playerid]][bMoney] += 200; PlayerInfo[playerid][PhoneNumber] = number;
new string[128]; format(string, sizeof(string), "Market: You have purchased a phone! You may now use all commands listed in [/help server]. Your number is %s.", number); SendClientMessage(playerid, LIBLUE, string ); PlayerInfo[playerid][HasPhone] = 1; return 1;
|
Hello!
Take a string length of 145, but the chat can show 144 symbols with the EOS.
Mencent