How to save the bought car to the .ini file
#1

pawn Код:
enum pInfo
{
    vModel,
    Float:vLoc[4],
    vOwner[MAX_PLAYER_NAME]
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{
    new strLoc[8];
    INI_Int("Password",PlayerInfo[playerid][pPass]);
    INI_Int("Cash",PlayerInfo[playerid][pCash]);
    INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_Int("Scores",PlayerInfo[playerid][pScores]);
    INI_Int("IP",PlayerInfo[playerid][IP]);
    INI_Int("Model",PlayerInfo[playerid][vModel]);
    for(new i = 0; i < 4; i++)
    {
    format(strLoc, sizeof(strLoc), "Loc%d", i);
    INI_Float(strLoc, PlayerInfo[playerid][vLoc][i]);
    }
    INI_String("Owner", PlayerInfo[playerid][vOwner], MAX_PLAYER_NAME);
    return 1;
}
pawn Код:
forward SavePlayer(playerid);
SavePlayer(playerid)
{
    //new strLoc[8];
    new INI:File = INI_Open(UserPath(playerid));
    for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, weapons[playerid][i][0], weapons[playerid][i][1]);
    INI_SetTag(File,"Player Data");
    INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
    INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
    INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
    INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
    INI_WriteString(File,"IP", PlayerInfo[playerid][IP]);
    INI_WriteInt(File,"Scores",PlayerInfo[playerid][pScores]);
    INI_WriteInt(File,"Model", PlayerInfo[playerid][vModel]);
    for(new i; i  < 4; i++)
    {
        format(strLoc, sizeof(strLoc), "Loc%d", i);
        INI_WriteFloat(File, strLoc, PlayerInfo[playerid][vLoc][i]);
    }
    INI_WriteString(File, "Owner", PlayerInfo[playerid][vOwner]);
    INI_Close(File);
}

OnDialog
pawn Код:
if(listitem == 1)
            {
                if(GetPlayerMoney(playerid) <15000) return SendClientMessage(playerid, CR," You do not have enough cash!");
                new Float:_Position[4];
                GetPlayerPos( playerid, _Position[ 0 ], _Position[ 1 ], _Position[ 2 ] );
                GetPlayerFacingAngle( playerid, _Position[ 3 ] );
                CreateVehicle(481,_Position[0],_Position[1],_Position[2],_Position[3],-1,-1,-1);
                PutPlayerInVehicle(playerid, 481, 0);
                GivePlayerMoney(playerid, -400000);
                SendClientMessage(playerid, -1,""CLG"[SERVER] "CLW"You successfully purchased a BMX for 400,000$!");
            }
My question is how do I save the car to the players .ini file and make him the owner of that car?
I created a stock but it failed here
pawn Код:
stock VehicleCreate(vehicleModel, Float:vehicleLoc[4],vehicleOwner,playerid)
{
    PlayerInfo[playerid][vModel] = vehicleModel;
    PlayerInfo[playerid][vLoc] = vehicleLoc
    format(PlayerInfo[playerid][vOwner], MAX_PLAYER_NAME, vehicleOwner)
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)