[+rep] Help with %s and %d.
#1

pawn Код:
format(tohitman, sizeof(tohitman), "%s has requested a contract on %s for $%s. (Reason: %s) | /recievehit [id]", playerid, id, price, reason);
    format(toplayer, sizeof(toplayer), "You have requested a contract on %s for $%s. (Reason: %s)", id, price, reason);
That's the code I have, and it does this.
Then when I do /recievehit [id], it doesn't say a name.
It shows this.
/recievehit line:
pawn Код:
format(getmsg, sizeof(getmsg), "You have taken the contract on %s!", id);
Reply
#2

use:
%s - Strings. Like names, words, sentences and stuff ...
%i - for numbers (23, 43, 20, 2, etc etc) and player id (not name! Their ID)
%f - for floats, numbers with comma (34,23; 45,2450, etc etc)

So, on short, you first need to get the player name, using GetPlayerName function and then insert it in a string:
pawn Код:
new PlayerName[MAX_PLAYER_NAME];
new VictimName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, sizeof PlayerName);
GetPlayerName(id, VictimName, sizeof VictimName);
format(tohitman, sizeof(tohitman), "%s (ID %i) has requested a contract on %s (ID %i) for $%i. | /recievehit [id]", PlayerName, playerid, VictimName, id, price);
    format(toplayer, sizeof(toplayer), "You have requested a contract on %s for $%i. (Reason: %s)", VictimName, price);
You don't need no reason there.

And by the way, you don't need two strings to send multiple messages. You can reformat a string, after you send a message. For example:
pawn Код:
new str[128];
format(str, sizeof str, "This message goes to playerid who gets the contract.");
SendClientMessage(playerid, -1, str);
format(str, sizeof str, "This message goes to the leader, who can confirm his contract.");
SendClientMessage(id, -1, str);
// See ? After you send a message, you can reformat the same string and resend it to another player or to the same player aswell.
Reply
#3

NVM. I'm a retard.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)