SA-MP Forums Archive
Respawn a vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Respawn a vehicle (/showthread.php?tid=632202)



Respawn a vehicle - Mencent - 10.04.2017

Hello.

When I respawn my vehicle which has tuning then the tuning is delete.
I respawn it like this:
PHP код:
case DIALOG_RESPAWN_1:
        {
            if(!
response)
            {
                
ShowPlayerDialog(playerid,DIALOG_RESPAWN,DIALOG_STYLE_LIST,!"{ff3737}LSC - CnR:{FFFFFF} Respawn",!"{FFFFFF}1.)\tEinzelnes Fahrzeug respawnen",!"{FFFFFF}Weiter",!"{FFFFFF}Abbrechen");
                return 
1;
            }
            if(!
IsNumeric(inputtext))
            {
                
ShowPlayerDialog(playerid,DIALOG_RESPAWN_1,DIALOG_STYLE_INPUT,!"{ff3737}LSC - CnR:{FFFFFF} Einzelnes Fahrzeug respawnen",!"{FFFFFF}Gib unten bitte die Fahrzeug-ID ein, welche du respawnen mцchtest.",!"{FFFFFF}Weiter",!"{FFFFFF}Zurьck");
                return 
1;
            }
            if(!
IsValidVehicle(strval(inputtext)))
            {
                
ShowPlayerDialog(playerid,DIALOG_RESPAWN_1,DIALOG_STYLE_INPUT,!"{ff3737}LSC - CnR:{FFFFFF} Einzelnes Fahrzeug respawnen",!"{FFFFFF}Gib unten bitte die Fahrzeug-ID ein, welche du respawnen mцchtest.",!"{FFFFFF}Weiter",!"{FFFFFF}Zurьck");
                return 
1;
            }
            new 
string[145];
            
SetVehicleToRespawn(strval(inputtext));
            
format(string,sizeof(string),"AdmCmd: %s %s hat das Fahrzeug %d respawnt!",aRang[Player[playerid][pAdmin]],Player[playerid][pName],strval(inputtext));
            
SendAdminMessage(adminrot,string);
            return 
1;
        } 
I tried to add the tuning after "SendAdminMessage" but it don't work.

How I have to realize that?

EDIT:
Sorry, I did a mistake. Now I realize that like this:
PHP код:
for(new i,j=MAX_VEHICLES;i<j;i++)
            {
                if(
Vehicle[i][vVehID] != strval(inputtext))continue;
                
Vehicle[i][vSpoiler] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_SPOILER);
                
Vehicle[i][vHood] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_HOOD);
                
Vehicle[i][vRoof] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_ROOF);
                
Vehicle[i][vSideSk] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_SIDESKIRT);
                
Vehicle[i][vLamps] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_LAMPS);
                
Vehicle[i][vNitro] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_NITRO);
                
Vehicle[i][vExhaust] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_EXHAUST);
                
Vehicle[i][vWheels] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_WHEELS);
                
Vehicle[i][vStereo] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_STEREO);
                
Vehicle[i][vHydr] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_HYDRAULICS);
                
Vehicle[i][vFrontB] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_FRONT_BUMPER);
                
Vehicle[i][vRearB] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_REAR_BUMPER);
                
Vehicle[i][vVentR] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_VENT_RIGHT);
                
Vehicle[i][vVentL] = GetVehicleComponentInSlot(Vehicle[i][vVehID],CARMODTYPE_VENT_LEFT);
                break;
            }
            new 
string[145];
            
SetVehicleToRespawn(strval(inputtext));
            
format(string,sizeof(string),"AdmCmd: %s %s hat das Fahrzeug %d respawnt!",aRang[Player[playerid][pAdmin]],Player[playerid][pName],strval(inputtext));
            
SendAdminMessage(adminrot,string);
            for(new 
i,j=MAX_VEHICLES;i<j;i++)
            {
                if(
Vehicle[i][vVehID] != strval(inputtext))continue;
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vSpoiler]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vHood]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vRoof]);
                   
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vSideSk]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vLamps]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vNitro]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vExhaust]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vWheels]);
                   
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vStereo]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vHydr]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vFrontB]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vRearB]);
                
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vVentR]);
                   
AddVehicleComponent(Vehicle[i][vVehID],Vehicle[i][vVentL]);
                
ChangeVehicleColor(Vehicle[i][vVehID],Vehicle[i][vFarbe][0],Vehicle[i][vFarbe][1]);
                   return 
1;
            } 
Thanks!