AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Converting from string to num/float problem (https://forums.alliedmods.net/showthread.php?t=182882)

NucL3ra 04-14-2012 12:58

Converting from string to num/float problem
 
I can't convert some variables that I read from a file.

This is the code:
PHP Code:

new Float:SavedTime[33], SavedChecks[33], SavedGoChecks[33], Float:SavedOrigins[33][3]
........
new 
file fopen(tempfile"wt")
new 
vault fopen(realfile"rt")
new 
data[128], sid[32], time[25], checks[5], gochecks[5], x[25], y[25], z[25]
while( !
feof(vault) )
{
    
fgets(vaultdata127)
    
parse(datasid31time24,  checks4gochecks4x24,  y24z24)
    
    if( 
equal(sidauthid) && !exist)
    {
        
existtrue 
        SavedChecks
[id] = str_to_num(checks)
        
SavedGoChecks[id] = str_to_num(gochecks)
        
SavedTime[id] = str_to_float(time)
        
SavedOrigins[id][0]=str_to_float(x)
        
SavedOrigins[id][1]=str_to_float(y)
        
SavedOrigins[id][2]=str_to_float(z)
        
ColorChat(idGREEN"%s %f %d %d %f %f %f"sidSavedTimeSavedChecksSavedGoChecksSavedOrigins[0], SavedOrigins[1], SavedOrigins[2])
        
ColorChat(idGREEN"%s %s %s %s %s %s %s"sidtimechecksgochecksxyz)
    }
    else
    {
        
fputs(filedata
    }


On first print i get: STEAM_0:0:20106667 0.000000 0 0 0.000000 -1056964608.000000 0.000000
On second print: STEAM_0:0:20106667 25.000000 19 30 -1056964608 1098907648 -1042300928 (correct values)


I might be a little tired, but I really don't see my mistake...

Arkshine 04-14-2012 13:45

Re: Converting from string to num/float problem
 
Float:SavedOrigins[33][3]
SavedOrigins[0]

You don't see the problem ?

NucL3ra 04-14-2012 13:47

Re: Converting from string to num/float problem
 
.... :(

fysiks 04-14-2012 13:50

Re: Converting from string to num/float problem
 
Quote:

Originally Posted by NucL3ra (Post 1689096)
.... :(

That's not very descriptive of what you mean. You have to properly index the array if you want individual values in the array.

NucL3ra 04-14-2012 15:45

Re: Converting from string to num/float problem
 
Quote:

Originally Posted by fysiks (Post 1689101)
That's not very descriptive of what you mean. You have to properly index the array if you want individual values in the array.


That was my disappointing face when I realized the mistake... :D


All times are GMT -4. The time now is 07:50.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.