OnPlayerKeyStateChange callbackbe
if(((oldkeys & KEY_FIRE) && !(newkeys & KEY_FIRE)) || ((newkeys & KEY_FIRE) && !(oldkeys & KEY_FIRE)) || (newkeys & KEY_FIRE))
{
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && playerid != i && !IsPlayerNPC(i))
{
if(IsPlayerAiming(playerid, i))
{
printf(\"A jatekost eltalaltak!\")
return 1;
}
}
}
Funkció amit használ
stock IsPlayerAiming(playerid, aimid)
{
new Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2;
GetPlayerPos(playerid, X1, Y1, Z1);
GetPlayerPos(aimid, X2, Y2, Z2);
new Float:Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
if(Distance < 100)
{
new Float:A;
GetPlayerFacingAngle(playerid, A);
X1 += (Distance * floatsin(-A, degrees));
Y1 += (Distance * floatcos(-A, degrees));
Distance = floatsqroot(floatpower(floatabs(X1-X2), 2) + floatpower(floatabs(Y1-Y2), 2));
if(Distance < 0.5)
{
return true;
}
}
return false;
}