Spawning of MYSQL Cars
#1

pawn Код:
LoadCar();
    if(PlayerInfo[playerid][pPcarkey] != 9999 && PSpawned[playerid] == 0)
    {
        new query[90], query2[90], h = PlayerInfo[playerid][pPcarkey], sname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, sname, sizeof(sname));
        format(query, sizeof(query), "SELECT * FROM `ownedcars` WHERE Owner = '%s'", sname);
        mysql_query(query);
        mysql_ store_result();
        while(mysql_retrieve_row())
        {
            ownedcar[h] = CreateVehicle(CarInfo[h][cModel],CarInfo[h][cLocationx],CarInfo[h][cLocationy],CarInfo[h][cLocationz]+1.0,CarInfo[h][cAngle],CarInfo[h][cColorOne],CarInfo[h][cColorTwo],60000);
            if(CarInfo[h][cLock] == 1)
            {
                new e,l,a,d,b,bo,o;
                GetVehicleParamsEx(h,e,l,a,d,b,bo,o);
                SetVehicleParamsEx(h,e,l,a,1,b,bo,o);
            }
            if(CarInfo[h][cPaintjob] != 999)
            {
                ChangeVehiclePaintjob(h, CarInfo[h][cPaintjob]);
            }
            if(CarInfo[h][cPlateSet] == 1)
            {
                SetVehicleNumberPlate(h, CarInfo[h][cPlate]);
            }
            SetVehicleModifications(h);
            new vmodel = GetVehicleModel(h);
            if(vmodel == 481 || vmodel == 509 || vmodel == 510)
            {
                new lights, alarm, doors, bonnet, boot, objective;
                SetVehicleParamsEx(h, 1, lights, alarm, doors, bonnet, boot, objective);
                engineOn[h] = true;
            }
            else
            {
                new lights, alarm, doors, bonnet, boot, objective;
                SetVehicleParamsEx(h, 0, lights, alarm, doors, bonnet, boot, objective);
                engineOn[h] = false;
            }
            PlayerInfo[playerid][pPcarkey] = ownedcar[h];
            printf("[SERVER]: Loaded %s's Vehicle Slot 1 [Veh ID: %d]", GetPlayerNameEx(playerid), PlayerInfo[playerid][pPcarkey]);
            format(query2, sizeof(query2), "UPDATE `ownedcars` SET spawnid = '%d' WHERE Owner = '%s'", PlayerInfo[playerid][pPcarkey], sname);
            mysql_query(query2);
            mysql_free_result();
        }
    }
I think I've nearly got the car system working, apart from one issue. "h", Before the car ID's was static, and now I'm moving them to Dynamic, Is there a way to replace that, so as you can see, I'm trying to make the cars load from %s (player name), instead of the ID's, as they are no longer static. I want them to load from the player name, when he spawns.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)