29.04.2012, 17:12
(
Last edited by Faisal_khan; 01/05/2012 at 08:43 AM.
)
Police Car Mine System V 1.0
Hi SA-MP Community,This is my third Filterscript. Hope you like it. So as the title says, Police Car Mine System, it is a FS for the police to drop a mine on the road. And if a vehicle steps on it except the police car, the mine will blow off! KABOOM!
Lets go for the explanation:
To drop a mine, a player must press Y key. Here is the code for it:
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys == KEY_YES)
{
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid);
if (IsPlayerInAnyVehicle(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) != 597)
{
return 1;
}
else
{
new Float:plocx,Float:plocy,Float:plocz;
GetVehiclePos(vehicleid, plocx, plocy, plocz);
CreateMine(plocx,plocy,plocz);
}
}
return 1;
}
pawn Code:
new Float:plocx,Float:plocy,Float:plocz;
GetVehiclePos(vehicleid, plocx, plocy, plocz);
CreateMine(plocx,plocy,plocz);
pawn Code:
public OnPlayerUpdate(playerid)
{
if(!IsPlayerConnected(playerid)) return 0;
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i = 0; i < sizeof(MineInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 1, MineInfo[i][mX], MineInfo[i][mY], MineInfo[i][mZ]))
{
if(MineInfo[i][mCreated])
{
if (IsPlayerInAnyVehicle(playerid) && GetVehicleModel(GetPlayerVehicleID(playerid)) == 597)
{
return 1;
}
else
{
CreateExplosion(MineInfo[i][mX], MineInfo[i][mY], MineInfo[i][mZ], 7, 20.0);
DestroyObject(MineInfo[i][mObject]);
}
return 0;
}
}
}
}
return 1;
}
pawn Code:
stock CreateMine(Float:x,Float:y,Float:z)
{
for(new i = 0; i < sizeof(MineInfo); i++)
{
if(MineInfo[i][mCreated] == 0)
{
MineInfo[i][mCreated]=1;
MineInfo[i][mX]=x;
MineInfo[i][mY]=y;
MineInfo[i][mZ]=z-0.7;
MineInfo[i][mObject] = CreateObject(364, x, y, z, 0, 0, 0);
return 1;
}
}
return 0;
}
Screenshots





This object (i.e. a detonator is our mine)






This object (i.e. a detonator is our mine)

Credits
Faisal_khan for scripting.
Soon gonna release v2.0 for this with new features.
Pastebin