Wrong coords
#4

Look closely at this snippet from your code
PHP Code:
     cache_get_field_content(i"SpawnX"tmp);    FactionInfo[id][fSpawnX] = strval(tmp);
     
cache_get_field_content(i"SpawnY"tmp);    FactionInfo[id][fSpawnY] = strval(tmp);
     
cache_get_field_content(i"SpawnZ"tmp);    FactionInfo[id][fSpawnZ] = strval(tmp);
     
cache_get_field_content(i"ExitX"tmp);        FactionInfo[id][fExitX] = strval(tmp);
     
cache_get_field_content(i"ExitY"tmp);        FactionInfo[id][fExitY] = strval(tmp);
     
cache_get_field_content(i"ExitZ"tmp);        FactionInfo[id][fExitZ] = strval(tmp); 
you are using strval function which converts strings to integers,
this is how strval works
PHP Code:
     new floatNumber[7] = "15.623";
     
printf("%f"strval(floatNumber)); 
This would print 15 not 15.623, because it's converted to an integer (the float part is removed)
more exemples
Code:
     strval("6.23")           ==> 6
     strval("96494.544")   ==> 96494
     strval("1.0")             ==> 1
following this logic, when your current position has been calculated GetPlayerPos(...), let's say the positions are
Code:
X = 1663.2345
Y = -4959.2783
Z = 3.296
when you sue strval function on them they will be integers meaning
Code:
strval(X) = 1663
strval(Y) = -4959
strval(Z) = 3
see? All the float part is removed, and when dealing with positions, the float part matters, that's why the pickup isn't created in your exact position but offset a little bit

the correct way to go around this, is to use floatstr function instead of strval, which converts strings to
floats

*A correct snippet
PHP Code:
     cache_get_field_content(i"SpawnX"tmp);    FactionInfo[id][fSpawnX] = floatstr(tmp);
     
cache_get_field_content(i"SpawnY"tmp);    FactionInfo[id][fSpawnY] = floatstr(tmp);
     
cache_get_field_content(i"SpawnZ"tmp);    FactionInfo[id][fSpawnZ] = floatstr(tmp);
     
cache_get_field_content(i"ExitX"tmp);        FactionInfo[id][fExitX] = floatstr(tmp);
     
cache_get_field_content(i"ExitY"tmp);        FactionInfo[id][fExitY] = floatstr(tmp);
     
cache_get_field_content(i"ExitZ"tmp);        FactionInfo[id][fExitZ] = floatstr(tmp); 
reference: https://sampwiki.blast.hk/wiki/Floatstr
Reply


Messages In This Thread
Wrong coords - by StR_MaRy - 18.06.2017, 14:41
Re: Wrong coords - by Sew_Sumi - 18.06.2017, 15:55
Re: Wrong coords - by StR_MaRy - 18.06.2017, 16:52
Re: Wrong coords - by Eoussama - 18.06.2017, 17:13
Re: Wrong coords - by skuller12 - 18.06.2017, 17:15
Re: Wrong coords - by CrossUSAAF - 18.06.2017, 17:33
Re: Wrong coords - by StR_MaRy - 18.06.2017, 17:38

Forum Jump:


Users browsing this thread: 3 Guest(s)