SA-MP Forums Archive
How do I make this to send this message? - 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: How do I make this to send this message? (/showthread.php?tid=401122)



How do I make this to send this message? - jNkk - 21.12.2012

Hello.
This is my code:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	new wantedlevel; wantedlevel = GetPlayerWantedLevel(playerid);
	new moneyamount; moneyamount = GetPlayerMoney(playerid);
	new tax; tax = (wantedlevel*((5/100)*moneyamount))/10+random(1000);
	GivePlayerMoney(playerid,tax);
	return 1;
}
What I want is this to display a message like:
"Your total tax was <tax>"

I am not sure how to use %i or %s whatever, so please help me.
Thank you very much.


Re: How do I make this to send this message? - YoYo123 - 21.12.2012

You need to use the format() function. https://sampwiki.blast.hk/wiki/Format
Quote:

%b Inserts a number at this position in binary radix
%c Inserts a single character.
%d Inserts an integer (whole) number
%f Inserts a floating point number.
%i Inserts an integer.
%s Inserts a string.
%x Inserts a number in hexadecimal notation.
%% Inserts the literal '%'

For your problem use this code:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new wantedlevel; wantedlevel = GetPlayerWantedLevel(playerid);
    new moneyamount; moneyamount = GetPlayerMoney(playerid);
    new tax; tax = (wantedlevel*((5/100)*moneyamount))/10+random(1000);
    GivePlayerMoney(playerid,tax);
        new string[128];
        format(string, sizeof string, "Your total tax was $%d.", tax);
        SendClientMessage(playerid, -1, string);
    return 1;
}
BTW, the tax should decrease the player's money so instead of GivePlayerMoney(playerid, tax) you should use GivePlayerMoney(playerid, -tax);


Re: How do I make this to send this message? - jNkk - 21.12.2012

Haha! Didn't notice the tax part too. Thank you very much man xDDDD


Re: How do I make this to send this message? - RedCrossER - 21.12.2012

Use %d for number