#include <a_samp>
forward tiburon();
forward PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z);
forward ObjectToPoint(Float:radi, tibu, Float:x, Float:y, Float:z);
new CheckTibu;
new tibu1;
new Float:px, Float:py, Float:pz,Float:tx, Float:ty, Float:tz;
new bool: AttackShark[MAX_PLAYERS];
public OnGameModeInit()
{
tibu1 = CreateObject(1608,2933.6648,-2369.7048,-0.1378,0,0,0);
CheckTibu = SetTimer("tiburon", 1000, 1);
return 1;
}
public PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
public ObjectToPoint(Float:radi, tibu, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetObjectPos(tibu, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
public tiburon()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
//tiburon 1
GetObjectPos(tibu1, tx, ty, tz);
GetPlayerPos(tibu1, px, py, pz);
if(PlayerToPoint(1.0, i,tx, ty, tz)&& AttackShark[i] == false)
{
AttackShark[i] = true;
SetPlayerHealth(i,0.0);
MoveObject(tibu1, px, py, pz, 4.0);
}
else if(PlayerToPoint(10.0, i,tx, ty, tz)&& AttackShark[i] == false)
{
AttackShark[i] = false;
MoveObject(tibu1, px, py, pz, 4.0);
}
else if(ObjectToPoint(1, tibu1, 1481.7092,3031.3877,-5.5186))
{
MoveObject(tibu1, 1476.9131,3014.5708,-1.0782, 4.0);
}
else if(ObjectToPoint(1, tibu1,1476.9131,3014.5708,-1.0782))
{
MoveObject(tibu1, 1481.7092,3031.3877,-5.5186, 4.0);
}
//end tiburon 1
}
}
Originally Posted by patchkinson
bout if player in on sea dunno if theres a state of player swimming, if not you have to create playerinrangeofpoint all over the sea xD
|