Forcing Reparse?
#1

Im using a get distance function and getting this warning:

C:\Users\Nickolas\Desktop\samp03x_svr_R1-2_win32\gamemodes\MissionScript.pwn(1676) : warning 208: function with tag result used before definition, forcing reparse

pawn Код:
stock Float:GetDistanceBetweenPoints(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2) //By Gabriel "Larcius" Cordes
{
    return floatadd(floatadd(floatsqroot(floatpower(floatsub(x1,x2),2)),floatsqroot(floatpower(floatsub(y1,y2),2))),floatsqroot(floatpower(floatsub(z1,z2),2)));
}
How would i fix this?
Reply
#2

You need to make the stock function prior to calling it. Put the code on top of your script or forward it.
Reply
#3

Yeah i found that right when ****** posted that.

Now its something weird.
Im using this function to determine the distance between two points then floatrounding it into an integer and timing it by two. For some reason it keeps equaling zero.

pawn Код:
new Float:Distance = GetDistanceBetweenPoints(mInfo[playerid][Fx],mInfo[playerid][Fy],mInfo[playerid][Fz],mInfo[playerid][Lx],mInfo[playerid][Ly],mInfo[playerid][Lz]);
    new mPay = floatround(Distance);
    mPay = mPay * 2;
 mInfo[playerid][Pay] = mPay;
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
That's probably because the equation you're using is wrong - go back and look up Pythagoras.
I may be retarded for asking this, but how is the Pythagorean theorem going to help?
Reply
#5

Are you using this to calculate payments? I Don't know how much use it'd be but here's mine that i use:
pawn Код:
new iPay[MAX_PLAYERS];

    iPay[playerid] = GetDistance(X,Y,Z,unx[playerid],uny[playerid],unz[playerid]); //this is inside the stock that returns the job.

//GetDistance from X Y Z(load) to unx uny and unz (unload)

//here's the stock for GetDistance

stock GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
    return floatround(floatsqroot(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) + ((z1 - z2) * (z1 - z2))));
}
Then giving or using the "iPay" amount:
pawn Код:
GivePlayerMoney(playerid, iPay[playerid]*8);
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Because that's how you calculate distances between points, that's the formula you use.
I get it now. (Been out of math classes for like 3 years. Haha)
Reply
#7

https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint
https://sampwiki.blast.hk/wiki/GetVehicleDistanceFromPoint

This may be a relavant and a little more accurate
Reply
#8

Quote:
Originally Posted by DobbysGamertag
Посмотреть сообщение
Are you using this to calculate payments? I Don't know how much use it'd be but here's mine that i use:
pawn Код:
new iPay[MAX_PLAYERS];

    iPay[playerid] = GetDistance(X,Y,Z,unx[playerid],uny[playerid],unz[playerid]); //this is inside the stock that returns the job.

//GetDistance from X Y Z(load) to unx uny and unz (unload)

//here's the stock for GetDistance

stock GetDistance(Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2)
{
    return floatround(floatsqroot(((x1 - x2) * (x1 - x2)) + ((y1 - y2) * (y1 - y2)) + ((z1 - z2) * (z1 - z2))));
}
Then giving or using the "iPay" amount:
pawn Код:
GivePlayerMoney(playerid, iPay[playerid]*8);
Something weird as heck is going on. Im printing the result of the the function you gave me and like the rest its returning 0;
Reply
#9

NEVERMIND. I just realized that i was defining the variables that the functon is using AFTER i called it. Its fixed now.(I feel dumb as heck)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)