Creating vehicles
#1

Hello people, I want to ask for help. I need help in creating vehicles.
Here is my script:

Код:
stock CreateVehicleForPlayer(model, owner[], Float: x, Float: y, Float: z, Float:a)
{
	new query[512], vehicleid;
	format(query, sizeof(query), "INSERT INTO Vehicles (Owner, CarX, CarY, CarZ, CarA, Model, Color1, Color2, Faction, Plate, Paintjob, Locked, Sell) VALUES ('%s', '%f', '%f', '%f', '%f', '%d', '-1', '-1', '-1', 'NOTREG', '-1', '1', '0')", owner, x, y, z, a, model);
	mysql_query(query);
	mysql_free_result();
	vInfo[vehicleid][Model] = model;
	myStrcpy(vInfo[vehicleid][Owner], owner);
	myStrcpy(vInfo[vehicleid][Plate], "NOTREG");
	vInfo[vehicleid][vColor1] = -1;
	vInfo[vehicleid][vColor2] = -1;
	vInfo[vehicleid][Paintjob] = -1;
	vInfo[vehicleid][Locked] = 1;
	vInfo[vehicleid][Faction] = -1;
	vInfo[vehicleid][vPosX] = x;
	vInfo[vehicleid][vPosY] = y;
	vInfo[vehicleid][vPosZ] = z;
	vInfo[vehicleid][vPosA] = a;
	CreateVehicle(vInfo[vehicleid][Model], vInfo[vehicleid][vPosX], vInfo[vehicleid][vPosY], vInfo[vehicleid][vPosZ], vInfo[vehicleid][vPosA], vInfo[vehicleid][vColor1], vInfo[vehicleid][vColor2], -1);
	SetVehicleNumberPlate(vehicleid, vInfo[vehicleid][Plate]);
 	SetVehicleToRespawn(vehicleid);
	return 1;
}
You can see vehicleid in every brackets. How I should define the vehicleid here?
Reply
#2

You should create the vehicle first and the vehicleid CreateVehicle function returns is the one you should use in the vInfo array.
Reply
#3

pawn Код:
stock CreateVehicleForPlayer(model, owner[], Float: x, Float: y, Float: z, Float:a)
{
    new query[512], vehicleid;
    format(query, sizeof(query), "INSERT INTO Vehicles (Owner, CarX, CarY, CarZ, CarA, Model, Color1, Color2, Faction, Plate, Paintjob, Locked, Sell) VALUES ('%s', '%f', '%f', '%f', '%f', '%d', '-1', '-1', '-1', 'NOTREG', '-1', '1', '0')", owner, x, y, z, a, model);
    mysql_query(query);
    mysql_free_result();
    vehicleid = CreateVehicle(model, x, y, z, a, -1, -1, -1);
    vInfo[vehicleid][Model] = model;
    myStrcpy(vInfo[vehicleid][Owner], owner);
    myStrcpy(vInfo[vehicleid][Plate], "NOTREG");
    vInfo[vehicleid][vColor1] = -1;
    vInfo[vehicleid][vColor2] = -1;
    vInfo[vehicleid][Paintjob] = -1;
    vInfo[vehicleid][Locked] = 1;
    vInfo[vehicleid][Faction] = -1;
    vInfo[vehicleid][vPosX] = x;
    vInfo[vehicleid][vPosY] = y;
    vInfo[vehicleid][vPosZ] = z;
    vInfo[vehicleid][vPosA] = a;
    SetVehicleNumberPlate(vehicleid, vInfo[vehicleid][Plate]);
    SetVehicleToRespawn(vehicleid);
    return 1;
}
Should work.
Reply
#4

Eh.. how I could forget that Thanks a lot
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)