*** This title is not descriptive - ******
#1

Error:
C:\Users\9903286\Desktop\Server\gamemodes\CNR.pwn( 5026) : error 035: argument type mismatch (argument 2)

Lines involving error:
Код:
    new Float: phealth;
	new Float: vhealth;
	vhealth = GetVehicleHealth(vehicleid);
	phealth = GetPlayerHealth(playerid);
and
Код:
    new string[128];
    if(newstate == PLAYER_STATE_DRIVER) {
		format(string,sizeof(string), "Health: %d% Vehicle health: %d%", phealth, vhealth);
	} else {
		format(string,sizeof(string), "Health: %d%", phealth);
	}
	TextDrawShowForPlayer(playerid, string);
Reply
#2

https://sampwiki.blast.hk/wiki/Format
Reply
#3

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
So what am i supposed to look at here?
I've checked this site about 6 times already.
Reply
#4

I've edited the code as good as i can to be like the one on that page.
Код:
    new string[128];
	new vhealth = GetVehicleHealth(vehicleid);
	new phealth = GetPlayerHealth(playerid);
    if(newstate == PLAYER_STATE_DRIVER) {
		format(string,sizeof(string), "Health: %.3d Vehicle health: .4%d", phealth, vhealth);
	} else {
		format(string,sizeof(string), "Health: %.3d", phealth);
	}
	TextDrawShowForPlayer(playerid, string);
Still gives same error.
Reply
#5

A person or vehicle's health is a float, not a numerical value.

pawn Код:
new Float:vhealth = GetVehicleHealth(vehicleid);
new Float:phealth = GetPlayerHealth(playerid);
In the string, you need to update the %.3d with %.3f because again, they are floats.
Reply
#6

Changed it to:
Код:
    new string[128];
	new Float:vhealth = GetVehicleHealth(vehicleid);
	new Float:phealth = GetPlayerHealth(playerid);
    if(newstate == PLAYER_STATE_DRIVER) {
		format(string,sizeof(string), "Health: %f Vehicle health: %f", phealth, vhealth);
	} else {
		format(string,sizeof(string), "Health: %f", phealth);
	}
	TextDrawShowForPlayer(playerid, string);
Still giving me the same error, and i noticed there are two other warnings about that code:
Код:
C:\Users\9903286\Desktop\Server\gamemodes\CNR.pwn(5017) : warning 202: number of arguments does not match definition
C:\Users\9903286\Desktop\Server\gamemodes\CNR.pwn(5018) : warning 202: number of arguments does not match definition
C:\Users\9903286\Desktop\Server\gamemodes\CNR.pwn(5024) : error 035: argument type mismatch (argument 2)
Oh and btw, the error is for:
TextDrawShowForPlayer(playerid, string);
Reply
#7

TextDrawShowForPlayer requires a textdraw ID, you need to first create a textdraw and then assign a shitload of variables to it. You can then use TextDrawSetString. In your example, you would need to create a textdraw for every single playerid.

Here is an example of what you would need to do:

Under OnGameModeInit:
Код:
	for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
	{
		
		tdHealth[playerid] = TextDrawCreate(505.099975, 401.000000, "Health: 100.00");
		TextDrawBackgroundColor(tdHealth[playerid], 255);
		TextDrawFont(tdHealth[playerid], 2);
		TextDrawLetterSize(tdHealth[playerid], 0.390000, 1.700000);
		TextDrawColor(tdHealth[playerid], -1);
		TextDrawSetOutline(tdHealth[playerid], 1);
		TextDrawSetProportional(tdHealth[playerid], 1);
	}
You can then change then ShowTextDrawForPlayer(playerid, tdHealth[playerid]); and TextDrawSetString, to change the values.
Reply
#8

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
A person or vehicle's health is a float, not a numerical value.

pawn Код:
new Float:vhealth = GetVehicleHealth(vehicleid);
new Float:phealth = GetPlayerHealth(playerid);
In the string, you need to update the %.3d with %.3f because again, they are floats.
This is not how it works. Contrary to what the tooltip might say, the correct syntax is:
pawn Код:
new Float:vhealth;
GetVehicleHealth(vehicleid, vhealth);
Same for GetPlayerHealth and GetPlayerArmour.
Reply
#9

Quote:
Originally Posted by Vince
Посмотреть сообщение
This is not how it works. Contrary to what the tooltip might say, the correct syntax is:
pawn Код:
new Float:vhealth;
GetVehicleHealth(vehicleid, vhealth);
Same for GetPlayerHealth and GetPlayerArmour.
I remembered that last night but didn't care enough to change my post. Although, wouldn't it be a good idea to change that in the tooltip?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)