If player near an object the object will be destroyed
#1

Well, how can i do that detects if player near in that object and that object will be destroyed do i need to use timers for that?
Reply
#2

you want when you go near a object that object will destroy?
sry because my english in not good
Reply
#3

Hi, well I'm half sure you can.
You will need to see if player is near object, using a stock.
Add the following:
pawn Код:
stock IsPlayerNearObject(playerid, objectid, Float:range)
{
    new Float:X, Float:Y, Float:Z;
    GetObjectPos(objectid, X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z))return true;
    return false;
}
Now you can use the following:
pawn Код:
IsPlayerNearObject(playerid, OBJECT-HERE, Range) return DestroyObject(objectid);
Well something like that, hope you get the idea
Reply
#4

Quote:
Originally Posted by JimmyCh
Посмотреть сообщение
Hi, well I'm half sure you can.
You will need to see if player is near object, using a stock.
Add the following:
pawn Код:
stock IsPlayerNearObject(playerid, objectid, Float:range)
{
    new Float:X, Float:Y, Float:Z;
    GetObjectPos(objectid, X, Y, Z);
    if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z))return true;
    return false;
}
Now you can use the following:
pawn Код:
IsPlayerNearObject(playerid, OBJECT-HERE, Range) return DestroyObject(objectid);
Well something like that, hope you get the idea
oh i see thanks for the idea, but i think i will need a timer for that so that it detects every seconds correct me if im wrong
Reply
#5

IsPlayerInRangeOfPoint work when you going near a position and dont need a timer
Reply
#6

Well depending on what you want the script to be, you can put a timer for the DestroyObject(objectid) depending on your needs
Reply
#7

Quote:
Originally Posted by rouzbeh
Посмотреть сообщение
IsPlayerInRangeOfPoint work when you going near a position and dont need a timer
you dont get my point, c'oz im making unique job for my server

When player using a vehicle and he run over the object the object will destroyed
Reply
#8

So you can do range like 0.5 or even less, am I right?
That would work, with the stock I gave you.
Good luck anyway!
Reply
#9

btw maybe this should work if i use Incognitos OnplayerEnterDynamicArea?

pawn Код:
SetPVarInt(playerid, "Object", CreateDynamicSphere(x, y, z, 0.5, 0, 0);
public OnPlayerEnterDynamicArea(playerid, areaid)
{
    if(GetPVarType(playerid, "Object"))
    {
        if(areaid == GetPVarInt(playerid, "Objects"))
        {
            DestroyObject(objectid);
            return 1;
        }
    }
    return 1;
}
Reply
#10

Hmm, but must be a really small area.
I would suggest my IsPlayerNearObject because it's efficient and it's EXACTLY what you were looking for.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)