SA-MP Forums Archive
KeyPressed doesnt work.. - 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: KeyPressed doesnt work.. (/showthread.php?tid=366777)



KeyPressed doesnt work.. - Riddy - 07.08.2012

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?


Re: KeyPressed doesnt work.. - iggy1 - 07.08.2012

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.


Re: KeyPressed doesnt work.. - Riddy - 07.08.2012

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;
}



Re: KeyPressed doesnt work.. - Riddy - 08.08.2012

well??... 1 day, 3 hours bump


Re: KeyPressed doesnt work.. - damiantof71 - 09.08.2012

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


Re: KeyPressed doesnt work.. - Riddy - 09.08.2012

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


Re: KeyPressed doesnt work.. - Riddy - 19.08.2012

10 days bump.


Re: KeyPressed doesnt work.. - MadeMan - 19.08.2012

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);
                }
            }
        }