SA-MP Forums Archive
Key Question - 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: Key Question (/showthread.php?tid=391939)



Key Question - jakejohnsonusa - 12.11.2012

How can I make my engine system start when I am in my car by pressing Left Shift (jump)? I had it working in my GM, but when I updated the system (edited a few things) in now starts with the down arrow key... I don't know why. It says Key_Jump... Is there somthing I need to add to the script so it works with the actual jump key while in a vehicle?

Please do NOT just give me a link to the key codes, as I've already looked at it.

Thanks,
-jakejohnsonusa


Re: Key Question - Ballu Miaa - 12.11.2012

These keys are set to your keyboard according to the settings you have in your GTA San Andreas game settings.

Check your keyboard controls once! Assign the key you want the player to jump by and start the engine with!


Re: Key Question - jakejohnsonusa - 12.11.2012

I have done this, I set if for left shift... But it's not working. It os working as the down key for myself and others. There must be a problem in the code. Maybe the fact that I'm in a vehicle IDK... But how can I fix?


Re: Key Question - Camorra - 12.11.2012

This is the public - https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Keys of GTA - https://sampwiki.blast.hk/wiki/GetPlayerKeys

You have to remmber, all keys will works as defult setting.
Any help you can feel free to PM me about keys scripting.


Re: Key Question - jakejohnsonusa - 12.11.2012

This is what I mean:

This code works for the jump key (left shift):
pawn Код:
else if(PRESSED(KEY_JUMP))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(IsPlayerConnected(playerid))
            {
                if(!engineOn[GetPlayerVehicleID(playerid)])
                {
                    new idcar = GetPlayerVehicleID(playerid);

                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
                    if(IsARentableCar(idcar))
                    {
                        if(HireCar[playerid] != idcar) return 1;
                    }
                    if(IsAHarvest(idcar)) return 1;
                    if(IsADrugHarvest(idcar)) return 1;
                    if(IsASweeper(idcar)) return 1;

                    if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
                        return SendClientMessage(playerid, COLOR_GREY,"* You cannot turn this car's engine!");

                    new plname[MAX_PLAYER_NAME];
                    GetPlayerName(playerid, plname, sizeof(plname));

                    format(string, sizeof(string), "* %s spins a key and tries to start vehicle engine.", plname);
                    ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                    if(PlayerInfo[playerid][pAdmin] < 1337 && PlayerInfo[playerid][pAdminDuty] == 1)
                    {
                        SetTimerEx("StartingTheVehicle",1,0,"i",playerid);
                    }
                    else
                    {
                        SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
                    }
                    GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
                    gEngine[playerid] = 1;
                    new y, m, d;
                    new h,mi,s;
                    getdate(y,m,d);
                    gettime(h,mi,s);
                    format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,plname);
                    CommandLog(string);
                    return 1;
                }
            }
        }
This code doesn't work with the jump key (left shift), instead it works with the down key:
pawn Код:
else if(PRESSED(KEY_JUMP))
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(IsPlayerConnected(playerid))
            {
                new idcar = GetPlayerVehicleID(playerid);
                if(gEngine[idcar] == 0)
                {
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
                    if(IsARentableCar(idcar))
                    {
                        if(HireCar[playerid] != idcar) return 1;
                    }
                    if(IsAHarvest(idcar)) return 1;
                    if(IsADrugHarvest(idcar)) return 1;
                    if(IsASweeper(idcar)) return 1;


                    if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
                        return SendClientMessage(playerid, COLOR_GREY,"* You cannot turn this car's engine!");

                    format(string, sizeof(string), "* %s spins a key and tries to start vehicle engine.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_CHAT1,COLOR_CHAT2,COLOR_CHAT3,COLOR_CHAT4,COLOR_CHAT5);
                    SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
                    GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
                    gEngine[idcar] = 1;
                    SetVehicleParamsEx(idcar, 1, 1, 0, 0, 0, 0, 0);
                    new y, m, d;
                    new h,mi,s;
                    getdate(y,m,d);
                    gettime(h,mi,s);
                    format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s [CMD] -> /engine",d,m,y,h,mi,s,sendername);
                    CommandLog(string);
                    return 1;
                }
            }
        }

How do I make the second code work for the jump key (left shift) as there must be somthing wrong with it that causes it to not be...

Thanks: jakejohnsonusa