bomb command
#1

Hello I'm trying a command, so for start I tried to detect if player is near vehicle but it's not working

everytime I write /bomb it spam me msg "No vehicles near you to plant bomb" even if I'm close to vehicle

pawn Код:
if(strcmp(cmd, "/bomb", true) == 0)
    {
        new Float:X, Float:Y, Float:Z;
        for(new a = 0; a < MAX_VEHICLES; a++)
        {
            GetVehiclePos(a, X, Y, Z);
            if(IsPlayerInRangeOfPoint(a, 4.0, X, Y, Z))
            {
                SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} Bomb planted!");
            }
            else
            {
                SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} No vehicles near you to plant bomb.");
            }
        }
        return 1;
    }
Reply
#2

Try if(IsPlayerInRangeOfPoint(a, 4.0, X+5, Y, Z))
Reply
#3

pawn Код:
if(strcmp(cmd, "/bomb", true) == 0)
    {
     if(GetClosestVehicleForPlayer(playerid) != INVALID_VEHICLE_ID)
     {
                SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} Bomb planted!");
            }
            else
            {
                SendClientMessage(playerid, -1, "{FF6A22}INFO:{FFFFFF} No vehicles near you to plant bomb.");
            }
        }
        return 1;
    }
Reply
#4

pawn Код:
new Float:X, Float:Y, Float:Z, bool: in_range;
for(new a = 1; a < MAX_VEHICLES - 1; a++)
{
    if (!GetVehiclePos(a, X, Y, Z)) continue; // vehicle does not exist
    if (IsPlayerInRangeOfPoint(playerid, 4.0, X, Y, Z))
    {
        in_range = true;
        break;
    }
}
SendClientMessage(playerid, -1, (in_range) ? ("{FF6A22}INFO:{FFFFFF} Bomb planted!") : ("{FF6A22}INFO:{FFFFFF} No vehicles near you to plant bomb."));
Reply
#5

Working, thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)