SA-MP Forums Archive
Problem with car saving and loading. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with car saving and loading. (/showthread.php?tid=264819)



Problem with car saving and loading. - budelis - 27.06.2011

Hello people,I need help.I wanna ask you,i have save my car by player name:


new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
new files[ 60 ];

format( files, 60, "saves/cars/%s.ini",name);

All saves well,but with loading bad,i don't know how to make when server is on,then load cars(OnGameModeInit).

new files [128];
for(new playerid=0; playerid<MAX_VEHICLES; playerid++)
{
format(files, sizeof(files),"saves/cars/%s.ini",playerid );


I try this and do not work(maybe you can fix that).Maybe it's impossible to load file with player name,then please show me other way.Thanks for answers(and sorry for bad english).


Re: Problem with car saving and loading. - budelis - 28.06.2011

any help?


Re: Problem with car saving and loading. - [HiC]TheKiller - 28.06.2011

For the 2nd one, there is multiple errors. Do something like this:

pawn Код:
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,sizeof(name));
    format( files, 60, "saves/cars/%s.ini",name);
}



Re: Problem with car saving and loading. - budelis - 28.06.2011

Do not work.Maybe look in this:
OnGameModeInit

CarSave();

public CarSave()
{
new files [128];
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format( files, 60, "saves/cars/%s.ini",name);
if(!fexist(files))
{
return 1;
}
print("Cars suceful loading");
PlayerData[ playerid ][ CarType ] = dini_Int( files, "CarType");
PlayerData[ playerid ][ pX ] = dini_Float( files, "PosX");
PlayerData[ playerid ][ pY ] = dini_Float( files, "PosY");
PlayerData[ playerid ][ pZ ] = dini_Float( files, "PosZ");
PlayerData[ playerid ][ pA ] = dini_Float( files, "PosA");
VehicleInfo[ playerid ][ Color1 ] = dini_Int( files, "Color1");
VehicleInfo[ playerid ][ Color2 ] = dini_Int( files, "Color2");
new carid = CreateVehicle(PlayerData[ playerid ][ CarType ], PlayerData[ playerid ][ pX ], PlayerData[ playerid ][ pY ], PlayerData[ playerid ][ pZ ],PlayerData[ playerid ][ pA ], VehicleInfo[ playerid ][Color1], VehicleInfo[ playerid ][Color2], -1);
PlayerData[playerid][pcar]=carid;
vehicleDB[carid][lock]=true;
new string[128];
format(string,128,"Model:%d,X:%f,Y:%f,Z:%f,A:%f",P layerData[ playerid ][ CarType ], PlayerData[ playerid ][ pX ], PlayerData[ playerid ][ pY ], PlayerData[ playerid ][ pZ ], PlayerData[ playerid ][ pA ]);
print(string);




And why i don't get this message:

new string[128];
format(string,128,"Model:%d,X:%f,Y:%f,Z:%f,A:%f",P layerData[ playerid ][ CModelis ], PlayerData[ playerid ][ pX ], PlayerData[ playerid ][ pY ], PlayerData[ playerid ][ pZ ], PlayerData[ playerid ][ pA ]);
print(string);


Re: Problem with car saving and loading. - budelis - 28.06.2011

Please help who can.


Re: Problem with car saving and loading. - budelis - 28.06.2011

sorry for double post but any can't help me?


Re: Problem with car saving and loading. - budelis - 28.06.2011

very very sorry for triple post but I don't understand why when i use number all is fine?why with name can't load cars please help!