SA-MP Forums Archive
[Ajuda] O que estб errado nesse cуdigo: - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] O que estб errado nesse cуdigo: (/showthread.php?tid=663899)



O que estб errado nesse cуdigo: - Gabriel432135 - 14.02.2019

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)

{
    if(issuerid != INVALID_PLAYER_ID && bodypart == 9) // If not self-inflicted
    {
        new
            infoString[128],
            weaponName[24],
            victimName[MAX_PLAYER_NAME],
            attackerName[MAX_PLAYER_NAME];

        GetPlayerName(playerid, victimName, sizeof (victimName));
        GetPlayerName(issuerid, attackerName, sizeof (attackerName));
        SetPlayerHealth(playerid, 0.0);

        GetWeaponName(weaponid, weaponName, sizeof (weaponName));

        format(infoString, sizeof(infoString), "%s Deu um tiro na cabeзa de %s, usando %s", attackerName, victimName, weaponName);
        SendClientMessageToAll(AMARELO, infoString);
    }
//--------------------------------------------------------------------------------------------------------------------------------------------------
    if(issuerid != INVALID_PLAYER_ID && bodypart == 4) // If not self-inflicted
    {
        new
            infoString[128],
            weaponName[24],
            victimName[MAX_PLAYER_NAME],
            attackerName[MAX_PLAYER_NAME];

		new vida = GetPlayerHealth(playerid);

        GetPlayerName(playerid, victimName, sizeof (victimName));
        GetPlayerName(issuerid, attackerName, sizeof (attackerName));
  		SetPlayerHealth(playerid, vida - 40.0);

        GetWeaponName(weaponid, weaponName, sizeof (weaponName));

        format(infoString, sizeof(infoString), "%s Deu um tiro nas partes baixas de %s, usando %s", attackerName, victimName, weaponName);
        SendClientMessageToAll(AMARELO, infoString);
    }
    return 1;



Re: O que estб errado nesse cуdigo: - Felipealves - 14.02.2019

Aquele velho jogo do adivinhe o erro hmm


Re: O que estб errado nesse cуdigo: - JeffSantos2 - 14.02.2019

Teste assim:

Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
		if(bodypart == 9 || bodypart == 4)
		{
			new infoString[128], weaponName[24], victimName[MAX_PLAYER_NAME], attackerName[MAX_PLAYER_NAME];
			GetPlayerName(playerid, victimName, sizeof (victimName));
			GetPlayerName(issuerid, attackerName, sizeof (attackerName));

			GetWeaponName(weaponid, weaponName, sizeof (weaponName));

			if(bodypart == 9) 
			{
				SetPlayerHealth(playerid, 0.0);
				format(infoString, sizeof(infoString), "%s Deu um tiro na cabeзa de %s, usando %s", attackerName, victimName, weaponName);
			}
			else 
			{
				new Float:Vida;
				GetPlayerHealth(playerid, Vida);
				SetPlayerHealth(playerid, Vida - 40.0);
				format(infoString, sizeof(infoString), "%s Deu um tiro nas partes baixas de %s, usando %s", attackerName, victimName, weaponName);
			}
			SendClientMessageToAll(AMARELO, infoString);
    }
	return 1;
}



Re: O que estб errado nesse cуdigo: - Gabriel432135 - 15.02.2019

JeffSantos2 eu dei uma arrumada nos erros, mas vlw! O princнpio funcionou! +R