SA-MP Forums Archive
[FilterScript] Code 2 - flashing police lights - 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] Code 2 - flashing police lights (/showthread.php?tid=343224)

Pages: 1 2


Code 2 - flashing police lights - KoczkaHUN - 16.05.2012

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]


Re : Code 2 - flashing police lights - dydjyz - 16.05.2012

look good.


Re: Code 2 - flashing police lights - Shadow_ - 16.05.2012

Looks really good


Re: Code 2 - flashing police lights - Indom - 16.05.2012

Good job! This is nice.


Re: Code 2 - flashing police lights - munapea123 - 17.05.2012

C:\Users\Boo\Desktop\Samp serv\filterscripts\Code2.pwn(56) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
C:\Users\Boo\Desktop\Samp serv\filterscripts\Code2.pwn(61) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
C:\Users\Boo\Desktop\Samp serv\filterscripts\Code2.pwn(66) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
C:\Users\Boo\Desktop\Samp serv\filterscripts\Code2.pwn(71) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.


Re: Code 2 - flashing police lights - KoczkaHUN - 17.05.2012

Quote:
Originally Posted by KoczkaHUN
View Post
Police Code 2 lights

It is recommended to use the latest Incognito's streamer (you can compile with those includes without editing the filterscript itself).
pawn Code:
native AttachDynamicObjectToVehicle(objectid, vehicleid, Float:offsetx, Float:offsety, Float:offsetz, Float:rx, Float:ry, Float:rz);
added in revision 37
Download it from the homepage of Streamer Plugin (streamer_plugin_v2_6_1_r67.rar)


Re: Code 2 - flashing police lights - Niko_boy - 17.05.2012

Nice work with this simple and cool
lol @!video xD


Re: Code 2 - flashing police lights - ilikenuts - 17.05.2012

Wtf is wrong with the video? It fucked up my eyes.. :O


Re: Code 2 - flashing police lights - KoczkaHUN - 17.05.2012

I don't really know, on my laptop it plays fine. Seems ******* does not like Fraps-made videos by me Sorry for this.

Thanks for all positive comments


Re: Code 2 - flashing police lights - $$inSane - 17.05.2012

Nice


Re: Code 2 - flashing police lights - KoczkaHUN - 17.05.2012

I have just fixed it, because I had found a big bug which prevented it working with Vehicle IDs bigger than maximum players.

If you downloaded it, please redownload.


Re: Code 2 - flashing police lights - miley1 - 17.05.2012

Nice :O


Re: Code 2 - flashing police lights - Sodear - 17.05.2012

Not bad


Re : Code 2 - flashing police lights - Thunderboy - 18.05.2012

Fine

(just edited it to remove SendClientMsg and adding keybind)
Код:
#define FILTERSCRIPT
#include <a_samp>
#include <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_PLAYERS] = { INVALID_OBJECT_ID, ... };

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

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

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

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((oldkeys & KEY_LOOK_RIGHT ) && !(newkeys & KEY_LOOK_RIGHT ))
    {
        if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        {
            //return SendClientMessage(playerid, -1, "Vous n'etes pas le conducteur");
        }
        new pveh = GetPlayerVehicleID(playerid);
        //if (!GetVehicleModel(pveh)) return SendClientMessage(playerid, -1, "Vous n'etes pas dans un vehicule");
        //if (VObject(obj[pveh])) return SendClientMessage(playerid, -1, "Vous eteignez les gyrophares"), 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, "Vous n'etes pas dans un vehicule de police");
            }
        }
        //return SendClientMessage(playerid, -1, "Vous activez les gyrophares silencieux");

    }
    return 0;
}



Re: Code 2 - flashing police lights - V415 - 24.05.2012

One of the bugs we found in our server is that if playera turns it on, it takes the object from playerb.

Anyone else have that problem?


Re: Code 2 - flashing police lights - Juninho_Oakley - 24.05.2012

Goood Job


Re: Code 2 - flashing police lights - KoczkaHUN - 24.05.2012

Quote:
Originally Posted by V415
Посмотреть сообщение
One of the bugs we found in our server is that if playera turns it on, it takes the object from playerb.

Anyone else have that problem?
It should not have such a problem, more objects can be shown simultaneously - as you can see on the video.
You may have a streamer problem.


Re: Code 2 - flashing police lights - liri.x - 25.05.2012

14 errors
Код:
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(274) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(296) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(318) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(340) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(362) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(384) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(406) : error 017: undefined symbol "IsPlayerNPC"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(433) : warning 202: number of arguments does not match definition
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(434) : error 017: undefined symbol "CreatePlayer3DTextLabel"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(436) : error 017: undefined symbol "DeletePlayer3DTextLabel"
C:\Documents and Settings\SinkopaComputers\Desktop\samp03dsvr_R2_win32\pawno\include\streamer.inc(454) : error 017: undefined symbol "UpdatePlayer3DTextLabelText"
C:\Documents and Settings\SinkopaComputers\Desktop\gang wars\filterscripts\police.pwn(56) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
C:\Documents and Settings\SinkopaComputers\Desktop\gang wars\filterscripts\police.pwn(61) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
C:\Documents and Settings\SinkopaComputers\Desktop\gang wars\filterscripts\police.pwn(66) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
C:\Documents and Settings\SinkopaComputers\Desktop\gang wars\filterscripts\police.pwn(71) : error 017: undefined symbol "AttachDynamicObjectToVehicle"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


14 Errors.



Re: Code 2 - flashing police lights - rabexann - 22.06.2012

Used it on all my servers!


Re: Code 2 - flashing police lights - Jhero - 22.06.2012

Niice Job..