KeyPressed doesnt work..
#1

pawn Код:
if(PRESSED(KEY_CROUCH))
    {
        if(IsPublicService(GetPlayerVehicleID(playerid)) && GetPlayerVehicleSeat(playerid) == 0)
        {
            switch(GetPVarInt(playerid, "CopFlash"))
            {
                case 0:

                {
                    KillTimer(BlinkTime[playerid]);
                    BlinkTime[playerid] = SetTimerEx("vBlinker", PFLASH_RATE, 1, "i", playerid);
                    SetPVarInt(playerid, "CopFlash", 1);

                }
                case 1:

                {
                    KillTimer(BlinkTime[playerid]);
                    new panels, doors, lights, tires;
                    new carid = GetPlayerVehicleID(playerid);
                    GetVehicleDamageStatus(carid, panels, doors, lights, tires);
                    lights = encode_lights(1, 1, 1, 1);
                    UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
                    SetPVarInt(playerid, "CopFlash", 0);

                }

            }

        }

    }

    if(PRESSED(KEY_LOOK_LEFT))
    {
        if(GetPlayerVehicleSeat(playerid) == 0)
        {
            if(GetPVarInt(playerid, "vBLeft") == 0)
            {
                KillTimer(BlinkTime[playerid]);
                BlinkTime[playerid] = SetTimerEx("vBlinker", BLINK_RATE, 1, "i", playerid);
                SetPVarInt(playerid, "vBLeft", 1);
                SetPVarInt(playerid, "vBRight", 0);

            }
            else
            {
                KillTimer(BlinkTime[playerid]);
                new panels, doors, lights, tires;
                new carid = GetPlayerVehicleID(playerid);
                GetVehicleDamageStatus(carid, panels, doors, lights, tires);
                switch(GetPVarInt(playerid, "vMainOn"))
                {
                    case 0:

                    {
                        lights = encode_lights(1, 1, 1, 1);

                    }
                    case 1:

                    {
                        lights = encode_lights(0, 0, 0, 0);

                    }

                }
                UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
                SetPVarInt(playerid, "vBLeft", 0);

            }

        }

    }

    if(PRESSED(KEY_LOOK_RIGHT))
    {
        if(GetPlayerVehicleSeat(playerid) == 0)
        {
            if(GetPVarInt(playerid, "vBRight") == 0)
            {
                KillTimer(BlinkTime[playerid]);
                BlinkTime[playerid] = SetTimerEx("vBlinker", BLINK_RATE, 1, "i", playerid);
                SetPVarInt(playerid, "vBRight", 1);
                SetPVarInt(playerid, "vBLeft", 0);

            }
            else
            {
                KillTimer(BlinkTime[playerid]);
                new panels, doors, lights, tires;
                new carid = GetPlayerVehicleID(playerid);
                GetVehicleDamageStatus(carid, panels, doors, lights, tires);
                switch(GetPVarInt(playerid, "vMainOn"))
                {
                    case 0:

                    {
                        lights = encode_lights(1, 1, 1, 1);

                    }
                    case 1:

                    {
                        lights = encode_lights(0, 0, 0, 0);

                    }

                }
                UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
                SetPVarInt(playerid, "vBRight", 0);


            }

        }

        return 1;

    }
It doesnt sem to work, can some check if it scripted right?
Reply
#2

Hi riddy, add some prints to your code to see where it messes up. People wont be able to check your code because we don't have all your vars/functions. The code you posted looks OK.

Post your IsPublicService func too i have a feeling it might be expecting a modelid and not vehicleid. Though obviosly i can't be sure of that.
Reply
#3

pawn Код:
IsPublicService(carid)
{
    new PS[11] = { 416, 427, 490, 528, 407, 544, 596, 598, 597, 599, 601 };
    for(new i = 0; i < sizeof(PS); i++)
    {
        if(GetVehicleModel(carid) == PS[i]) return 1;
    }
    return 0;
}
Reply
#4

well??... 1 day, 3 hours bump
Reply
#5

you use it in public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)?
Reply
#6

Quote:
Originally Posted by damiantof71
Посмотреть сообщение
you use it in public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)?
Yes, I do.
Reply
#7

10 days bump.
Reply
#8

Use this and see what messages you get

pawn Код:
if(PRESSED(KEY_CROUCH))
    {
        SendClientMessage(playerid, -1, "PRESSED(KEY_CROUCH)");
        if(IsPublicService(GetPlayerVehicleID(playerid)) && GetPlayerVehicleSeat(playerid) == 0)
        {
            SendClientMessage(playerid, -1, "IsPublicService");
            switch(GetPVarInt(playerid, "CopFlash"))
            {
                case 0:
                {
                    SendClientMessage(playerid, -1, "CopFlash 0");
                    KillTimer(BlinkTime[playerid]);
                    BlinkTime[playerid] = SetTimerEx("vBlinker", PFLASH_RATE, 1, "i", playerid);
                    SetPVarInt(playerid, "CopFlash", 1);
                }
                case 1:
                {
                    SendClientMessage(playerid, -1, "CopFlash 1");
                    KillTimer(BlinkTime[playerid]);
                    new panels, doors, lights, tires;
                    new carid = GetPlayerVehicleID(playerid);
                    GetVehicleDamageStatus(carid, panels, doors, lights, tires);
                    lights = encode_lights(1, 1, 1, 1);
                    UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
                    SetPVarInt(playerid, "CopFlash", 0);
                }
            }
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)