%d help -
i_Ryan - 23.11.2011
I am attempting to make my first gamemode, which is going to be a deathmatch gamemode to learn, however after a respawn I would like it to tell you what your kill streak currently is, obviously it is going to be one, but I would like to figure out how to use %d to tell the player. If that made any sense at all...
Here is the code:
Код:
public OnPlayerSpawn(playerid)
{
SendClientMessage(playerid, COLOR_RED, "Your objective is simple, find and kill all others. It is every man for himself!");
killstreak = 1;
format("Your currently have a %d killstreak!", killstreak);
SendClientMessage(playerid, COLOR_RED, killstreak);
return 1;
}
The main problem I am having is the "format" part. I have looked everywhere I can not understand it, nor can I understand how the wiki stated it. I have been toying around with this for the past hour and a half and no luck. At one point the format part looked something like this:
Код:
format(killstreak, sizeof(killstreak), "Your currently have a %d killstreak!", killstreak);
But it looked retarded and was not working, so I botched it to my current creation.
AW: %d help -
Drebin - 23.11.2011
Use %i.
Re: AW: %d help -
Calgon - 23.11.2011
Your code makes no sense. Where do you define 'killstreak'? Is it a string? Is it an integer?
You're trying to format an integer then display the integer in the format, which makes no sense at all.
Quote:
Originally Posted by Drebin
Use %i.
|
No, that's a pointless suggestion. %i and %d are both placeholders for integers/digits.
Re: %d help -
[MG]Dimi - 23.11.2011
pawn Код:
public OnPlayerSpawn(playerid)
{
new msg[128];//we created new string that we will format
SendClientMessage(playerid, COLOR_RED, "Your objective is simple, find and kill all others. It is every man for himself!");
killstreak = 1;
format(msg,128,"Your currently have a %d killstreak!", killstreak);
SendClientMessage(playerid, COLOR_RED, msg);
return 1;
}
Re: %d help -
i_Ryan - 23.11.2011
Quote:
Originally Posted by Calgon
Your code makes no sense. Where do you define 'killstreak'? Is it a string? Is it an integer?
You're trying to format an integer then display the integer in the format, which makes no sense at all.
No, that's a pointless suggestion. %i and %d are both placeholders for integers/digits.
|
It was a variable on the top of the script.
Quote:
Originally Posted by [MG]Dimi
pawn Код:
public OnPlayerSpawn(playerid) { new msg[128];//we created new string that we will format SendClientMessage(playerid, COLOR_RED, "Your objective is simple, find and kill all others. It is every man for himself!"); killstreak = 1; format(msg,128,"Your currently have a %d killstreak!", killstreak); SendClientMessage(playerid, COLOR_RED, msg); return 1; }
|
Thanks it fixed the error.
Re: %d help -
steki. - 23.11.2011
Don't you want to know why?
Re: %d help -
i_Ryan - 23.11.2011
Quote:
Originally Posted by Stewie`
Don't you want to know why?
|
I would love to, if one is willing to explain.
Re: %d help -
[MG]Dimi - 23.11.2011
You have to create new string variable as I did
Then format function is used with following params
Код:
(output[], len, const format[], {Float,_}:...)
In your function you don't have output and it's length. Length of output is that number after variable name (128 means 128 character spaces). You formatted message on good way but you didn't have output so it didn't have where to store that formatted message. Also in SendClientMessage you said to sent killstreak which is normal number. There you have to put formatted message like me
pawn Код:
SendClientMessage(playerid, COLOR_RED, msg);