23.10.2011, 19:35
pawn Код:
#include <a_samp>
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward SharkDetect();
new Shark;
new IsMoving;
public OnFilterScriptInit()
{
Shark = CreateObject(1608, 757.7714, -1996.8455, -0.3859, 0, 0, 0, 300);
SetTimer("SharkDetect", 1001, true);
return 1;
}
public OnFilterScriptExit()
{
DestroyObject(Shark);
return 1;
}
public SharkDetect()
{
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
if(IsMoving == 0)
{
if(PlayerToPoint(40.0, playerid, 757.7714, -1996.8455, -0.3859))
{
new Float:angle;
new Float:X,Y,Z;
GetPlayerFacingAngle(playerid, Float:angle);
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
MoveObject(Shark, Float:X, Float:Y, Float:Z, 4.0, -1000.0, -1000.0, Float:angle);
IsMoving = 1;
}
}
if(IsMoving == 2)
{
if(!PlayerToPoint(40.0, playerid, 757.7714, -1996.8455, -0.3859))
{
MoveObject(Shark,757.7714, -1996.8455, -0.3859,4);
IsMoving = 0;
}
}
}
return 1;
}
public OnObjectMoved(objectid)
{
if(objectid == Shark && IsMoving == 1)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
new Float:X,Float:Y,Float:Z;
GetObjectPos(Shark,X,Y,Z);
if(IsPlayerInRangeOfPoint(playerid,5,X,Y,Z);
{
new Float:health;
GetPlayerHealth(i,health);
SetPlayerHealth(i,health-20);
IsMoving = 2;
return 1;
}
}
}
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerInRangeOfPoint(playerid, radi, x, y, z)) {
return 1;
}
return 0;
}