SA-MP Forums Archive
Closest station - 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: Closest station (/showthread.php?tid=540465)



Closest station - Blademaster680 - 05.10.2014

Hi

I am busy making a RP server, and kinda stuck with a CDL job... I am wanting there to be quite a few CDL depots, and when a player types /loadtrailer, it will set a checkpoint at the closest depot for players to get the job. I also want it so that when they enter the checkpoint, it will check what depot they are at, and depending on the depot, depends on the location they can choose...

Anyone that can help me with this?
Thanks

Let me know if you need more info


Re: Closest station - PabloAguado - 05.10.2014

Well have you started coding one? if yes please hand us some code because making such a system takes times it's not easy if you already have one just give us the code and we will simply edit it and hand it to you


Re: Closest station - Josh_Main - 05.10.2014

pawn Код:
CMD:loadtrailer(playerid, params[])
{
    if(!IsPlayerInRangeOfPoint(playerid, range,x, y, z)) // add in the range, x pos, y pos and z pos of the depot for the player to get the job, and if they aren't in range of it... It will set their checkpoint here.
    {
            PlayerStat[playerid][Removalist] = 1;
            SetPlayerCheckpoint(playerid, x,y, z, size of checkpoint); // Same here.  X pos, Y pos, Z pos, size of checkpoint.  I usually use 3.0
            SendClientMessage(playerid, ORANGE, "Head towards the depot, a location has been marked on your map");
    }
    else
    {
        SendClientMessage(playerid, GREY, "You are already at the depot area!");
    }
    return 1;
}
This should work, you'll just have to edit it if you want to change it around or add code


Re: Closest station - Blademaster680 - 05.10.2014

Quote:

IsPlayerInRangeOfPoint

That would work, but the problem is I need it to see were the closest station is, not if it is in range of one... I need to get the player position, and then almost "scan" the map to see what station will be the closest... If that makes sense...


Re: Closest station - MacT - 05.10.2014

Good way you can start making dynamic areas (depot) and find nearest depot with timer or ifplyerchangedepot stock or custom function. I can figure out this but I need time.


Re: Closest station - Blademaster680 - 05.10.2014

Ok I jsut figured it out... can use GetPlayerDistanceFromPoint and just loop through all the depot's positions
Thanks all for your help