warning 202: number of arguments does not match definition
#1

Hi guys, i am getting that annoying error which is in the title of topic

The line is:

Код:
strcat(string, "{00FF00}Amount of HP{FFFFFF}: %d\n", GetPlayerHealth(playerid));
Thanks.
Reply
#2

Strcat concats i.e. joins two "strings" so you cannot format a string in the function there itself... Your code should be like

Код:
new str[10];
format(str,sizeof(str),"%f",GetPlayerHealth(playerid)); //change line here with %f not %d as health is always a real number
strcat(string,str);
Reply
#3

Well, i was celebrating really soon.

As i made it, it throwed the same error.

Few lines above and under:

Код:
	format(str,sizeof(str),"{00FF00}Team{FFFFFF}: %s\n",GetPlayerTeam(playerid));
	strcat(string, str);
	format(str,sizeof(str),"{00FF00}Amount of HP{FFFFFF}: %d\n",GetPlayerHealth(playerid));
	strcat(string, str);
Reply
#4

Oh, okay.

So i managed to fix my function as you said. Previous error fixed but new error spotted.

Код:
error 017: undefined symbol "health"
I fixed it from:

Код:
format(str,sizeof(str),"{00FF00}Amount of HP{FFFFFF}: %d\n",GetPlayerHealth(playerid));
to:

Код:
format(str,sizeof(str),"{00FF00}Amount of HP{FFFFFF}: %d\n",GetPlayerHealth(playerid,health));
Reply
#5

You are doing it wrong. In order to obtain player's health ou should create a float variable:

pawn Код:
new Float:pHP;
Then store the health value passed by reference:

pawn Код:
GetPlayerHealth(playerid,pHP);
And now you can use pHP to access it value

pawn Код:
format(string,sizeof string,"HP Amount: %.1f",pHP);
Reply
#6

Thank you for your interest and capable advice to solve my problem, this is solved and can be locked optionally moved to the solved requests for assistance.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)