Mysql - update multiple rows!
#1

Hey, I'm new to SA:MP programming, but I have some experience with PHP and Mysql programming.
I'm using Vortex gamemode and I'm having a problem with the cars.

So, the vehicles table contains the rows id, x, y, z and some other stuff..

What I'm trying to do is everytime the gamemode starts (ongamemodeinit or something.. ) to have the ids of the cars ordered. So, if I have 5 cars with the ids 1, 2, 4, 6 and 11, I want the ids to be updated to 1, 2, 3, 4 and 5.

I need a function like:
Код:
stock updatecarid(){
 while(something){
    // update the cars ids!
 }
}
I tried doing that for a few hours and.. nothing.
Can someone please help me?

Thanks!
Reply
#2

And why exactly would you want to do that?
Reply
#3

I want to be able to delete cars ingame using a command like /deletecar. The command does that:

Код:
		    format(queryString, sizeof(queryString), "DELETE FROM vehicles WHERE vehicleID = %d", GetPlayerVehicleID(playerid));
		    mysql_query(queryString);
But, if I have 5 cars in the database with the ids 1,2,3,5 and 9 and I try to delete the car with the id 9 (by getting in the car and typing /delete), the car that will be deleted will be car with id 5, because in SAMP the ids of the cars are in order.

Another solution it would be if I would be able to delete the fifth row. Don't know if that's something that you can do in SA:MP.
Reply
#4

Quote:
Originally Posted by im
Посмотреть сообщение
I want to be able to delete cars ingame using a command like /deletecar. The command does that:

Код:
		    format(queryString, sizeof(queryString), "DELETE FROM vehicles WHERE vehicleID = %d", GetPlayerVehicleID(playerid));
		    mysql_query(queryString);
But, if I have 5 cars in the database with the ids 1,2,3,5 and 9 and I try to delete the car with the id 9 (by getting in the car and typing /delete), the car that will be deleted will be car with id 5, because in SAMP the ids of the cars are in order.

Another solution it would be if I would be able to delete the fifth row. Don't know if that's something that you can do in SA:MP.
if you want to do something in sa-mp what you can do is make a variable array sized [MAX_VEHICLES] and assign each vehicleid the database id so you can quicly delete from the database.
Reply
#5

Quote:
Originally Posted by Gamer_Z
Посмотреть сообщение
if you want to do something in sa-mp what you can do is make a variable array sized [MAX_VEHICLES] and assign each vehicleid the database id so you can quicly delete from the database.
Could you please tell me how exactly would I do that?
The vehicle are spawned using

Код HTML:
vehicleVariables[x][vVehicleScriptID] = CreateVehicle(vehicleVariables[x][vVehicleModelID], vehicleVariables[x][vVehiclePosition][0], vehicleVariables[x][vVehiclePosition][1], vehicleVariables[x][vVehiclePosition][2], vehicleVariables[x][vVehicleRotation], vehicleVariables[x][vVehicleColour][0], vehicleVariables[x][vVehicleColour][1], 60000);
The CreateVehicle function doesn't accept an ID parameter.
Reply
#6

Код:
format(query, sizeof(query), "DELETE FROM `vehicles` WHERE ID=%d", vehicleVariables[vehicleid][ID]);
mysql_query(query);
Reply
#7

Quote:
Originally Posted by im
Посмотреть сообщение
Could you please tell me how exactly would I do that?
The vehicle are spawned using

Код HTML:
vehicleVariables[x][vVehicleScriptID] = CreateVehicle(vehicleVariables[x][vVehicleModelID], vehicleVariables[x][vVehiclePosition][0], vehicleVariables[x][vVehiclePosition][1], vehicleVariables[x][vVehiclePosition][2], vehicleVariables[x][vVehicleRotation], vehicleVariables[x][vVehicleColour][0], vehicleVariables[x][vVehicleColour][1], 60000);
The CreateVehicle function doesn't accept an ID parameter.
This is some code from my mode: (yay I'm a poet lol)
pawn Код:
enum Vehicle_E
{
    VID,
    ModelID,
    Owner[32],
    OwnerType,
    Color1,
    Color2,
    PaintJobID,
    Float:Spawn[3],
    Float:Angle,
    Float:Fuel,
    Price,
    Text3D:LabelID,
    InteriorID,
    VirtualWorld,
    V_Size,
    Components[14],
    bool:IsTrailer,
    bool:IsPlane,
    bool:IsHeli,
    bool:IsTruck,
    bool:IsBoat
};

new Vehicle[MAX_VEHICLES ][Vehicle_E];

forward OnQueryFinish(query[],resultid, extraid, connectionHandle);
public OnQueryFinish(query[],resultid, extraid, connectionHandle)
{
    switch(resultid)
    {
        case LOAD_VEHICLES:
        {
            mysql_store_result();
            new id = 0//,unused
            ;
            new vid,ot,mid,tmpid,colors[2],pjid,Float:spwn[5],pricx,interior,world,componenty[14];
            while(mysql_fetch_row_format(GlobalString2048))
            {
                //id++;
                sscanf(GlobalString2048,"p<|>ddddddds[32]fffffddddddddddddddddd",
                    vid,//Vehicle[id][VID],
                    ot,//Vehicle[id][OwnerType],
                    mid,//Vehicle[id][ModelID],
                    tmpid,//unused,
                    colors[0],//Vehicle[id][Color1],
                    colors[1],//Vehicle[id][Color2],
                    pjid,//Vehicle[id][PaintJobID],
                    GlobalString32,//Vehicle[id][Owner],
                    spwn[0],//Vehicle[id][Spawn][0],
                    spwn[1],//Vehicle[id][Spawn][1],
                    spwn[2],//Vehicle[id][Spawn][2],
                    spwn[3],//Vehicle[id][Angle],
                    spwn[4],//Vehicle[id][Fuel],
                    pricx,//Vehicle[id][Price],
                    interior,//Vehicle[id][InteriorID],
                    world,//Vehicle[id][VirtualWorld],
                    componenty[0],
                    componenty[1],
                    componenty[2],
                    componenty[3],
                    componenty[4],
                    componenty[5],
                    componenty[6],
                    componenty[7],
                    componenty[8],
                    componenty[9],
                    componenty[10],
                    componenty[11],
                    componenty[12],
                    componenty[13]
                );
               
                tmpid = CreateNormalVehicle(mid,spwn[0],spwn[1],spwn[2],spwn[3],colors[0],colors[1],999999999);
                Vehicle[tmpid][Components] = componenty;
                LoadCarComponents(tmpid);
                SetVehicleVirtualWorld(tmpid,world);
                LinkVehicleToInterior(tmpid,interior);
                mysql_query(sprintf("update `vehicles` set `tmp_vehice_id` = %d WHERE `v_id` = %d",tmpid,vid));
                Vehicle[tmpid][VID] = vid;
                Vehicle[tmpid][OwnerType]=ot;
                //if(Vehicle[tmpid][OwnerType] != 0)
                //{
                //    Vehicle[tmpid][LabelID] = Create3DTextLabel(sprintf("%s\nOwner: %s",aVehicleNames[mid-400],GlobalString32), 0x008080FF, 0.0, 0.0, 0.0, 35.0, 0, 0);
                //    Attach3DTextLabelToVehicle(Vehicle[tmpid][LabelID],tmpid,0.0,0.0,0.0);
                //}
                //else
                //{
                Vehicle[tmpid][LabelID] = Text3D:(-1);
                //}
                Vehicle[tmpid][ModelID]=mid;
                Vehicle[tmpid][Color1]=colors[0];
                Vehicle[tmpid][Color2]=colors[1];
                Vehicle[tmpid][PaintJobID]=pjid;
                Vehicle[tmpid][Owner]=GlobalString32;
                Vehicle[tmpid][Spawn][0]=spwn[0];
                Vehicle[tmpid][Spawn][1]=spwn[1];
                Vehicle[tmpid][Spawn][2]=spwn[2];
                Vehicle[tmpid][Angle]=spwn[3];
                Vehicle[tmpid][Fuel]=spwn[4];
                Vehicle[tmpid][Price]=pricx;
                Vehicle[tmpid][InteriorID]=interior;
                Vehicle[tmpid][VirtualWorld]=world;

                id++;
            }
            if(id == 0)
            {
                mysql_free_result();
                print("No vehicles loaded... inserting default vehicles");
                InsertDefaultVehicles();
                return 1;
            }
            printf("Loaded %d vehicles",id);
            mysql_free_result();
        }
    }
    return 1;
}

stock InsertDefaultVehicles()
{
    if(!fexist("vehicles.dat"))
    {
        print("Cannot find 'vehicles.dat' in scriptfiles folder. No vehicles on server will be available. Quiting...");
        SendRconCommand("exit");
        return 0;
    }
    new File:fh = fopen("vehicles.dat",io_read);
    new modelid,Float:Position[4],Color_x[2];
    while(fread(fh,GlobalString256))
    {
        //print(GlobalString256);
        sscanf(GlobalString256,"p<,>dffffdd",modelid,Position[0],Position[1],Position[2],Position[3],Color_x[0],Color_x[1]);
        mysql_query(sprintf("INSERT INTO `vehicles` (model_id,spawnx,spawny,spawnz,angle,color_1,color_2) VALUES (%d,%f,%f,%f,%f,%d,%d)",modelid,Position[0],Position[1],Position[2],Position[3],Color_x[0],Color_x[1]));
        //print(sprintf("INSERT INTO `vehicles` (model_id,spawnx,spawny,spawnz,angle,color_1,color_2) VALUES (%d,%f,%f,%f,%f,%d,%d)",modelid,Position[0],Position[1],Position[2],Position[3],Color_x[0],Color_x[1]));
    }
    print("Saving vehicles...");
    new tx = GetTickCount();
    while(GetTickCount()-tx < 2000){}//give the time to mysql plugin to execute all queries
    print("Loading vehicles...");
    mysql_query(sprintf("SELECT * FROM `vehicles` LIMIT %d",MAX_VEHICLES-1),LOAD_VEHICLES);
    return 1;
}

stock LinkVehicleToInteriorEx(vehicleid,interiorid)
{
    mysql_query(sprintf("update `vehicles` set `interior` = %d WHERE `v_id` = %d",interiorid,Vehicle[vehicleid][VID]));
    Vehicle[vehicleid][InteriorID] = interiorid;
    return LinkVehicleToInterior(vehicleid,interiorid);
}

stock SetVehicleVirtualWorldEx(vehicleid,worldid)
{
    mysql_query(sprintf("update `vehicles` set `world` = %d WHERE `v_id` = %d",worldid,Vehicle[vehicleid][VID]));
    Vehicle[vehicleid][VirtualWorld] = worldid;
    return SetVehicleVirtualWorld(vehicleid,worldid);
}

stock ChangeVehicleColorEx(vehicleid,color1,color2)
{
    Vehicle[vehicleid][Color1] = color1;
    Vehicle[vehicleid][Color2] = color2;
    mysql_query(sprintf("update `vehicles` set `color_1` = %d,`color_2` = 5d WHERE `v_id` = %d",color1,color2,Vehicle[vehicleid][VID]));
    return ChangeVehicleColor(vehicleid,color1,color2);
}

//#define ChangeVehicleColor ChangeVehicleColorEx
stock ChangeVehiclePaintJobEx(vehicleid,paintjobid)
{
    mysql_query(sprintf("update `vehicles` set `paintjob` = %d WHERE `v_id` = %d",paintjobid,Vehicle[vehicleid][VID]));
    Vehicle[vehicleid][PaintJobID] = paintjobid;
    return ChangeVehiclePaintJob(vehicleid,paintjobid);
}

stock CreateVehicleEx(vehicletype,Float:x,Float:y,Float:z,Float:rotation,color1,color2,respawn_delay=999999999,_OwnerType=0,_PaintJobID=0,const _Owner[]="SERVER",Float:_fuel=100.0,_Price=0,_InteriorID=0,_VirtualWorld=0)
{
    RecieverID = CreateVehicle(vehicletype,x,y,z,rotation,color1,color2,respawn_delay);
    Vehicle[RecieverID][V_Size] = ReturnVehicleSize(vehicletype);
    mysql_function_query(1,
        sprintf("INSERT INTO `vehicles` (model_id,spawnx,spawny,spawnz,angle,color_1,color_2,owner_type,paintjob,owner,fuel,price,interior,world) VALUES (%d,%f,%f,%f,%f,%d,%d,%d,%d,'%s',%f,%d,%d,%d)",vehicletype,x,y,z,rotation,color1,color2,_OwnerType,_PaintJobID,_Owner,_fuel,_Price,_InteriorID,_VirtualWorld),
        false,"CreateNewMYSQLVehicle", "iiffffiiiisfiii",RecieverID,vehicletype,x,y,z,rotation,color1,color2,_OwnerType,_PaintJobID,_Owner,_fuel,_Price,_InteriorID,_VirtualWorld);
    return RecieverID;
}

stock DestroyVehicleEx(vehicleid)
{
    Vehicle[vehicleid][VID] = (-1);
    return DestroyVehicle(vehicleid);
}
#define DestroyVehicle DestroyVehicleEx

stock RemoveVehicleFromServer(vehicleid = -1,const _Owner[] = "",bool:CaseInsensetive=true)
{
    if(vehicleid != (-1))
    {
        mysql_query(sprintf("DELETE FROM `vehicles` WHERE `v_id` = %d",Vehicle[vehicleid][VID]));
        DestroyVehicle(vehicleid);
    }
    else
    {
        for(new i = 0; i < MAX_VEHICLES; ++i)
        {
            if(Vehicle[vehicleid][VID] == (-1))continue;
            if(!strcmp(Vehicle[i][Owner],_Owner,CaseInsensetive))
            {
                DestroyVehicle(i);
            }
        }
        mysql_function_query(1,sprintf("DELETE FROM `vehicles` WHERE `owner` = '%s'",_Owner));
    }
    return 1;
}

//forward SaveCarComponents(vehicleid);
stock SaveCarComponents(vehicleid)
{
    Vehicle[vehicleid][Components][0]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_SPOILER);
    Vehicle[vehicleid][Components][1]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_HOOD);
    Vehicle[vehicleid][Components][2]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_ROOF);
    Vehicle[vehicleid][Components][3]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_SIDESKIRT);
    Vehicle[vehicleid][Components][4]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_LAMPS);
    Vehicle[vehicleid][Components][5]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_NITRO);
    Vehicle[vehicleid][Components][6]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_EXHAUST);
    Vehicle[vehicleid][Components][7]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_WHEELS);
    Vehicle[vehicleid][Components][8]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_STEREO);
    Vehicle[vehicleid][Components][9]  = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_HYDRAULICS);
    Vehicle[vehicleid][Components][10] = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_FRONT_BUMPER);
    Vehicle[vehicleid][Components][11] = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_REAR_BUMPER);
    Vehicle[vehicleid][Components][12] = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_VENT_RIGHT);
    Vehicle[vehicleid][Components][13] = GetVehicleComponentInSlot( vehicleid,      CARMODTYPE_VENT_LEFT);
    mysql_query(
        sprintf("update `vehicles` set spoiler = %d, hood = %d, roof = %d, sideskirt = %d, lamps = %d, nitro = %d, exhaust = %d, wheels = %d, stereo = %d, hydraulics = %d, frontbumper = %d, rearbumper = %d, ventright = %d, ventleft = %d, paintjob WHERE `v_id` = %d",Vehicle[vehicleid][Components][0],Vehicle[vehicleid][Components][1],Vehicle[vehicleid][Components][2],Vehicle[vehicleid][Components][3],Vehicle[vehicleid][Components][4],Vehicle[vehicleid][Components][5],Vehicle[vehicleid][Components][6],Vehicle[vehicleid][Components][7],Vehicle[vehicleid][Components][8],Vehicle[vehicleid][Components][9],Vehicle[vehicleid][Components][10],Vehicle[vehicleid][Components][11],Vehicle[vehicleid][Components][12],Vehicle[vehicleid][Components][13],GetVehiclePaintJob(vehicleid),Vehicle[vehicleid][VID]
    );

    return 1;
}

stock LoadCarComponents(vehicleid)
{
    for(new i; i < 14;i++){
        if(Vehicle[vehicleid][Components][i] >= 0){
            AddVehicleComponent(vehicleid,Vehicle[vehicleid][Components][i]);
        }
    }
    return 1;
}

forward bool:IsTypePlane(vehicletype);
stock bool:IsTypePlane(vehicletype)
{
    switch(vehicletype)
    {
        case 460,476,511,512,513,519,520,553,577,592,593:
        {
            return true;
        }
    }
    return false;
}

forward bool:IsTypeHeli(vehicletype);
stock bool:IsTypeHeli(vehicletype)
{
    switch(vehicletype)
    {
        case 417,425,447,469,487,488,497,548,563:
        {
            return true;
        }
    }
    return false;
}

forward bool:IsTypeTruck(vehicletype);
stock bool:IsTypeTruck(vehicletype)
{
    switch(vehicletype)
    {
        case 403,514,515:
        {
            return true;
        }
    }
    return false;
}

forward bool:IsTypeBoat(vehicletype);
stock bool:IsTypeBoat(vehicletype)
{
    switch(vehicletype)
    {
        case 430,446,452,453,454,472,473,484,493:
        {
            return true;
        }
    }
    return false;
}

stock CreateNormalVehicle(vehicletype,Float:x,Float:y,Float:z,Float:rotation,color1,color2,respawn_delay)
{
    new vehicleid = CreateVehicle(vehicletype,x,y,z,rotation,color1,color2,respawn_delay);
    Vehicle[vehicleid][V_Size] = ReturnVehicleSize(vehicletype);
    Vehicle[vehicleid][OwnerType]=0;
    Vehicle[vehicleid][LabelID] = Text3D:(-1);
    Vehicle[vehicleid][ModelID]=vehicletype;
    Vehicle[vehicleid][Color1]=color1;
    Vehicle[vehicleid][Color2]=color2;
    Vehicle[vehicleid][PaintJobID]=0;
    format(Vehicle[vehicleid][Owner],32,"SERVER");
    Vehicle[vehicleid][Spawn][0]=x;
    Vehicle[vehicleid][Spawn][1]=y;
    Vehicle[vehicleid][Spawn][2]=z;
    Vehicle[vehicleid][Angle]=rotation;
    Vehicle[vehicleid][Fuel]=100.0;
    Vehicle[vehicleid][Price]=0;
    Vehicle[vehicleid][InteriorID]=0;
    Vehicle[vehicleid][VirtualWorld]=0;

    Vehicle[vehicleid][IsTrailer]   = IsTypeTrailer(vehicletype);
    Vehicle[vehicleid][IsPlane]     = IsTypePlane(vehicletype);
    Vehicle[vehicleid][IsHeli]      = IsTypeHeli(vehicletype);
    Vehicle[vehicleid][IsTruck]     = IsTypeTruck(vehicletype);
    Vehicle[vehicleid][IsBoat]      = IsTypeBoat(vehicletype);

    return vehicleid;
}

public OnVehicleSpawn(vehicleid)
{
    LoadCarComponents(vehicleid);
    return 1;
}

forward CreateNewMYSQLVehicle(vehicleid,vehicletype,Float:x,Float:y,Float:z,Float:rotation,color1,color2,_OwnerType,_PaintJobID,_Owner[],Float:_fuel,_Price,_InteriorID,_VirtualWorld);
public CreateNewMYSQLVehicle(vehicleid,vehicletype,Float:x,Float:y,Float:z,Float:rotation,color1,color2,_OwnerType,_PaintJobID,_Owner[],Float:_fuel,_Price,_InteriorID,_VirtualWorld)
{
    Vehicle[vehicleid][VID] = mysql_insert_id();
    Vehicle[vehicleid][OwnerType]=_OwnerType;
    //if(Vehicle[vehicleid][OwnerType] != 0)
    //{
    //    Vehicle[vehicleid][LabelID] = Create3DTextLabel(sprintf("%s\nOwner: %s",aVehicleNames[vehicletype-400],_Owner), 0x008080FF, 0.0, 0.0, 0.0, 35.0, 0, 0);
    //    Attach3DTextLabelToVehicle(Vehicle[vehicleid][LabelID],vehicleid,0.0,0.0,0.0);
    //}
    //else
    //{
    //SetPVarInt(vehicleid,"3DLABEL",_:Create3DTextLabel("Blablabla", 0x008080FF, 0.0, 0.0, 0.0, 35.0, 0, 0));
    //Delete3DTextLabel(Text3D:GetPVarInt(vehicleid,"3DLABEL"));
    Vehicle[vehicleid][LabelID] = Text3D:(-1);
    //}
    Vehicle[vehicleid][ModelID]=vehicletype;
    Vehicle[vehicleid][Color1]=color1;
    Vehicle[vehicleid][Color2]=color2;
    Vehicle[vehicleid][PaintJobID]=_PaintJobID;
    Vehicle[vehicleid][Owner]=GlobalString32;
    Vehicle[vehicleid][Spawn][0]=x;
    Vehicle[vehicleid][Spawn][1]=y;
    Vehicle[vehicleid][Spawn][2]=z;
    Vehicle[vehicleid][Angle]=rotation;
    Vehicle[vehicleid][Fuel]=_fuel;
    Vehicle[vehicleid][Price]=_Price;
    Vehicle[vehicleid][InteriorID]=_InteriorID;
    Vehicle[vehicleid][VirtualWorld]=_VirtualWorld;

    Vehicle[vehicleid][IsTrailer] = IsTypeTrailer(vehicletype);
    Vehicle[vehicleid][IsPlane] = IsTypePlane(vehicletype);
    Vehicle[vehicleid][IsHeli] = IsTypeHeli(vehicletype);
    Vehicle[vehicleid][IsTruck] = IsTypeTruck(vehicletype);
    Vehicle[vehicleid][IsBoat] = IsTypeBoat(vehicletype);

    return 1;
}

forward bool:IsTypeTrailer(vehicletype);
stock bool:IsTypeTrailer(vehicletype)
{
    switch(vehicletype)
    {
        case 435,450,584,591:
        {
            return true;
        }
    }
    return false;
}

stock GetTrailerType(vehicletype)
{
    switch(vehicletype)
    {
        case 435:return 0;//food trailer
        case 450:return 1;//Trailer with coal,grind,sand
        case 584:return 2;//petrol trailer
        case 591:return 3;//Anything trailer
    }
    return -1;
}
If you need anything explained from this code just ask. It's a bit messy in the OnqueryFinish part, but hey it works, and does only get executed at ongamemodeinit so no need for superb performance there.

Here is the vehicle table structure/put in ongamemodeinit:
pawn Код:
mysql_query("CREATE TABLE IF NOT EXISTS `vehicles` (`v_id` int(11) NOT NULL auto_increment,PRIMARY KEY  (`v_id`))");
    mysql_query("ALTER TABLE `vehicles` ADD `owner_type`    int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `model_id`      int(11) NOT NULL");
    mysql_query("ALTER TABLE `vehicles` ADD `tmp_vehice_id` int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `color_1`       int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `color_2`       int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `paintjob`      int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `owner`         VARCHAR(32) NOT NULL default 'SERVER'");
    mysql_query("ALTER TABLE `vehicles` ADD `spawnx`        FLOAT(35,25) NOT NULL");
    mysql_query("ALTER TABLE `vehicles` ADD `spawny`        FLOAT(35,25) NOT NULL");
    mysql_query("ALTER TABLE `vehicles` ADD `spawnz`        FLOAT(35,25) NOT NULL");
    mysql_query("ALTER TABLE `vehicles` ADD `angle`         FLOAT(35,25) NOT NULL");
    mysql_query("ALTER TABLE `vehicles` ADD `fuel`          FLOAT(35,25) NOT NULL default 100.00");
    mysql_query("ALTER TABLE `vehicles` ADD `price`         int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `interior`          int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `world`         int(11) NOT NULL default 0");

    mysql_query("ALTER TABLE `vehicles` ADD `spoiler`           int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `hood`          int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `roof`          int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `sideskirt`         int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `lamps`         int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `nitro`         int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `exhaust`           int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `wheels`            int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `stereo`            int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `hydraulics`            int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `frontbumper`           int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `rearbumper`            int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `ventright`         int(11) NOT NULL default 0");
    mysql_query("ALTER TABLE `vehicles` ADD `ventleft`          int(11) NOT NULL default 0");

mysql_query(sprintf("SELECT * FROM `vehicles`  LIMIT %d",MAX_VEHICLES-1 ),LOAD_VEHICLES );
ofcourse I use MySQL R7 plugin, the stock I have for mysql query is:
pawn Код:
stock mysql_query(query[],resultid = (-1),extraid = (-1),connectionHandle = 1)
{
    return mysql_function_query(connectionHandle,query,false,"OnQueryFinish", "siii",query,resultid,extraid,connectionHandle);
}
Please note that some variables like GlobalString256 and RecieverID are global vriables, shouldn't be hard to identify them yourselves.

Don't just copy & paste, you need to undestand what you're doing, else you will have big (unsolvable) problems!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)