[FilterScript] Code 2 - flashing police lights
#1

Police Code 2 lights (fixed)

This very simple filterscript allows you to drive police vehicles (ID 596, 597, 598 and 599) in a Code 2 situation (only lights flashing, no siren).

The script requires SA:MP 0.3e to work. It is recommended to use the latest Incognito's streamer (2.6.1 or newer) (you can compile with those includes without editing the filterscript itself). It is also working perfectly without an object streamer as well.

Notes
The reason I am not using any command processor is there is only one command, for which strcmp is enough, too.
When you leave your vehicle with lights on, it remains flashing, but other players can get in your car and switch the lights off.
You can use it in your RP/CNR/whatever gamemode, just give me a comment about it. You can also edit it free.

Usage
Compile the script using 0.3e PAWNO, and load the filterscript.
As a driver in a LSPD/LVPD/SFPD/Police Rancher car type /code2 to control the lights.
If you are not the driver, or not in a controllable vehicle, you will be given a warning.

Code
pawn Code:
#define FILTERSCRIPT
#include <a_samp>
#tryinclude <streamer>
#if defined _streamer_included
    #define CObject CreateDynamicObject
    #define AObject AttachDynamicObjectToVehicle
    #define DObject DestroyDynamicObject
    #define VObject IsValidDynamicObject
#else
    #define CObject CreateObject
    #define AObject AttachObjectToVehicle
    #define DObject DestroyObject
    #define VObject IsValidObject
#endif

new obj[MAX_VEHICLES] = { INVALID_OBJECT_ID, ... };

public OnFilterScriptInit()
{
    print("Code 2 lights loaded.");
    return 1;
}

public OnFilterScriptExit()
{
    for (new i = 0; i < MAX_VEHICLES; i++)
    {
        DObject(obj[i]);
    }
    print("Code 2 lights unloaded.");
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    DObject(obj[vehicleid]);
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/code2", cmdtext, true, 6) == 0)
    {
        if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        {
            return SendClientMessage(playerid, -1, "* You are not the driver!");
        }
        new pveh = GetPlayerVehicleID(playerid);
        if (!GetVehicleModel(pveh)) return SendClientMessage(playerid, -1, "* You are not in a vehicle!");
        if (VObject(obj[pveh])) return SendClientMessage(playerid, -1, "* You switched off the lights."), DObject(obj[pveh]);
        switch (GetVehicleModel(pveh))
        {
            case 596:
            {
                obj[pveh] = CObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                AObject(obj[pveh], pveh, 0.000000, -0.379999, 0.889999, 0.000000, 0.000000, 0.000000);
            }
            case 597:
            {
                obj[pveh] = CObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                AObject(obj[pveh], pveh, 0.000000, -0.374999, 0.884999, 0.000000, 0.000000, 0.000000);
            }
            case 598:
            {
                obj[pveh] = CObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                AObject(obj[pveh], pveh, 0.000000, -0.334498, 0.933500, 0.000000, 0.000000, 0.000000);
            }
            case 599:
            {
                obj[pveh] = CObject(19419, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
                AObject(obj[pveh], pveh, 0.000000, 0.039999, 1.153999, 0.000000, 0.000000, 0.000000);
            }
            default:
            {
                return SendClientMessage(playerid, -1, "* You are not in a CODE 2 compatible police vehicle!");
            }
        }
        return SendClientMessage(playerid, -1, "* Lights on, you are now in a CODE 2 run!");
    }
    return 0;
}
Video
[ame]http://www.youtube.com/watch?v=2qNTMZ_Jo4U[/ame]
Reply


Messages In This Thread
Code 2 - flashing police lights - by KoczkaHUN - 16.05.2012, 18:07
Re : Code 2 - flashing police lights - by dydjyz - 16.05.2012, 18:08
Re: Code 2 - flashing police lights - by Shadow_ - 16.05.2012, 18:53
Re: Code 2 - flashing police lights - by Indom - 16.05.2012, 19:20
Re: Code 2 - flashing police lights - by munapea123 - 17.05.2012, 10:41
Re: Code 2 - flashing police lights - by KoczkaHUN - 17.05.2012, 11:55
Re: Code 2 - flashing police lights - by Niko_boy - 17.05.2012, 12:11
Re: Code 2 - flashing police lights - by ilikenuts - 17.05.2012, 12:25
Re: Code 2 - flashing police lights - by KoczkaHUN - 17.05.2012, 13:56
Re: Code 2 - flashing police lights - by $$inSane - 17.05.2012, 14:00
Re: Code 2 - flashing police lights - by KoczkaHUN - 17.05.2012, 15:31
Re: Code 2 - flashing police lights - by miley1 - 17.05.2012, 15:42
Re: Code 2 - flashing police lights - by Sodear - 17.05.2012, 17:56
Re : Code 2 - flashing police lights - by Thunderboy - 18.05.2012, 18:40
Re: Code 2 - flashing police lights - by V415 - 24.05.2012, 03:05
Re: Code 2 - flashing police lights - by Juninho_Oakley - 24.05.2012, 03:12
Re: Code 2 - flashing police lights - by KoczkaHUN - 24.05.2012, 14:25
Re: Code 2 - flashing police lights - by liri.x - 25.05.2012, 17:47
Re: Code 2 - flashing police lights - by rabexann - 22.06.2012, 22:55
Re: Code 2 - flashing police lights - by Jhero - 22.06.2012, 23:23
Re: Code 2 - flashing police lights - by sherlock - 23.06.2012, 15:22
Re: Code 2 - flashing police lights - by KoczkaHUN - 24.06.2012, 17:24
Re: Code 2 - flashing police lights - by n00el - 02.07.2012, 08:37
Re: Code 2 - flashing police lights - by pasha97 - 02.07.2012, 10:27
Re: Code 2 - flashing police lights - by pasha97 - 02.07.2012, 10:33
Re: Code 2 - flashing police lights - by N0FeaR - 23.09.2012, 00:46
Re: Code 2 - flashing police lights - by Eugene. - 23.09.2012, 01:01
Re: Code 2 - flashing police lights - by DaniceMcHarley - 06.09.2013, 10:25
Re: Code 2 - flashing police lights - by KoczkaHUN - 26.01.2014, 08:27

Forum Jump:


Users browsing this thread: 1 Guest(s)