13.04.2016, 00:07
Heya there SAMP scripters, I was wondering what's wrong in this code
This is a stretcher system im trying to script, although it detects every vehicle as Ambulance
(Command works even if im not near an ambulance)
Note: I am pretty sure the problem is in the for loop
Thanks in advice
This is a stretcher system im trying to script, although it detects every vehicle as Ambulance
(Command works even if im not near an ambulance)
Note: I am pretty sure the problem is in the for loop
Thanks in advice
PHP Code:
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);