INI_ParseFile loads tons of vehicles
#1

I'm having problem with "CreateVehicle" when loading it for player.

Under "public LoadUserInfo_data(playerid,name[],value[])"

I've created one dealership vehicle if the player bought vehicle from dealership then it will create it by the last place he left it/parked it.
The problem is when he enters the server it creates tons of the same vehicle in the same X,Y,Z.

I thought about " return 1; " after creating a vehicle but that didn't help. The INI_ParseFile is called before player respawns. but after he log-in.

have a clue on why this is happening?
Reply
#2

Maybe first add a print("Hi");
Then maybe check if you put it before or after respawning
If its before you might need to move where it parses the file
Reply
#3

Quote:
Originally Posted by NovaGaming
Посмотреть сообщение
Maybe first add a print("Hi");
Then maybe check if you put it before or after respawning
If its before you might need to move where it parses the file
The loading is for the user stuff & for hes vehicles in one public so it prases that after login.

First it loads vehicle components:
pawn Код:
INI_Int("VehVW",PlayerInfo[playerid][pVehVW]);
INI_Int("vModel",PlayerInfo[playerid][vModel]);
INI_Float("vX",PlayerInfo[playerid][vX]);
INI_Float("vY",PlayerInfo[playerid][vY]);
INI_Float("vZ",PlayerInfo[playerid][vZ]);
INI_Float("vA",PlayerInfo[playerid][vA]);
INI_Int("vC1",PlayerInfo[playerid][vC1]);
INI_Int("vC2",PlayerInfo[playerid][vC2]);
INI_Int("vPJ",PlayerInfo[playerid][vPJ]);
INI_Int("vLocked",PlayerInfo[playerid][vLocked]);
INI_Int("vModSlot0",PlayerInfo[playerid][pVehMod][0]);
INI_Int("vModSlot1",PlayerInfo[playerid][pVehMod][1]);
INI_Int("vModSlot2",PlayerInfo[playerid][pVehMod][2]);
INI_Int("vModSlot3",PlayerInfo[playerid][pVehMod][3]);
INI_Int("vModSlot4",PlayerInfo[playerid][pVehMod][4]);
INI_Int("vModSlot5",PlayerInfo[playerid][pVehMod][5]);
INI_Int("vModSlot6",PlayerInfo[playerid][pVehMod][6]);
INI_Int("vModSlot7",PlayerInfo[playerid][pVehMod][7]);
INI_Int("vModSlot8",PlayerInfo[playerid][pVehMod][8]);
INI_Int("vModSlot9",PlayerInfo[playerid][pVehMod][9]);
INI_Int("vModSlot10",PlayerInfo[playerid][pVehMod][10]);
INI_Int("vModSlot11",PlayerInfo[playerid][pVehMod][11]);
INI_Int("vModSlot12",PlayerInfo[playerid][pVehMod][12]);
INI_Int("vModSlot13",PlayerInfo[playerid][pVehMod][13]);
After then I'm using code below to create vehicle.
pawn Код:
if(PlayerInfo[playerid][vModel])
{
    PlayerInfo[playerid][pVeh] = CreateVehicle(PlayerInfo[playerid][vModel], PlayerInfo[playerid][vX],PlayerInfo[playerid][vY],PlayerInfo[playerid][vZ],PlayerInfo[playerid][vA],PlayerInfo[playerid][vC1],PlayerInfo[playerid][vC2],1200);
    SetVehicleVirtualWorld(PlayerInfo[playerid][pVeh], PlayerInfo[playerid][pVehVW]);
    ChangeVehiclePaintjob(PlayerInfo[playerid][pVeh], PlayerInfo[playerid][vPJ]);
    //PlayerInfo[playerid][vOwner] = RPN(playerid);
    if(PlayerInfo[playerid][vLocked]) SetVehicleParamsEx(PlayerInfo[playerid][pVeh], 0, 0, 0, 1, 0, 0, 0);
    for(new i=0; i<14; i++)
    {
        AddVehicleComponent(PlayerInfo[playerid][pVeh], PlayerInfo[playerid][pVehMod][i]);
    }
}
pawn Код:
INI_ParseFile(UserDB(playerid), "LoadUserInfo_data", .bExtra = true, .extra = playerid);
And when player spawn it creates tons of vehicles at the same position.
Reply
#4

Quote:
Originally Posted by ******
Посмотреть сообщение
I suspect you may be using the callback wrong (but it is difficult to tell without seeing any code). The callback is called once per value in your file, and ends the moment that value has been loaded. This means that any creation code in the loading callback MAY be executed multiple times, but also may never be executed if it comes after all the "INI_X" lines.
Sweet! I took the creation code and I put it after the parsing file its all good now. thank you for suggesting me about callback, now i will use it only for values.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)