Lights
#1

i need help me a problem it's been buzzing me for years..(months) i cant make it work!a lights sistem!no errors
no warnings just no work i go in game at 1:00am and i press button 2(not numpad)and no work

PHP код:
#include <a_samp>
new boolVehicleLightsOn[MAX_VEHICLES];
new 
enginelightsalarmdoorsbonnetbootobjective;
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if (
newstate == PLAYER_STATE_DRIVER)
    {
        if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == true)
        {
            new 
vehicleid;
            
vehicleid GetPlayerVehicleID(playerid);
            
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
            
SetVehicleParamsEx(vehicleidenginetruealarmdoorsbonnetbootobjective);
            
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
        }
        else
        {
            
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
            
SetVehicleParamsEx(vehicleidenginefalsealarmdoorsbonnetbootobjective);
             
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
        }
    }
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if (
PRESSED(KEY_SUBMISSION))
    {
        if (
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
            {
                
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
                
SetVehicleParamsEx(vehicleidenginetruealarmdoorsbonnetbootobjective);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
            }
            else
            {
                new 
enginelightsalarmdoorsbonnetbootobjective;
                
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
                
SetVehicleParamsEx(vehicleidenginefalsealarmdoorsbonnetbootobjective);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
            }
        }
    }
    return 
1;

PS:in gamemode under ongamemodeinit i have ManualVehicleEngineAndLights();[/quote]

i post it at thread and no oe answer i got it 10 days..
Reply
#2

try changing true to 1
and change false to 0
Reply
#3

Maybe you should get rid of the "PRESSED" define, and use
Код:
newkeys & KEY_SUBMISSION
because your code is saying that only if the key is pressed the lights will turn on. It's messing up somehow. Also, you could be pressing the wrong key. Check your key settings in game.
Reply
#4

np work EDIT:UPDATE VINCENT.no work

PHP код:
#include <a_samp>
new boolVehicleLightsOn[MAX_VEHICLES];
new 
panelsdoorslightstires;
public 
OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
"Lumini Masini");
    print(
"--------------------------------------\n");
    for (new 
1MAX_VEHICLESx++)
    {
        
VehicleLightsOn[x] = ;
    }
    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)] == 1)
        {
            
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
            
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(1111), tires);
               
VehicleLightsOn[GetPlayerVehicleID(playerid)] = 1;
        }
        else
        {
            
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
            
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(0000), tires);
             
VehicleLightsOn[GetPlayerVehicleID(playerid)] = 0;
        }
    }
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_SUBMISSION)
    {
        if (
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == 0)
            {
                
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
                
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(0000), tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = 1;
            }
            else
            {
                
GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorslightstires);
                
UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panelsdoorsencode_lights(1111), tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = 0;
            }
        }
    }
    return 
1;
}
stock encode_lights(light1light2light3light4)
{
    return 
light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);

Reply
#5

BUMP
Reply
#6

anyone know?no hurry but i no one has a light cmd?that can help me?
Reply
#7

Quote:
Originally Posted by Dan_Barocu
Посмотреть сообщение
i need help me a problem it's been buzzing me for years..(months) i cant make it work!a lights sistem!no errors
no warnings just no work i go in game at 1:00am and i press button 2(not numpad)and no work

PHP код:
#include <a_samp>
new boolVehicleLightsOn[MAX_VEHICLES];
new 
enginelightsalarmdoorsbonnetbootobjective;
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if (
newstate == PLAYER_STATE_DRIVER)
    {
        if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == true)
        {
            new 
vehicleid;
            
vehicleid GetPlayerVehicleID(playerid); 
                    
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors0tires);
           
            
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
        }
        else
        {
            
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors5tires);
             
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
        }
    }
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if (
PRESSED(KEY_SUBMISSION))
    {
        if (
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
            {
                 
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors0tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
            }
            else
            {
                new 
enginelightsalarmdoorsbonnetbootobjective;
             
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors5tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
            }
        }
    }
    return 
1;

This should work try it!
You had it all wrong for the lights you need it to edit it tell me if it works [/QUOTE]
Reply
#8

PHP код:
#include <a_samp>
new boolVehicleLightsOn[MAX_VEHICLES];
new 
enginelightsalarmdoorsbonnetbootobjective;
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    if (
newstate == PLAYER_STATE_DRIVER)
    {
        if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == true)
        {
            new 
vehicleid;
            
vehicleid GetPlayerVehicleID(playerid); 
                    
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors0tires);
           
            
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
        }
        else
        {
            
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors5tires);
             
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
        }
    }
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if (
PRESSED(KEY_SUBMISSION))
    {
        if (
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
            {
                 
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors0tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
            }
            else
            {
                new 
enginelightsalarmdoorsbonnetbootobjective;
             
GetVehicleDamageStatus(idcar,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors5tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
            }
        }
    }
    return 
1;

Reposted it so i can be easier!
Reply
#9

i get lots of errors..
Reply
#10

PHP код:
#include <a_samp>
new boolVehicleLightsOn[MAX_VEHICLES];
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public 
OnPlayerStateChange(playeridnewstateoldstate)
{
    new 
enginelightsalarmdoors,panelsbonnetbootobjective;
    if (
newstate == PLAYER_STATE_DRIVER)
    {
        if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == true)
        {
            new 
vehicleid;
            
vehicleid GetPlayerVehicleID(playerid); 
                    
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(vehicleidpanelsdoors0tires);
           
            
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
        }
        else
        {
            
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
             
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
        }
    }
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
vehicleid;
    
vehicleid GetPlayerVehicleID(playerid); 
new 
enginelightsalarmdoors,panelsbonnetbootobjective;
    if (
PRESSED(KEY_SUBMISSION))
    {
        if (
IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (
VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
            {
                 
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(idcarpanelsdoors0tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = true;
            }
            else
            {
                new 
enginelightsalarmdoors,panelsbonnetbootobjective;
             
GetVehicleDamageStatus(vehicleid,panels,doors,lights,tires);
                    
UpdateVehicleDamageStatus(vehicleidpanelsdoors5tires);
                
VehicleLightsOn[GetPlayerVehicleID(playerid)] = false;
            }
        }
    }
    return 
1;

Try now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)