[FilterScript] Police Car Mine System v1.0
#1

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;
}
We created the mine with this:
pawn Code:
new Float:plocx,Float:plocy,Float:plocz;
GetVehiclePos(vehicleid, plocx, plocy, plocz);
CreateMine(plocx,plocy,plocz);
Now when a player steps on mine in an vehicle, he must experience an explosion of type 7. Here is how we did it using OnPlayerUpdate:
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;
}
The CreateMine function is build like this:
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;
}
Hope you got it.

Screenshots











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


Reply


Messages In This Thread
Police Car Mine System v1.0 - by Faisal_khan - 29.04.2012, 17:12
Re : Police Car Mine System v1.0 - by BigBaws - 29.04.2012, 17:26
Re: Re : Police Car Mine System v1.0 - by Faisal_khan - 29.04.2012, 17:34
Re: Police Car Mine System v1.0 - by [Dk]RoCk - 29.04.2012, 17:55
Re: Police Car Mine System v1.0 - by System64 - 29.04.2012, 17:57
Re: Police Car Mine System v1.0 - by sscarface - 29.04.2012, 18:10
Re: Police Car Mine System v1.0 - by Bruno Pereira - 30.04.2012, 02:32
Re: Police Car Mine System v1.0 - by WarriorEd22 - 30.04.2012, 04:47
Re: Police Car Mine System v1.0 - by Faisal_khan - 30.04.2012, 07:27
Re: Police Car Mine System v1.0 - by Faisal_khan - 30.04.2012, 14:50
Re: Police Car Mine System v1.0 - by Phyrunx - 30.04.2012, 14:53
Re: Police Car Mine System v1.0 - by Faisal_khan - 30.04.2012, 15:39
Re: Police Car Mine System v1.0 - by Ballu Miaa - 30.04.2012, 16:44
Re: Police Car Mine System v1.0 - by Logitech90 - 30.04.2012, 19:03
Re: Police Car Mine System v1.0 - by Faisal_khan - 01.05.2012, 08:44
Re: Police Car Mine System v1.0 - by Ballu Miaa - 01.05.2012, 13:26
Re: Police Car Mine System v1.0 - by MichaelProPlayer - 01.05.2012, 13:38
Respuesta: Police Car Mine System v1.0 - by javi - 01.05.2012, 14:49
Re: Respuesta: Police Car Mine System v1.0 - by Faisal_khan - 01.05.2012, 17:11
Re: Police Car Mine System v1.0 - by Arnold_Collins - 01.05.2012, 18:33

Forum Jump:


Users browsing this thread: 1 Guest(s)