Can you help me please?
#1

Hello guys.
How can I do that the cop who is closest to the player that the gets the money?
Currently it is so that all cops who are in the radius 30.0, get the money.
Sincerely, Imagician and here is my code:

if(IsACop(i) && CrimInRange(30.0, playerid, i))
{
count = 1;
format(string, sizeof(string), "~w~Gesuchten umgebracht~n~Bonus: ~g~%d$", price);
GameTextForPlayer(i, string, 5000, 1);
ConsumingMoney[i] = 1;
GivePlayerMoney(i, price);
PlayerPlaySound(i, 1058, 0.0, 0.0, 0.0);
SetPlayerFree(playerid, i, "Erschossen");
}
Reply
#2

You want to increase the radius?
Reply
#3

No. The player (Police / Cop), which is closest gets the money.
Reply
#4

I think you can use ProxDetectorS
Reply
#5

And how?
Reply
#6

Add this on top of script
pawn Код:
forward ProxDetectorS(Float:radi, playerid, targetid);
Add this somewhere you want after OnGameModeInit or somefhing
pawn Код:
public ProxDetectorS(Float:radi, playerid, targetid)
{
    if(IsPlayerConnected(playerid)&&IsPlayerConnected(targetid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        GetPlayerPos(targetid, posx, posy, posz);
        tempposx = (oldposx -posx);
        tempposy = (oldposy -posy);
        tempposz = (oldposz -posz);
        if(((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
        {
            return 1;
        }
    }
    return 0;
}
Usage of if(ProxDetectorS(8.0, playerid, targetid))
pawn Код:
8.0 = The Radius Like if the radius between the 2 varibles.
playerid = Player One You can use whatever you want
targetid = Player 2 You can use whatever you want here
It will get the distance of playerid and target name and if its true it will continue
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)