SA-MP Forums Archive
If player near an object the object will be destroyed - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: If player near an object the object will be destroyed (/showthread.php?tid=454813)



If player near an object the object will be destroyed - ToiletDuck - 30.07.2013

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?


Re: If player near an object the object will be destroyed - rouzbeh - 30.07.2013

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


Re: If player near an object the object will be destroyed - JimmyCh - 30.07.2013

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


Re: If player near an object the object will be destroyed - ToiletDuck - 30.07.2013

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


Re: If player near an object the object will be destroyed - rouzbeh - 30.07.2013

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


Re: If player near an object the object will be destroyed - JimmyCh - 30.07.2013

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


Re: If player near an object the object will be destroyed - ToiletDuck - 30.07.2013

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


Re: If player near an object the object will be destroyed - JimmyCh - 30.07.2013

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!


Re: If player near an object the object will be destroyed - ToiletDuck - 30.07.2013

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;
}



Re: If player near an object the object will be destroyed - JimmyCh - 30.07.2013

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.