15.08.2010, 21:20
BUMP!!
Ok, here is the code fixed a little bit:
Ok, the vehicles now load and formats the name, but somehow its formatting it wrong :S
, here is the function i use to check if the names match:
and i use this to test it:
The output of the above function is :
So the problem is when it creates the function, its not getting the correct name
Ok, here is the code fixed a little bit:
pawn Код:
stock AddPVehiclesFromFile(FileName[])
{
if(!fexist(FileName)) return 0;
new File:VehicleFile, vModel, Float:VX, Float:VY, Float:VZ, Float:VA, vTotal, Line[128], vOwner[MAX_PLAYER_NAME+6], C1, C2, vID;
VehicleFile = fopen(FileName, io_read);
while(fread(VehicleFile, Line))
{
if(Line[0] == '/' || isnull(Line)) continue;
unformat(Line, "iffffiis[24]", vModel, VX, VY, VZ, VA, C1, C2, vOwner[24]);
vID = AddStaticVehicleEx(vModel, VX, VY, VZ, VA, -1, -1, (30*60));
format(VEHICLE_OWNER[vID][VEHOWNER], MAX_PLAYER_NAME, vOwner[24]);
vTotal++;
}
fclose(VehicleFile);
return vTotal;
}
, here is the function i use to check if the names match:
pawn Код:
stock VehicleOwner(playerid, VehicleID)
{
if(strlen(VEHICLE_OWNER[VehicleID][VEHOWNER]) == 0)
{
return -1;
}
if(!StringCompare(VEHICLE_OWNER[VehicleID][VEHOWNER],pName(playerid)))
{
return 0;
}
return 1;
}
pawn Код:
stock StringCompare(String1[], String2[])
{
if(strlen(String1) == 0 || strlen(String2) == 0)
{
return false;
}
if(strcmp(String1 ,String2, true ) == 0 )
{
printf("\"%s\" is the same as \"%s\"", String1, String2);
return true;
}
else
{
printf("\"%s\" is different from \"%s\"", String1, String2);
return false;
}
}
pawn Код:
[16:12:05] `U214
` is different from `U214`
[16:12:05] `U214
` is different from `U214`