Forcing Reparse?
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?
You need to make the stock function prior to calling it. Put the code on top of your script or forward it.
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;`
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?
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 GetDistancestock 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);`
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)
https://sampwiki.blast.hk/wiki/GetPlayerDistanceFromPoint
https://sampwiki.blast.hk/wiki/GetVehicleDistanceFromPoint

This may be a relavant and a little more accurate
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 GetDistancestock 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;
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)

Forum Jump:

Users browsing this thread: 1 Guest(s)