How do I make this to send this message?
#1

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.
Reply
#2

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

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

Use %d for number
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)