PDA

View Full Version : Vehicles are Respawning or Destroying when drive


Varg
28/07/2018, 12:07 PM
Sorry for my bad English,

My problem is;

Vehicles respawning or destroying i dont know, when im driving a car. It is being in 1-2 min. And vehicles ids not same in MySQL. I can get again car with /spawncar cmd. How i can delete despawncar/spawncar and how fix that problem. I can upload video, if u dont understand.

this video;

https://www.youtube.com/watch?v=nWnw5Vb8qg0&feature=youtu.be

Libbyphay
28/07/2018, 12:16 PM
http://wiki.sa-mp.com/wiki/CreateVehicle

CreateVehicle(vehicletype, Float:x, Float:y, Float:z, Float:rotation, color1, color2, respawn_delay, addsiren=0)

Example if you want no respawn car:

CreateVehicle(411, 2109.1763, 1503.0453, 32.2887, 82.2873, 1, 1, -1)

Varg
28/07/2018, 12:25 PM
@Libbyphay

I did try respawndelay -1 but didnt change anything. Everytime when im driving car, that car is respawning or destroying. This script using StaticVehicleEx i can show you veh codes;

CMD:veh(playerid, params[])
{
new model[20], modelid, color1, color2, Float:x, Float:y, Float:z, Float:a, vehicleid;

if(PlayerInfo[playerid][pAdmin] < 3)
{
return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
}
if(!PlayerInfo[playerid][pAdminDuty] && PlayerInfo[playerid][pAdmin] < 6)
{
return SendClientMessage(playerid, COLOR_GREY, "This command requires you to be on admin duty. /aduty to go on duty.");
}
if(sscanf(params, "s[20]I(-1)I(-1)", model, color1, color2))
{
return SendClientMessage(playerid, COLOR_GREY3, "[Usage]: /veh [modelid/name] [color1 (optional)] [color2 (optional)]");
}
if((modelid = GetVehicleModelByName(model)) == 0)
{
return SendClientMessage(playerid, COLOR_GREY, "Invalid vehicle model.");
}
if(!(-1 <= color1 <= 255) || !(-1 <= color2 <= 255))
{
return SendClientMessage(playerid, COLOR_GREY, "Invalid color. Valid colors range from -1 to 255.");
}

GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);

vehicleid = AddStaticVehicleEx(modelid, x, y, z, a, color1, color2, -1);

if(vehicleid == INVALID_PLAYER_ID)
{
return SendClientMessage(playerid, COLOR_GREY, "Cannot spawn vehicle. The vehicle pool is currently full.");
}

adminVehicle{vehicleid} = true;
vehicleFuel[vehicleid] = 100;
vehicleColors[vehicleid][0] = color1;
vehicleColors[vehicleid][1] = color2;

SetVehicleVirtualWorld(vehicleid, GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(vehicleid, GetPlayerInterior(playerid));

PutPlayerInVehicle(playerid, vehicleid, 0);
SendAdminMessage(COLOR_LIGHTRED, "AdmCmd: %s spawned a %s.", GetPlayerRPName(playerid), GetVehicleName(vehicleid));
SendClientMessageEx(playerid, COLOR_WHITE, "** %s (ID %i) spawned. Use '/savevehicle %i' to save this vehicle to the database.", GetVehicleName(vehicleid), vehicleid, vehicleid);
return 1;
}

CMD:savevehicle(playerid, params[])
{
new vehicleid, gangid, type, delay, Float:x, Float:y, Float:z, Float:a;

if(PlayerInfo[playerid][pAdmin] < 3)
{
return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
}
if(sscanf(params, "iiii", vehicleid, gangid, type, delay))
{
SendClientMessage(playerid, COLOR_GREY3, "[Usage]: /savevehicle [vehicleid] [gangid (-1 = none)] [faction type] [respawn delay (seconds)]");
SendClientMessage(playerid, COLOR_GREY3, "List of types: (0) None (1) Police (2) Medic (3) News (4) Government (5) Hitman (6) Federal");
return 1;
}
if(!IsValidVehicle(vehicleid) || !adminVehicle{vehicleid})
{
return SendClientMessage(playerid, COLOR_GREY, "The vehicle specified is either invalid or not an admin spawned vehicle.");
}
if(!(-1 <= gangid < MAX_GANGS) || (gangid >= 0 && !GangInfo[gangid][gSetup]))
{
return SendClientMessage(playerid, COLOR_GREY, "Invalid gang.");
}
if(!(0 <= type <= 7))
{
return SendClientMessage(playerid, COLOR_GREY, "Invalid type.");
}

SendClientMessageEx(playerid, COLOR_WHITE, "** %s saved. This vehicle will now spawn here from now on.", GetVehicleName(vehicleid));

GetVehiclePos(vehicleid, x, y, z);
GetVehicleZAngle(vehicleid, a);

mysql_format(connectionID, queryBuffer, sizeof(queryBuffer), "INSERT INTO vehicles (modelid, pos_x, pos_y, pos_z, pos_a, color1, color2, gangid, factiontype, respawndelay) VALUES(%i, '%f', '%f', '%f', '%f', %i, %i, %i, %i, %i)", GetVehicleModel(vehicleid), x, y, z, a, vehicleColors[vehicleid][0], vehicleColors[vehicleid][1], gangid, type, delay);
mysql_tquery(connectionID, queryBuffer);
mysql_tquery(connectionID, "SELECT * FROM vehicles WHERE id = LAST_INSERT_ID()", "OnQueryFinished", "ii", THREAD_LOAD_VEHICLES, 0);

adminVehicle{vehicleid} = false;
DestroyVehicle(vehicleid);

return 1;
}

Libbyphay
28/07/2018, 12:41 PM
Add vehid before modelid, and change vehid = vehicleid

Varg
28/07/2018, 01:01 PM
https://www.youtube.com/watch?v=nWnw5Vb8qg0&feature=youtu.be

Varg
28/07/2018, 01:58 PM
I did try your say but didnt change. That cars going to when im driving.

Varg
28/07/2018, 09:02 PM
Guys im tilted, how can i fix that problem?

Banditul18
28/07/2018, 09:21 PM
Do you have any kind of timer that respawn/destroy cars? Lets say you want to destroy admin spawned cars from time to time so you use a timer. Do you have any kind of this stuff? I had the same issue when i did such a timer

EzeGODezE
28/07/2018, 09:49 PM
remove destroyvehicle(playerid);

Varg
28/07/2018, 10:51 PM
Do you have any kind of timer that respawn/destroy cars? Lets say you want to destroy admin spawned cars from time to time so you use a timer. Do you have any kind of this stuff? I had the same issue when i did such a timer

Thank you bro i checked it.


remove destroyvehicle(playerid);

Thank you man, fixed with this.

Thanks all ^^