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



GetDistanceBetweenPlayers - bleedis - 19.01.2013

Hello there, I were making rob for my gamemode and i have some weird stuff going on under this thing. I found in forum this

pawn Код:
forward Float:GetDistanceBetweenPlayers(p1,p2);
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
    {
        return -1.00;
    }
    GetPlayerPos(p1,x1,y1,z1);
    GetPlayerPos(p2,x2,y2,z2);
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}]
And then when i compile i got errors in this line
pawn Код:
format(string,sizeof(string),"You have robbed $%d from %s(%d).",mrand,PlayerName(ID),ID);
        SendClientMessage(playerid,COLOR_RED,string);
pawn Код:
(5644) : error 012: invalid function call, not a valid address
(5644) : warning 215: expression has no effect
(5644) : error 001: expected token: ";", but found ")"
(5644) : error 029: invalid expression, assumed zero
(5644) : fatal error 107: too many error messages on one line
Can someone help me to find out the problem?

Thanks ya all.


Re: GetDistanceBetweenPlayers - Patrick - 19.01.2013

Try this
pawn Код:
public Float:GetDistanceBetweenPlayers(p1,p2)
{
    new Float:x2,Float:y2,Float:z2;
    GetPlayerPos(p2, x2, y2, z2);
    return GetPlayerDistanceFromPoint(p1, x2, y2, z2);
}
And:
pawn Код:
format(string,sizeof(string),"You have robbed $%d from %s(%d)",mrand,PlayerName(ID),ID);
SendClientMessage(playerid,COLOR_RED,string);



Re: GetDistanceBetweenPlayers - bleedis - 19.01.2013

Still the same, seems like that sh*t doesnt aprove my string text


Re: GetDistanceBetweenPlayers - Patrick - 19.01.2013

Do you have teamviewer? Send me the ID and pass on Private Message, ill help you there better and fast


Re: GetDistanceBetweenPlayers - LarzI - 19.01.2013

How about you specify the line of the errors?