01.08.2011, 20:12
I wrote a simple system for you incase you want to use it, i haven't tested it but i cant see a problem with it. You can use this code in your own i left the include lines for testing for errors.
If you use it let me know if it works
pawn Код:
#include <a_samp>
#define ZOMBIE_RANGE (2.0)
#define ZOMBIE_UPDATE_TIME (535)
new gZombieObjects[6];
new gZombieTimerID;
forward ZombieUpdate(playerid, Float:speed);
public OnGameModeInit()//or put this in OnFilerScriptInit if it is a filterscript.
{
gZombieObjects[0] = CreateObject(2905,-2131.82617188,152.00000000,35.00876617,270.00000000,0.00000000,180.00000000); //object(kmb_deadleg) (3)
gZombieObjects[1] = CreateObject(2905,-2131.82617188,152.17556763,35.00876617,270.00000000,0.00000000,179.99450684); //object(kmb_deadleg) (4)
gZombieObjects[2] = CreateObject(2907,-2131.86035156,152.11634827,35.31094360,270.00000000,0.00000000,270.00000000); //object(kmb_deadtorso) (3)
gZombieObjects[3] = CreateObject(2906,-2131.67358398,151.92774963,35.46328735,0.00000000,0.00000000,270.00000000); //object(kmb_deadarm) (3)
gZombieObjects[4] = CreateObject(2906,-2131.70556641,152.26000977,35.46328735,0.00000000,180.00000000,270.00000000); //object(kmb_deadarm) (4)
gZombieObjects[5] = CreateObject(2908,-2131.81958008,152.08401489,35.85238647,270.00000000,0.00000000,180.00000000); //object(kmb_deadhead) (2)
}
public ZombieUpdate(playerid, Float:speed)
{
static
Float:fOx, Float:fOy, Float:fOz;
GetObjectPos(gZombieObjects[0], fOx, fOy, fOz);
if(IsPlayerInRangeOfPoint(playerid, ZOMBIE_RANGE, fOx, fOy, fOz))
{
//take health/kill? Make zombie dissapear?
KillTimer(gZombieTimerID);
}
else
{
static
Float:fPx, Float:fPy, Float:fPz;
GetPlayerPos(playerid, fPx, fPy, fPz);
MoveObject(gZombieObjects[0], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[1], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[2], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[3], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[4], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[5], fPx, fPy, fPz, speed);
}
}
MoveZombieToPlayer(playerid, Float:speed)
{
new
Float:fPx, Float:fPy, Float:fPz;
GetPlayerPos(playerid, fPx, fPy, fPz);
MoveObject(gZombieObjects[0], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[1], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[2], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[3], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[4], fPx, fPy, fPz, speed);
MoveObject(gZombieObjects[5], fPx, fPy, fPz, speed);
gZombieTimerID = SetTimerEx("ZombieUpdate", ZOMBIE_UPDATE_TIME, true, "df", playerid, speed);
}