23.10.2011, 16:30
I have a problem with my script.
Basicly that's the whole script. The problem can be seen in video. When the shark reaches the player, he wants to move back to the old position even if the player is not out of the 40.0 range. What I'm trying to do here is to make the shark stop near the player if the player is in the 40.0 range, and return to its original position if the player is not in the 40.0 range
[ame]http://www.youtube.com/watch?v=puJpAnKNf7E[/ame]
Also, when the shark reached the player, remove 20 hp from him.
pawn Код:
#include <a_samp>
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward SharkDetect();
new Shark;
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(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);
}
}
return 1;
}
public OnObjectMoved(objectid)
{
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
if(PlayerToPoint(5.0, playerid, 757.7714, -1996.8455, -0.3859))
{
StopObject(Shark);
}
}
MoveObject(Shark, 757.7714, -1996.8455, -0.3859, 4.0);
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerInRangeOfPoint(playerid, radi, x, y, z)) {
return 1;
}
return 0;
}
[ame]http://www.youtube.com/watch?v=puJpAnKNf7E[/ame]
Also, when the shark reached the player, remove 20 hp from him.