[Tutorial] Making a /tcar cmd to spawn a tuned car.
#1

Hello everyone,today i will be showing you how to make a /tcar command so that rcon admins can spawn a tuned car with nos,rims ect.If you want you can link it to your admin system so all admins can use it,so lets get started.

Make sure you include zcmd at the top of your script,and define the color at the top too.
pawn Код:
#include <zcmd>
#define COLOR_LIGHTBLUE 0x33CCFFFF
First lets make the cmd,the cmd will be /tcar if you want you can change the name of the cmd.
pawn Код:
CMD:tcar(playerid, params[])
{
Now we are going to make it so that only rcon admins can use it.This code will make it for rcon admins only.
If you want anyone to use this cmd do not add this code.
pawn Код:
if(!IsPlayerAdmin(playerid)) return 0;
Now we are going to make the car and add the nos ect.
pawn Код:
new Float:X,Float:Y,Float:Z,Float:Angle,LVehicleIDt;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
LVehicleIDt = CreateVehicle(411,X,Y,Z,Angle,1,-1,-1); //change the 411 to another car id if you want a different car
PutPlayerInVehicle(playerid,LVehicleIDt,0);
AddVehicleComponent(LVehicleIDt, 1028); AddVehicleComponent(LVehicleIDt, 1030); AddVehicleComponent(LVehicleIDt, 1031); AddVehicleComponent(LVehicleIDt, 1138); AddVehicleComponent(LVehicleIDt, 1140); AddVehicleComponent(LVehicleIDt, 1170);
AddVehicleComponent(LVehicleIDt, 1028); AddVehicleComponent(LVehicleIDt, 1030); AddVehicleComponent(LVehicleIDt, 1031); AddVehicleComponent(LVehicleIDt, 1138); AddVehicleComponent(LVehicleIDt, 1140); AddVehicleComponent(LVehicleIDt, 1170);
AddVehicleComponent(LVehicleIDt, 1080); AddVehicleComponent(LVehicleIDt, 1086); AddVehicleComponent(LVehicleIDt, 1087); AddVehicleComponent(LVehicleIDt, 1010);
ChangeVehiclePaintjob(LVehicleIDt,1);
SetVehicleVirtualWorld(LVehicleIDt, GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(LVehicleIDt, GetPlayerInterior(playerid));
return 1;
}
This code spawns the car id so if you want to spawn an infernus you will put infernus car id where it has 411.
411 is the car id,change that id if you want to add a different veh id.
pawn Код:
LVehicleIDt = CreateVehicle(411,X,Y,Z,Angle,1,-1,-1);
We also want to send a message to the admin when he spawns the car so we will add this to the bottom on the code.
pawn Код:
SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have spawned an Infernus (id 411).")
This is how the code will look when its done.
pawn Код:
CMD:tcar(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return 0;
new Float:X,Float:Y,Float:Z,Float:Angle,LVehicleIDt;
GetPlayerPos(playerid,X,Y,Z);
GetPlayerFacingAngle(playerid,Angle);
LVehicleIDt = CreateVehicle(411,X,Y,Z,Angle,1,-1,-1);
PutPlayerInVehicle(playerid,LVehicleIDt,0);
AddVehicleComponent(LVehicleIDt, 1028); AddVehicleComponent(LVehicleIDt, 1030); AddVehicleComponent(LVehicleIDt, 1031); AddVehicleComponent(LVehicleIDt, 1138); AddVehicleComponent(LVehicleIDt, 1140); AddVehicleComponent(LVehicleIDt, 1170);
AddVehicleComponent(LVehicleIDt, 1028); AddVehicleComponent(LVehicleIDt, 1030); AddVehicleComponent(LVehicleIDt, 1031); AddVehicleComponent(LVehicleIDt, 1138); AddVehicleComponent(LVehicleIDt, 1140); AddVehicleComponent(LVehicleIDt, 1170);
AddVehicleComponent(LVehicleIDt, 1080); AddVehicleComponent(LVehicleIDt, 1086); AddVehicleComponent(LVehicleIDt, 1087); AddVehicleComponent(LVehicleIDt, 1010);
ChangeVehiclePaintjob(LVehicleIDt,1);
SetVehicleVirtualWorld(LVehicleIDt, GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(LVehicleIDt, GetPlayerInterior(playerid));
SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have spawned an Infernus (id 411).")
return 1;
}
Well this is the end of this tut,i hope this helped and if you have any problems please comment below.
Thanks-[YrR]Jeremy.
Reply
#2

Good Tutorial!
Reply
#3

Could Have Explained Better.
Reply
#4

Will cause opcodes for some vehicles
Reply
#5

Useful for new scripters like me!
Reply
#6

I will try to explain better in my other tuts,but can you guys please rep thx
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)