/fash command, I dont want a filterscript
#1

I have been coding this new Code for /flash where it places a sliding neon light blue and red above a cruiser. I have that working but i need the lights to change. I have tried to settimer etc, but i have come to no prevail.

Код:
if (strcmp("/flash", cmdtext, true, 6) == 0)
    {
        if (GetPlayerState(playerid) != PLAYER_STATE_DRIVER)
        if(PlayerInfo[playerid][pMember] == Police || PlayerInfo[playerid][pLeader] == Police)
        {
            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 State vehicle");
        if (VObject(obj[pveh])) return format(string, sizeof(string), ">%s reaches over to their dashboard and flicks the code 2 lights off", sendername);
                ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        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 State Vehicle");
            }
        }
        return format(string, sizeof(string), ">%s reaches over to their dashboard and flicks the code 2 lights ON", sendername);
                ProxDetector(10.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
    }
Reply
#2

Hmmmmmmmmmmmmmmmm...
What do you mean by "changing the lights"?
Reply
#3

He meant changing the lights like Flashing Neons just like in Need For Speed Underground 2.

I guess you need SetTimerEx (if using playerid parameters) and create a random function to your own maxium value.

then switch the random.

then delete the old neon and replace it with new one everytime the timer called.

Since i don't know about this flashing neon. I don't think the tip i give will work.
Reply
#4

But this is a siren object, actually.
Reply
#5

use this
pawn Код:
/*
© Stefantjuh97
Mail: S.dorst1997@gmail.com
SAMP Forum name: Stefand.
Release Date: 18-6-2012
Version: 1.0
*/


#include <a_samp>
#include <zcmd>

#define FILTERSCRIPT

forward FlasherFunc();

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

new LightPwr[MAX_VEHICLES];
new Flasher[MAX_VEHICLES];
new FlasherState[MAX_VEHICLES];
new FlashTimer;

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Police Flash lights V1.0");
    print(" By Stefantjuh97");
    print("--------------------------------------\n");

    for (new x=0; x<MAX_VEHICLES; x++)
    {
        LightPwr[x]=1;
        Flasher[x]=0;
        FlasherState[x]=0;
    }

    FlashTimer = SetTimer("FlasherFunc",200,1); // "200" is the speed from the flashing headlights
    return 1;
}

public OnFilterScriptExit()
{
    KillTimer(FlashTimer);
    for (new i = 0; i < MAX_VEHICLES; i++)
    {
        DestroyObject(obj[i]);
        DestroyObject(obj2[i]);
    }
    return 1;
}




public OnVehicleSpawn(vehicleid)
{
    DestroyObject(obj[vehicleid]);
    DestroyObject(obj2[vehicleid]);
    return 1;
}

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

command(flash, playerid, params[])
{
    new vehicleid,panels,doors,lights,tires;
    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 (IsValidObject(obj[pveh]) || IsValidObject(obj2[pveh]))
    {
    SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[pveh]), DestroyObject(obj2[pveh]);
    vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
    if(LightPwr[vehicleid] == 1)
    UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
    else
    UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
    Flasher[vehicleid] = 0;
    }
    switch (GetVehicleModel(pveh))
    {
    case 596:
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
        AttachObjectToVehicle(obj2[pveh], pveh, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 597:
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
        AttachObjectToVehicle(obj2[pveh], pveh, -0.599999,-0.375000,0.899999,0.000000,0.000000,0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 598:
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
        AttachObjectToVehicle(obj2[pveh], pveh, -0.524999, -0.300000, 0.899999, 0.000000, 0.000000, 0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 599:
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        obj2[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
        AttachObjectToVehicle(obj2[pveh], pveh, -0.524999,0.000000,1.125000,0.000000,0.000000,0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 541://bullet
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.375000,0.524999,0.375000,0.000000,0.000000,0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 426://premier
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.524999,0.749999,0.375000,0.000000,0.000000,0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 427://enforcer
    {
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 416://Ambulance
    {
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 407://FireTruck
    {
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 560://sultan
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.225000,0.750000,0.449999,0.000000,0.000000,0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    case 490://FBI
    {
        obj[pveh] = CreateObject(18646, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
        AttachObjectToVehicle(obj[pveh], pveh, 0.000000,1.125000,0.599999,0.000000,0.000000,0.000000);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        Flasher[vehicleid] = 1;
    }
    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!");
}

command(flashoff, playerid, params[])
{
    new vehicleid,panels,doors,lights,tires;
    new pveh = GetPlayerVehicleID(playerid);
    {
        if (IsValidObject(obj[pveh]) || IsValidObject(obj2[pveh]))
        SendClientMessage(playerid, -1, "You switched off the lights."), DestroyObject(obj[pveh]), DestroyObject(obj2[pveh]);
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
        if(LightPwr[vehicleid] == 1)
            UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
            else
            UpdateVehicleDamageStatus(vehicleid, panels, doors, 5, tires);
        Flasher[vehicleid] = 0;
    }
    return 1;
}

public FlasherFunc() {
        new panelsx,doorsx,lightsx,tiresx;
        for (new p=0; p<MAX_VEHICLES; p++)
        {
                if (Flasher[p] == 1)
                {
                        if (FlasherState[p] == 1)
                        {
                                GetVehicleDamageStatus(p,panelsx,doorsx,lightsx,tiresx);
                                UpdateVehicleDamageStatus(p, panelsx, doorsx, 4, tiresx);
                                FlasherState[p] = 0;
                        }
                        else
                        {
                                GetVehicleDamageStatus(p,panelsx,doorsx,lightsx,tiresx);
                                UpdateVehicleDamageStatus(p, panelsx, doorsx, 1, tiresx);
                                FlasherState[p] = 1;
                        }
                }
        }
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)