Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). - 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: Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). (
/showthread.php?tid=632448)
Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). -
fatlirmorina - 14.04.2017
Hi,
I have been recently trying to figure out how to disable the drive-by shooting from a vehicle if there is no driver, I kinda made this code but it doesnt work lol. Can somebody help me? Would be appreciated(+rep)...
Код:
new allowed[MAX_PLAYERS]=0;
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
{
PlayerLoop(i)
{
new numri=GetPlayerVehicleID(i);
if(numri == GetPlayerVehicleID(playerid))
{
if(GetPlayerVehicleSeat(i) == 0)
{
allowed[playerid]=1;
}
if(allowed[playerid]==0)
{
return SendClientMessage(playerid, COLOR_LIGHTGREY, "You are not allowed to fire weapons in a vehicle without a driver."), SetPlayerArmedWeapon(playerid, 0);
}
}
}
}
return 1;
}
Re: Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). -
jasperschellekens - 14.04.2017
nvm misreaded
Re: Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). -
LEOTorres - 14.04.2017
Let me know how this works out:
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
new allowed;
if (IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
for (new i = 0; i < MAX_PLAYERS; i++)
{
if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER)
{
allowed = 1;
break;
}
}
if (allowed == 0)
{
SendClientMessage (playerid, -1, "SERVER: You must have a driver to perform a drive-by!");
SetPlayerArmedWeapon(playerid, 0);
}
}
return 1;
}
Re: Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). -
fatlirmorina - 14.04.2017
You sure this won't need a timer?
Re: Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). -
fatlirmorina - 14.04.2017
Thanks it actually works.
Re: Disabling firing weapons from a vehicle if there is no driver (drive-by shooting). -
LEOTorres - 14.04.2017
Quote:
Originally Posted by fatlirmorina
You sure this won't need a timer?
|
Unless you want to check at intervals instead of shooting, no.