SA-MP Forums Archive
CAR LOADING PROBLEM. - 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: CAR LOADING PROBLEM. (/showthread.php?tid=265060)



CAR LOADING PROBLEM. - budelis - 29.06.2011

Hello,again.I need help with my loading cars script here is it:

OnGameModeInit()

CarSave();

forward CarSave();

public CarSave()
{
for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
{
new files [128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,sizeof(name));
format( files, 60, "saves/cars/%s.ini",name);
if(!fexist(files))
{
return 1;
}
print("Masinos Uzkrautos");
PlayerData[ playerid ][ CModelis ] = dini_Int( files, "Modelis");
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 ][ CModelis ], 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][Uzrakinta]=true;
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);

All saves good here is a picture:



But when i start server i don't get this message:

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);



Whats can be wrong?


Re: CAR LOADING PROBLEM. - Vince - 29.06.2011

When the server starts, there are no players connected, thus GetPlayerName returns 0 (or an empty string, not sure).


Re: CAR LOADING PROBLEM. - budelis - 29.06.2011

Then how make other way?(or how to fix this way).Thanks for answers


Re: CAR LOADING PROBLEM. - whitedragon - 29.06.2011

use vehicleid


Re: CAR LOADING PROBLEM. - budelis - 29.06.2011

but if one player buy vehicle by id 522 and other player will buy 522 then file will overwrite


Re: CAR LOADING PROBLEM. - budelis - 30.06.2011

any answers?