MoveObject
#3

Quote:
Originally Posted by AeroBlast
Посмотреть сообщение
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;
}
I don't know if this works.
It works but now how it's supposed to do. Here's a video to show you what's not working.

[ame]http://www.youtube.com/watch?v=ERY0OaXhtuo[/ame]

The shark is going to the place where the command was called. (In that case, where the player enters the 40 range) The shark is not following the player anymore and that's the problem. Besides that, the "bite" thing works just fine. If there is any way to make a timer or something so the shark would "bite" every 2 seconds would be even more awesome! Please don't mind the music in the video, I forgot to stop it when I recorded and I didn't know it'll record the music too.
Reply


Messages In This Thread
MoveObject - by marko94 - 23.10.2011, 16:30
Re: MoveObject - by AeroBlast - 23.10.2011, 19:35
Re: MoveObject - by marko94 - 23.10.2011, 22:30
Re: MoveObject - by AeroBlast - 24.10.2011, 05:56

Forum Jump:


Users browsing this thread: 1 Guest(s)