SetVehicleParamsEx Problem with lights
#1

Hey people i have still a weird problem with the function SetVehicleParamsEx and the lights. I have tested now a lot, i also printed the lights, just to know if the params gets changed and well yes they do, just this freaky light won't turn on.

Here the code how i did it right now.

pawn Код:
//by my defines:

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

//^before some starts to ask me if i have it.

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_FIRE))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(pInfo[playerid][LightsOn]==0)
            {
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,1, alarm,doors, bonnet, boot, objective);
                pInfo[playerid][LightsOn]=1;
            }
            else if(pInfo[playerid][LightsOn]==1)
            {
                new engine, lights, alarm, doors, bonnet, boot, objective;
                GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,0, alarm,doors, bonnet, boot, objective);
                pInfo[playerid][LightsOn]=0;
            }
        }
    }
    return 1;
}
When anyone can tell me what i've done wrong would it be really great.

PS: When i press the first time KEY_FIRE when i printed it does it show me -1. Which is really really weird.
Reply
#2

Why is there two lines for the same thing?

you could try this:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_FIRE))
    {
        new vehicleid, engine,lights,alarm,doors,bonnet,boot,objective;
        vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
        if(!IsPlayerInAnyVehicle(playerid))
            return SendClientMessage(playerid, red, "Error: You are not in a vehicle.");
        if(GetPlayerVehicleSeat(playerid) != 0)
            return SendClientMessage(playerid, red, "Error: You are not in the drivers seat.");
        if(lights == 1)
        {
            SetVehicleParamsEx(vehicleid,engine,0,alarm,doors,bonnet,boot,objective);
        }
        else
        {
            SetVehicleParamsEx(vehicleid,engine,1,alarm,doors,bonnet,boot,objective);
        }

    }
    return 1;
}
Compiles without errors for me. Only you gotta add your extra stuff

Ima test it now

EDIT; it works
Reply
#3

Will test it in few and edit my result. Don't worry i know that i have to add my stuff. xD
Reply
#4

Alright
Reply
#5

Nope nothing changed. Still same result.

The lights turns always than on when i exit the vehicle. It's really weird. ;/

And because your question in first reply. Because i use the key fire for clickable textdraws for my register login system and with the variables does i make sure that no msg get showed while i click one. ^^

Anyway tested it without variables and it gave this result what i wrote above.
Reply
#6

What do you want??
Reply
#7

Quote:
Originally Posted by TomatoRage
Посмотреть сообщение
What do you want??
Read the first post than does you know it, wtf are you asking so stupid? I want that i can turn the lights with KEY_FIRE on nothing else and i provided all informations in my first post....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)