trouble printing a value
#1

hey guys, i recently made a dialog option for all my stores allowing them to be robbed.

it all works perfect except 1 part, i can't seem to get the script to announce to the entire server exactly how much money that player has robbed from the store.

here is a snippet of my code and most likely where the problem might be:

Код:
         new string[64];
	 new pname[MAX_PLAYER_NAME];
         new pcash = GivePlayerMoney(playerid, random(5000) + 10000);
	 GetPlayerName(playerid, pname, sizeof(pname));
         format(string, sizeof(string), "%s(%d) Robbed $%i From The 24-7!", pname, playerid, pcash);
         SendClientMessageToAll(0xAAAAAAAA, string);
         SetPVarInt(playerid,"WaitBeforeRobbing",GetTickCount()+30000);
         SetPlayerWantedLevel(playerid, 6);
         SetPlayerColor(playerid, 0xAA3333AA);
what have i done wrong?
Reply
#2

pawn Код:
new pcash = GivePlayerMoney(playerid, random(5000) + 10000);
you can't do that.
cuz after this, pcash will hold the return value of GivePlayerMoney, which is 1 (if it succeeded)

do it like this
pawn Код:
new pcash = random(5000) + 10000;
GivePlayerMoney(playerid,pcash);
Reply
#3

Ok thanks for that, but how do I print the amount robbed to everyone on the server? In SendClientMessageToAll
Reply
#4

Hey,

you can use format and SendClientMessageToAll as followed:

creating a new String, then formatting the text and finally sending it to all players

Код:
new message[128];
format(message,sizeof(message),"Robbed amount: %d",pcash);
SendClientMessageToAll(0xAAAAAAAA,message);
I hope I understood your problem right

Regards,
Max
Reply
#5

okay guys, i got it working . thanks for the help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)