new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, A);
for(new i=0; i<MAX_VEHICLES; i++)
{
if(IsPlayerNearVehicle(playerid, i, 2) && IsLSFMDVehicle(i))
{
ambulance++;
if(ContainStretcher[i]) ambstretcher++;
}
}
if(ambulance < 0) return SendClientMessage(playerid, COLOR_GREY, "You are not near any ambulance.");
if(ambstretcher < 0) return SendClientMessage(playerid, COLOR_GREY, "This ambulance doesn't contain any stretcher.");
if(UsingStretcher[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are already using a stretcher.");
UsingStretcher[playerid] = 1;
StretcherObj[playerid] = CreateObject(2146, X, Y, Z, 0, 0, A, 100.0);
MovingStretcher[playerid] = 1;
AttachObjectToPlayer(StretcherObj[playerid], playerid, 0.00, 1.30, -0.50, 0.0, 0.0, 0.0);
format(string, sizeof(string), "* %s opens the back of the ambulance and withdraws a stretcher.", RPN(playerid));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
IsLSFMDVehicle(i)
Can you post your code for this function?:
Code:
IsLSFMDVehicle(i) |
stock IsLSFMDVehicle(vehicleid)
{
for(new i=0; i<21; i++)
{
if(vehicleid == FacInfo[5][fCars][i]) return 1;
}
return 0;
}
FacInfo[5][fCars][0] = CreateVehicle(416,1124.0000000,-1329.1999512,13.5000000,0.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][1] = CreateVehicle(416,1110.5999756,-1328.9000244,13.3999996,0.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][2] = CreateVehicle(416,1097.4000244,-1329.0999756,13.5000000,0.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][3] = CreateVehicle(416,1147.6999512,-1314.0999756,13.8000002,0.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][4] = CreateVehicle(416,1135.4000244,-1340.6999512,13.8999996,0.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][5] = CreateVehicle(416,1147.5999756,-1347.0000000,13.6999998,180.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][6] = CreateVehicle(487,1161.5999756,-1310.0999756,31.7999992,268.0000000,3,1,0); //Maverick
FacInfo[5][fCars][7] = CreateVehicle(487,1162.0999756,-1296.8000488,31.7999992,270.0000000,3,1,0); //Maverick
FacInfo[5][fCars][8] = CreateVehicle(487,1161.4000244,-1322.0999756,31.7999992,268.0000000,3,1,0); //Maverick
FacInfo[5][fCars][9] = CreateVehicle(407,1217.6999512,-1332.8000488,13.8000002,90.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][10] = CreateVehicle(407,1218.0000000,-1341.5999756,13.8000002,90.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][11] = CreateVehicle(407,1218.0000000,-1350.0999756,13.6999998,90.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][12] = CreateVehicle(407,1246.6999512,-1332.5999756,13.8000002,270.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][13] = CreateVehicle(407,1246.8000488,-1341.0999756,13.8000002,270.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][14] = CreateVehicle(407,1247.0000000,-1349.9000244,13.8000002,270.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][15] = CreateVehicle(407,1232.3000488,-1315.8000488,14.3999996,90.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][16] = CreateVehicle(407,1231.3000488,-1360.6999512,14.5000000,270.0000000,3,1,0); //Firetruck
FacInfo[5][fCars][17] = CreateVehicle(416,1178.0000000,-1338.6999512,13.8999996,270.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][18] = CreateVehicle(416,1178.0999756,-1308.5000000,13.8999996,272.0000000,1,3,0); //Ambulance
FacInfo[5][fCars][19] = CreateVehicle(487,1231.4000244,-1334.1999512,27.5000000,90.0000000,3,1,0); //Maverick
FacInfo[5][fCars][20] = CreateVehicle(487,1232.0000000,-1348.8000488,27.5000000,90.0000000,3,1,0); //Maverick
for(new i=0; i<21; i++)
{
ContainStretcher[FacInfo[5][fCars][i]] = 1;
}
FacInfo[5][fCars][20]
FacInfo[fCars][20]
Code:
FacInfo[5][fCars][20] Why not just use: Code:
FacInfo[fCars][20] |
You could create an if statement to check if the Vehicle model is equal to that of an ambulance. You can do this using "getplayervehicleid" with a variable
![]() |
for(new i=0; i<MAX_VEHICLES; i++)
{
if(IsPlayerNearVehicle(playerid, i, 2) && IsLSFMDVehicle(i))
{
ambulance++;
if(ContainStretcher[i]) ambstretcher++;
}
}
if(ambulance < 0) return SendClientMessage(playerid, COLOR_GREY, "You are not near any ambulance.");
new ambulance;
pawn Code:
pawn Code:
|
CMD:stretcher(playerid, params[])
{
new string[128], ambulance, ambstretcher;
if(!IsPlayerLoggedIn(playerid) || PlayerInfo[playerid][pAsshole] == 1) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use this command.");
if(!IsMedic(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
In your "IsLSFMDCar" function try setting the return value to 0 instead of 1.
|
stock IsPlayerNearAmbulance(playerid, Float:range)
{
new Float:X, Float:Y, Float:Z;
for(new i; i<MAX_VEHICLES; i++)
{
GetVehiclePos(i, X, Y, Z);
if(IsPlayerInRangeOfPoint(playerid, range, X, Y, Z) && IsLSFMDVehicle(i) && GetVehicleModel(i) == 416) return i;
}
return 0;
}