Originally Posted by Kaperstone
ne super effectivna, nu, eta mozhna delat v pawn.
Ne zdelal eta 3D, ne hatel sdelat slishkom ``spaghetti``
(ne testiravana)
pawn Code:
stock isPlayerAimed2D(playerid) { new FLOAT:x,FLOAT:y,FLOAT:z,Float:tx,Float:ty,Float:tz,Float:Pyt,Float:Fa,Float:dx,Float:dy,Float:nFa,Aimed=false; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a); for(new j=0;j<MAX_PLAYERS;j++) { GetPlayerPos(playerid, tx, ty, tz); // Pythagoras Pyt=floatsqroot(floatadd(floatadd(floatpower(floatsub(x,tx),2),floatpower(floatsub(y,ty),2)))); dx=floatsqroot(floatpower(x-tx)); // bez minusa // Kakoi FacingAngle dolizhin bit shtob vnivo nFa=floattan(floatdiv(dx,Pyt), degrees)+SubsetFacingAngle(playerid, x, y, tx, ty); // yesli ani vmestimi i on precelivaytsa if(nFa==a&&IsPlayerAiming(playerid)) { Aimed=true; // ne uveren yesli mogu delat "return" atsuda break; } } return Aimed; } // FacingAngle ne idot po chisavuyu stock Float:SubsetFacingAngle(playerid, Float:x, Float:y, Float:tx, Float:ty) { if(tx>=x&&ty>=y) { return 0.0; }else if(tx>=x&&ty<=y) { return 270.0; }else if(tx<=x&&ty<=y) { return 180.0; }else if(tx<=x&&ty>=y) { return 90.0; } }
https://sampforum.blast.hk/showthread.php?tid=547324
pawn Code:
stock IsPlayerAiming(playerid) { new anim = GetPlayerAnimationIndex(playerid); if (((anim >= 1160) && (anim <= 1163)) || (anim == 1167) || (anim == 1365) || (anim == 1643) || (anim == 1453) || (anim == 220)) return 1; return 0; }
public OnPlayerUpdate(playerid) // You can put under OnPlayerTakeDamage or others to detect players is aiming { if(IsPlayerAiming(playerid)) { //Your some thing do here } return 1; }
EDIT: akazivaytsa ktota uzhe eta probaval i protestiraval
dumayu shto lutshe chem moi cod
https://sampforum.blast.hk/showthread.php?tid=140765
pawn Code:
stock IsPlayerAimed(playerid) { new FLOAT:x,FLOAT:y,FLOAT:z,Float:tx,Float:ty,Float:tz,Float:Pyt,Float:Fa,Float:dx,Float:dy,Float:nFa,Aimed=false; GetPlayerPos(playerid, x, y, z); GetPlayerFacingAngle(playerid, a); for(new j=0;j<MAX_PLAYERS;j++) { GetPlayerPos(playerid, tx, ty, tz); if(GetPointAngleToPoint(x, y, tx, ty) == a&&IsPlayerAiming(playerid)) { Aimed=true; break; } } return Aimed; } stock Float:GetPointAngleToPoint(Float:x2, Float:y2, Float:X, Float:Y) {
new Float:DX, Float:DY; new Float:angle;
DX = floatabs(floatsub(x2,X)); DY = floatabs(floatsub(y2,Y));
if (DY == 0.0 || DX == 0.0) { if(DY == 0 && DX > 0) angle = 0.0; else if(DY == 0 && DX < 0) angle = 180.0; else if(DY > 0 && DX == 0) angle = 90.0; else if(DY < 0 && DX == 0) angle = 270.0; else if(DY == 0 && DX == 0) angle = 0.0; } else { angle = atan(DX/DY);
if(X > x2 && Y <= y2) angle += 90.0; else if(X <= x2 && Y < y2) angle = floatsub(90.0, angle); else if(X < x2 && Y >= y2) angle -= 90.0; else if(X >= x2 && Y > y2) angle = floatsub(270.0, angle); }
return floatadd(angle, 90.0); }
SetPlayerOxygen
Vi imeyte vidu ``Stamina``
Yesli tak
https://sampforum.blast.hk/showthread.php?tid=302201
|