SA-MP Forums Archive
Arguments do not match error - 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: Arguments do not match error (/showthread.php?tid=517386)



Arguments do not match error - Pboachie - 04.06.2014

Im not sure whats going on here. Can anyone fix it?

ERROR CODE

Код:
warning 202: number of arguments does not match definition
./includes/functions.pwn(21321) : warning 202: number of arguments does not match definition
Where the error is:

Код:
			format(string, sizeof(string), "Spectating %s(%d): HP: %d Armour: %d", GetPlayerNameEx(Spectate[playerid]), Spectate[playerid], GetPlayerHealth(playerid), GetPlayerArmour(playerid));
Full Code

Код:
forward SpecUpdate(playerid);
public SpecUpdate(playerid)
{
	if(Spectating[playerid] > 0 && Spectate[playerid] != INVALID_PLAYER_ID) {	
		for(new i = 0; i < 2; i++) {
			TogglePlayerSpectating(playerid, true);
			PlayerSpectatePlayer( playerid, Spectate[playerid] );
			SetPlayerInterior( playerid, GetPlayerInterior( Spectate[playerid] ) );
			SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( Spectate[playerid] ) );
			new string[128];
			format(string, sizeof(string), "Spectating %s(%d): HP: %d Armour: %d", GetPlayerNameEx(Spectate[playerid]), Spectate[playerid], GetPlayerHealth(playerid), GetPlayerArmour(playerid));
            GameTextForPlayer(playerid, string, 5000, 2);
		}	
	}	
	return 1;
}



Re: Arguments do not match error - Koala818 - 04.06.2014

Functions GetPlayerHealth and GetPlayerArmour stores the value in a variable.
https://sampwiki.blast.hk/wiki/GetPlayerHealth
https://sampwiki.blast.hk/wiki/GetPlayerArmour

So you must do something like:
pawn Код:
forward SpecUpdate(playerid);
public SpecUpdate(playerid)
{
    if(Spectating[playerid] > 0 && Spectate[playerid] != INVALID_PLAYER_ID) {  
        for(new i = 0; i < 2; i++) {
            TogglePlayerSpectating(playerid, true);
            PlayerSpectatePlayer( playerid, Spectate[playerid] );
            SetPlayerInterior( playerid, GetPlayerInterior( Spectate[playerid] ) );
            SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( Spectate[playerid] ) );
            new string[128], Float:zhp, Float:zarmour;
            GetPlayerHealth(playerid, zhp);
            GetPlayerArmour(playerid, zarmour);
            format(string, sizeof(string), "Spectating %s(%d): HP: %f Armour: %f", GetPlayerNameEx(Spectate[playerid]), Spectate[playerid], zhp, zarmour);
            GameTextForPlayer(playerid, string, 5000, 2);
        }  
    }  
    return 1;
}



Re: Arguments do not match error - Pboachie - 04.06.2014

Quote:
Originally Posted by Koala818
Посмотреть сообщение
Functions GetPlayerHealth and GetPlayerArmour stores the value in a variable.
https://sampwiki.blast.hk/wiki/GetPlayerHealth
https://sampwiki.blast.hk/wiki/GetPlayerArmour

So you must do something like:
pawn Код:
forward SpecUpdate(playerid);
public SpecUpdate(playerid)
{
    if(Spectating[playerid] > 0 && Spectate[playerid] != INVALID_PLAYER_ID) {  
        for(new i = 0; i < 2; i++) {
            TogglePlayerSpectating(playerid, true);
            PlayerSpectatePlayer( playerid, Spectate[playerid] );
            SetPlayerInterior( playerid, GetPlayerInterior( Spectate[playerid] ) );
            SetPlayerVirtualWorld( playerid, GetPlayerVirtualWorld( Spectate[playerid] ) );
            new string[128], Float:zhp, Float:zarmour;
            GetPlayerHealth(playerid, zhp);
            GetPlayerArmour(playerid, zarmour);
            format(string, sizeof(string), "Spectating %s(%d): HP: %f Armour: %f", GetPlayerNameEx(Spectate[playerid]), Spectate[playerid], zhp, zarmour);
            GameTextForPlayer(playerid, string, 5000, 2);
        }  
    }  
    return 1;
}
Thank You +1! Worked perfectly