Jump to content

Cereti sisteme si le fac


nobilzeus

Recommended Posts

Simplu, compari unghiul tau cu unghiul de la player-ul care trimite damage.

 

hook OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    new Float:playerAngle, Float:attackerAngle;

	//player
    GetPlayerFacingAngle(playerid, playerAngle);
	//attacker
    GetPlayerFacingAngle(issuerid, attackerAngle);

    new Float:angleDifference = playerAngle - attackerAngle;
    if (angleDifference < -180.0 || angleDifference > 180.0)
    {
        SendClientMessage(playerid, -1, "damage from behind");
    }
    else if (angleDifference < -90.0 || angleDifference > 90.0)
    {
        SendClientMessage(playerid, -1, "damge from the side");
    }
    else
    {
        SendClientMessage(playerid, -1, "front damage");
    }

    return 1;
}

Eventual, poti sa mai adaugi si verificare de unde vine dmg-ul, sa iei numele zonei, coordonate, etc, si sa afisezi un mesaj ca te-a lovit un jucator din zona respectiva. Asta e varianta simpla.
 

 

Edited by Costi Oprea
Link to comment
Share on other sites

2 hours ago, Costi Oprea said:

Simplu, compari unghiul tau cu unghiul de la player-ul care trimite damage.

 

hook OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    new Float:playerAngle, Float:attackerAngle;

	//player
    GetPlayerFacingAngle(playerid, playerAngle);
	//attacker
    GetPlayerFacingAngle(issuerid, attackerAngle);

    new Float:angleDifference = playerAngle - attackerAngle;
    if (angleDifference < -180.0 || angleDifference > 180.0)
    {
        SendClientMessage(playerid, -1, "damage from behind");
    }
    else if (angleDifference < -90.0 || angleDifference > 90.0)
    {
        SendClientMessage(playerid, -1, "damge from the side");
    }
    else
    {
        SendClientMessage(playerid, -1, "front damage");
    }

    return 1;
}

Eventual, poti sa mai adaugi si verificare de unde vine dmg-ul, sa iei numele zonei, coordonate, etc, si sa afisezi un mesaj ca te-a lovit un jucator din zona respectiva. Asta e varianta simpla.
 

 

ai testat macar? 100% n-o sa functioneze cum crezi tu.

Link to comment
Share on other sites

1 hour ago, Sancky said:

ai testat macar? 100% n-o sa functioneze cum crezi tu.

ai dreptate, nu am testat

Varianta corecta ar fi: 

 

if (angleDifference < -135.0 || angleDifference > 135.0)
    {
        SendClientMessage(playerid, -1, "ai fost lovit din fata");
    }
    else if (angleDifference < -45.0 || angleDifference > 45.0)
    {
    	if (angleDifference < -45.0)
    	{
    		SendClientMessage(playerid, -1, "ai fost lovit din partea dreapta");
    	}
    	if (angleDifference > 45.0)
    	{
    		SendClientMessage(playerid, -1, "ai fost lovit din partea stanga");
    	} 
    }
    else
    {
        SendClientMessage(playerid, -1, "ai fost lovit din spate");
    }

 

Edited by Costi Oprea
Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.