SA-MP Forums Archive
warning 202: number of arguments does not match definition - 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: warning 202: number of arguments does not match definition (/showthread.php?tid=564597)



warning 202: number of arguments does not match definition - _GHT_MarK445 - 22.02.2015

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.


Re: warning 202: number of arguments does not match definition - -=Dar[K]Lord=- - 22.02.2015

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);



Re: warning 202: number of arguments does not match definition - _GHT_MarK445 - 22.02.2015

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);



Re: warning 202: number of arguments does not match definition - _GHT_MarK445 - 22.02.2015

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));



Re: warning 202: number of arguments does not match definition - arakuta - 22.02.2015

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);



Re: warning 202: number of arguments does not match definition - _GHT_MarK445 - 22.02.2015

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.