CMD:veh(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] >= 4) {
new
iVehicle,
iColors[2];
if(sscanf(params, "iii", iVehicle, iColors[0], iColors[1])) {
SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /veh [model ID] [color 1] [color 2]");
}
else if(!(400 <= iVehicle <= 611)) {
SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid model specified (model IDs start at 400, and end at 611).");
}
else if(IsATrain(iVehicle)) {
SendClientMessageEx(playerid, COLOR_GREY, "Trains cannot be spawned during runtime.");
}
else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid color specified (IDs start at 0, and end at 255).");
}
else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(iIterator >= 49) {
return SendClientMessageEx(playerid, COLOR_GRAD1, "The maximum limit of 50 spawned vehicles has been reached.");
}
else if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {
new
Float: fVehPos[4];
new fVW = GetPlayerVirtualWorld(playerid);
GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
GetPlayerFacingAngle(playerid, fVehPos[3]);
CreatedCars[iIterator] = CreateVehicle(iVehicle, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
VehicleFuel[CreatedCars[iIterator]] = 100.0;
Vehicle_ResetData(CreatedCars[iIterator]);
LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));
SetVehicleVirtualWorld(CreatedCars[iIterator], fVW);
return SendClientMessageEx(playerid, COLOR_GREY, "Vehicle spawned!");
}
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
return 1;
}]
if(listid == AdminCarList)
{
new
iVehicle,
iColors[2];
if(IsATrain(iVehicle)) {
SendClientMessageEx(playerid, COLOR_GREY, "Trains cannot be spawned during runtime.");
}
else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(iIterator >= 49) {
return SendClientMessageEx(playerid, COLOR_GRAD1, "The maximum limit of 50 spawned vehicles has been reached.");
}
else if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {
new
Float: fVehPos[4];
//new iVehicle[MAX_PLAYERS];
print("1");
new fVW = GetPlayerVirtualWorld(playerid);
GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
GetPlayerFacingAngle(playerid, fVehPos[3]);
CreatedCars[iIterator] = CreateVehicle(iVehicle, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
print("2");
VehicleFuel[CreatedCars[iIterator]] = 100.0;
Vehicle_ResetData(CreatedCars[iIterator]);
print("3");
LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));
print("4");
SetVehicleVirtualWorld(CreatedCars[iIterator], fVW);
return SendClientMessage(playerid, 0xFF0000FF, "Admin vehicle spawned");
}
else SendClientMessage(playerid, 0xFF0000FF, "Canceled Admin vehicle selection");
return 1;
}
1. use fVehPosX fVehPosY etc. it is faster than multi dimensional.
2. Can you post the code of Vehicle_ResetData or have you checked the logs with the crashdetect plugin? |
Vehicle_ResetData(iVehicleID) {
if(GetVehicleModel(iVehicleID)) {
for(new cv = 0; cv < 6; cv++)
{
CrateVehicleLoad[iVehicleID][vCrateID][cv] = -1;
}
Vehicle_Armor(iVehicleID);
LockStatus{iVehicleID} = 0;
VehicleStatus{iVehicleID} = 0;
arr_Engine{iVehicleID} = 0;
stationidv[iVehicleID][0] = 0;
TruckContents{iVehicleID} = 0;
TruckDeliveringTo[iVehicleID] = INVALID_BUSINESS_ID;
VehicleFuel[iVehicleID] = 100.0;
if(LockStatus{iVehicleID}) {
foreach(new i: Player)
{
if(PlayerInfo[i][pLockCar] == iVehicleID) {
PlayerInfo[i][pLockCar] = INVALID_VEHICLE_ID;
}
}
}
if(VehicleBomb{iVehicleID} == 1) {
foreach(new i: Player)
{
if(PlacedVehicleBomb[i] == iVehicleID) {
VehicleBomb{iVehicleID} = 0;
PlacedVehicleBomb[i] = INVALID_VEHICLE_ID;
PickUpC4(i);
PlayerInfo[i][pC4Used] = 0;
PlayerInfo[i][pC4Get] = 1;
}
}
}
}
}
else if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) { new Float: fVehPos[4]; //new iVehicle[MAX_PLAYERS]; print("1"); new fVW = GetPlayerVirtualWorld(playerid); GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]); GetPlayerFacingAngle(playerid, fVehPos[3]); CreatedCars[iIterator] = CreateVehicle(iVehicle, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1); print("2"); VehicleFuel[CreatedCars[iIterator]] = 100.0; Vehicle_ResetData(CreatedCars[iIterator]); print("3"); LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid)); print("4"); SetVehicleVirtualWorld(CreatedCars[iIterator], fVW); return SendClientMessage(playerid, 0xFF0000FF, "Admin vehicle spawned"); //Here }
From my silly experince.
Don't return break all incoming values and cancel all perivous action? unless you didn't control it with conditional (if) may i ask you to try it without if it works ? |