SA-MP Forums Archive
Car Function! - 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: Car Function! (/showthread.php?tid=369505)



Car Function! - Akcent_Voltaj - 17.08.2012

i got a car function it works good if i relog but if i restart host then the car isnt mine anymore..

please tell me what do you need and i will show please help fast i stopped server for this..


Re: Car Function! - Akcent_Voltaj - 17.08.2012

PHP код:
forward SaveCarCoords();
                    public 
SaveCarCoords()
                    {
                        new 
idx;
                        new 
Filefile2;
                        while (
idx sizeof(CarInfo))
                        {
                            new 
coordsstring[256];
                            
format(coordsstringsizeof(coordsstring), "%d|%f|%f|%f|%f|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d|%d\n",
                            
CarInfo[idx][cModel],
                            
CarInfo[idx][cLocationx],
                            
CarInfo[idx][cLocationy],
                            
CarInfo[idx][cLocationz],
                            
CarInfo[idx][cAngle],
                            
CarInfo[idx][cColorOne],
                            
CarInfo[idx][cColorTwo],
                            
CarInfo[idx][mod1],
                            
CarInfo[idx][mod2],
                            
CarInfo[idx][mod3],
                            
CarInfo[idx][mod4],
                            
CarInfo[idx][mod5],
                            
CarInfo[idx][mod6],
                            
CarInfo[idx][mod7],
                            
CarInfo[idx][mod8],
                            
CarInfo[idx][mod9],
                            
CarInfo[idx][mod10],
                            
CarInfo[idx][mod11],
                            
CarInfo[idx][mod12],
                            
CarInfo[idx][mod13],
                            
CarInfo[idx][mod14],
                            
CarInfo[idx][mod15],
                            
CarInfo[idx][mod16],
                            
CarInfo[idx][mod17],
                            
CarInfo[idx][paintjob]);
                            if(
idx == carsonserver)
                            {
                                
file2 fopen("masini.cfg"io_write);
                            }
                            else
                            {
                                
file2 fopen("masini.cfg"io_append);
                            }
                            
fwrite(file2coordsstring);
                            
idx++;
                            
fclose(file2);
                        }
                        return 
1;
                    }
                    
forward LoadCar();
                    public 
LoadCar()
                    {
                        new 
arrCoords[31][64];
                        new 
strFromFile2[256];
                        new 
Filefile fopen("masini.cfg"io_read);
                        if (
file)
                        {
                            new 
idx carsonserver;
                            while (
idx sizeof(CarInfo))
                            {
                                
fread(filestrFromFile2);
                                
split(strFromFile2arrCoords',');
                                
CarInfo[idx][cModel] = strval(arrCoords[0]);
                                
CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
                                
CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
                                
CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
                                
CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
                                
CarInfo[idx][cColorOne] = strval(arrCoords[5]);
                                
CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
                                
strmid(CarInfo[idx][cOwner], arrCoords[7], 0strlen(arrCoords[7]), 255);
                                
strmid(CarInfo[idx][cDescription], arrCoords[8], 0strlen(arrCoords[8]), 255);
                                
CarInfo[idx][cValue] = strval(arrCoords[9]);
                                
strmid(CarInfo[idx][cLicense], arrCoords[10], 0strlen(arrCoords[10]), 255);
                                
CarInfo[idx][cOwned] = strval(arrCoords[11]);
                                
CarInfo[idx][cLock] = strval(arrCoords[12]);
                                
CarInfo[idx][mod1] = strval(arrCoords[13]);
                                
CarInfo[idx][mod2] = strval(arrCoords[14]);
                                
CarInfo[idx][mod3] = strval(arrCoords[15]);
                                
CarInfo[idx][mod4] = strval(arrCoords[16]);
                                
CarInfo[idx][mod5] = strval(arrCoords[17]);
                                
CarInfo[idx][mod6] = strval(arrCoords[18]);
                                
CarInfo[idx][mod7] = strval(arrCoords[19]);
                                
CarInfo[idx][mod8] = strval(arrCoords[20]);
                                
CarInfo[idx][mod9] = strval(arrCoords[21]);
                                
CarInfo[idx][mod10] = strval(arrCoords[22]);
                                
CarInfo[idx][mod11] = strval(arrCoords[23]);
                                
CarInfo[idx][mod12] = strval(arrCoords[24]);
                                
CarInfo[idx][mod13] = strval(arrCoords[25]);
                                
CarInfo[idx][mod14] = strval(arrCoords[26]);
                                
CarInfo[idx][mod15] = strval(arrCoords[27]);
                                
CarInfo[idx][mod16] = strval(arrCoords[28]);
                                
CarInfo[idx][mod17] = strval(arrCoords[29]);
                                
CarInfo[idx][paintjob] = strval(arrCoords[30]);
                                
printf("CarInfo: %d Owner:%s LicensePlate %s",idx,CarInfo[idx][cOwner],CarInfo[idx][cLicense]);
                                
idx++;
                            }
                        }
                        return 
1;
                    }
                    
forward SavePlayerData(playerid);
                    public 
SavePlayerData(playerid)
                    {
                        if(
IsPlayerConnected(playerid))
                        {
                            new 
string3[32];
                            new 
playername3[MAX_PLAYER_NAME];
                            
GetPlayerName(playeridplayername3sizeof(playername3));
                            
format(string3sizeof(string3), "carkeys/%s.ini"playername3);
                            new 
FilehFile fopen(string3io_write);
                            if (
hFile)
                            {
                                new var[
32];
                                
format(var, 32"CarKey=%d\n",PlayerInfo[playerid][pPcarkey]);fwrite(hFile, var);
                                
format(var, 32"CarKey2=%d\n",PlayerInfo[playerid][pPcarkey2]);fwrite(hFile, var);
                                
format(var, 32"CarKey3=%d\n",PlayerInfo[playerid][pPcarkey3]);fwrite(hFile, var);
                                
fclose(hFile);
                            }
                        }
                        return 
1;
                    }
                    
forward CarKeys(playerid);
                    public 
CarKeys(playerid)
                    {
                        new 
string2[64];
                        new 
playername2[MAX_PLAYER_NAME];
                        
GetPlayerName(playeridplayername2sizeof(playername2));
                        
format(string2sizeof(string2), "carkeys/%s.ini"playername2);
                        new 
FileUserFile fopen(string2io_read);
                        if ( 
UserFile )
                        {
                            new 
key256 ] , val256 ];
                            new 
Data256 ];
                            while ( 
freadUserFile Data sizeofData ) ) )
                            {
                                
key ini_GetKeyData );
                                if( 
strcmpkey "CarKey" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPcarkey] = strvalval ); }
                                if( 
strcmpkey "CarKey2" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPcarkey2] = strvalval ); }
                                if( 
strcmpkey "CarKey3" true ) == ) { val ini_GetValueData ); PlayerInfo[playerid][pPcarkey3] = strvalval ); }
                            }
                            
fclose(UserFile);
                        }
                        return 
1;
                    } 



Re: Car Function! - Akcent_Voltaj - 17.08.2012

please help!!!!!!!!!!!!!


Re: Car Function! - Akcent_Voltaj - 17.08.2012

anyone help i l give rep if needed please im begging!its soo hard!