SA-MP Forums Archive
Lights Small Problem[rep] - 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: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lights Small Problem[rep] (/showthread.php?tid=319835)



Lights Small Problem[rep] - Dan_Barocu - 20.02.2012

i put this in my fs..and it doesnet work if i press 2.. in game..

PHP код:
THIS IN FS!
#include <a_samp>
new boolVehicleLightsOn[MAX_VEHICLES];
new 
panelsdoorslightstires;
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
"Lumini Masini");
    print(
"--------------------------------------\n");
    for (new 
1MAX_VEHICLESx++)
    {
        
VehicleLightsOn[x] = false;
    }
    return 
1;
}
public 
OnFilterScriptExit()
{
    print(
"\n--------------------------------------");
    print(
" Lumini Masini");
    print(
"--------------------------------------\n");
    return 
1;
}
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if (
newstate == PLAYER_STATE_DRIVER)
    {
        if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
        {
            
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
            
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(1111), tires);
               
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
        }
        else
        {
            
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
            
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(0000), tires);
             
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
        }
    }
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if (
PRESSED(KEY_SUBMISSION))
    {
        if (
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
            {
                
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
                
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(0000), tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
            }
            else
            {
                
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
                
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(1111), tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
            }
        }
    }
    return 
1;
}
stock encode_lights(light1light2light3light4)
{
    return 
light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);

PHP код:
THIS in gm at ongamemodeinit!
ManualVehicleEngineAndLights(); 



Re: Lights Small Problem[rep] - Dan_Barocu - 20.02.2012

anyone help please?


Re: Lights Small Problem[rep] - Guitar - 20.02.2012

I'll try to fix it - Give me some time, I'll go to try to fix it now ^^.

Edit: I've fixed it for you buddy ,

pawn Код:
#include <a_samp>

new bool: VehicleLightsOn[MAX_VEHICLES];
new panels, doors, lights, tires;

#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Lumini Masini");
    print("--------------------------------------\n");
    ManualVehicleEngineAndLights();
    for (new x = 1; x < MAX_VEHICLES; x++)
    {
        VehicleLightsOn[x] = false;
    }
    return 1;
}

public OnFilterScriptExit()
{
    print("\n--------------------------------------");
    print(" Lumini Masini");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (newstate == PLAYER_STATE_DRIVER)
    {
        if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
        {
            GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
            UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(1, 1, 1, 1), tires);
            VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
        }
        else
        {
            GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
            UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(0, 0, 0, 0), tires);
            VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
        }
    }
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_SUBMISSION))
    {
        if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
            {
                GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
                UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(0, 0, 0, 0), tires);
                VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
            }
            else
            {
                GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
                UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, encode_lights(1, 1, 1, 1), tires);
                VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
            }
        }
    }
    return 1;
}

stock encode_lights(light1, light2, light3, light4)
{
    return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);

}
What I actually did is, removes the " This is FS " and put the ManualVehicleEngineAndLights(); under OnFilterScriptInIt. .


Re: Lights Small Problem[rep] - Dan_Barocu - 20.02.2012

do i need to add some more things in gm??


Re: Lights Small Problem[rep] - Guitar - 20.02.2012

I've fixed it for you, check my first reply on this thread .


Re: Lights Small Problem[rep] - Dan_Barocu - 20.02.2012

so when i go in game if i press to rear and front lights go on daytime and nighttime??


Re: Lights Small Problem[rep] - Dan_Barocu - 20.02.2012

dosesnt work i pressed the button 2 like a manic and nothing..do i have to add something besides the fs in my gm??


Re: Lights Small Problem[rep] - Guitar - 20.02.2012

This is a Filterscript you should know how to install it, anyway, go to server.cfg, look for Filterscripts and make sure you compiled the script and put it in Filterscripts folder, now put the name of your current FS beside the line of Filterscripts in server.cfg.


Re: Lights Small Problem[rep] - Dan_Barocu - 20.02.2012

Quote:
Originally Posted by Guitar
Посмотреть сообщение
This is a Filterscript you should know how to install it, anyway, go to server.cfg, look for Filterscripts and make sure you compiled the script and put it in Filterscripts folder, now put the name of your current FS beside the line of Filterscripts in server.cfg.
) this isnt my first fs..did u try it??...i compiled it i go in game and i press button 2 nothing..probably i need to add something in gm..


Re: Lights Small Problem[rep] - Vince - 20.02.2012

Debug it. Also, are you sure you're pressing the actual '2' key and not NUMPAD2 ?