Problem with car saving and loading.
#1

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).
Reply
#2

any help?
Reply
#3

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);
}
Reply
#4

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);
Reply
#5

Please help who can.
Reply
#6

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

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!
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)