Buying a phone crashes server
#1

All this code pasted is extracted from a market dialog within the script.

PHP код:
if(PlayerInfo[playerid][HasPhone] == 1) return SendClientMessage(playeridGREY"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(playeridLIBLUE"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.
Reply
#2

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
Reply
#3

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;
Reply
#4

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
Reply


Forum Jump:


Users browsing this thread: