bomb command - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: bomb command (
/showthread.php?tid=526647)
bomb command -
Lajko1 - 18.07.2014
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;
}
Re: bomb command -
GShock - 18.07.2014
Try if(IsPlayerInRangeOfPoint(a, 4.0, X+5, Y, Z))
Re: bomb command -
Clad - 18.07.2014
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;
}
Re: bomb command -
Konstantinos - 18.07.2014
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."));
Re: bomb command -
Lajko1 - 18.07.2014
Working, thank you.