SA-MP Forums Archive
Engine Key Start wont 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Engine Key Start wont work (/showthread.php?tid=206249)



Engine Key Start wont work - wilko1995 - 03.01.2011

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

    new vehicleid,engine,lights,alarm,doors,bonnet,boot,objective;
    
    vehicleid = GetPlayerVehicleID(playerid);
	GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
	if(engine == 0)
	{
		if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))
	    {
	        SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
	        return 1;
		}
	}
 	return 0;
}
this is the code im using. It has NO Errors when i compile it but ingame it wont start my vehicle's engine when i press L-Shift...

Can some one help?


Re: Engine Key Start wont work - Jochemd - 03.01.2011

Unsure, but use instead of 'oldkeys' 'newkeys'. Correct me if I'm wrong.


Re: Engine Key Start wont work - wilko1995 - 03.01.2011

if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))


((newkeys & KEY_JUMP) checks if the key is pressed

!(oldkeys & KEY_JUMP)) checks that the key isnt being held


Re: Engine Key Start wont work - Tessar - 03.01.2011

Quote:
Originally Posted by wilko1995
Посмотреть сообщение
if ((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP))


((newkeys & KEY_JUMP) checks if the key is pressed

!(oldkeys & KEY_JUMP)) checks that the key isnt being held
Always put code in [ pawn ][ /pawn ] it makes it easier to understand.


Re: Engine Key Start wont work - wilko1995 - 03.01.2011

Anyone?


Re: Engine Key Start wont work - psoftware - 03.01.2011

L-Shift Key doesn't work in vehicles. Try with another key.....


Re: Engine Key Start wont work - Sascha - 03.01.2011

yap, you can only get keys that are defined for the vehicle..
you can try one of the fire keys or so...


Re: Engine Key Start wont work - DRIFT_HUNTER - 03.01.2011

KEY_JUMP - Left shift in vehicle become S key


Re: Engine Key Start wont work - duukjones - 10.02.2011

Quote:
Originally Posted by psoftware
Посмотреть сообщение
L-Shift Key doesn't work in vehicles. Try with another key.....
Ofcourse it does. I got it working in my server.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    new pveh = GetVehicleModel(GetPlayerVehicleID(playerid));
    new newcar = GetPlayerVehicleID(playerid);
    if(newkeys == KEY_JUMP)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            if(IsPlayerConnected(playerid))
            {
                if(!engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
                    {
                        return 1;
                    }
                    if(IsAnOwnableCar(newcar))
                    {
                        if(PlayerInfo[playerid][pPcarkey] == newcar) { }
                        else if(PlayerInfo[playerid][pPcarkey2] == newcar) { }
                        else if(PlayerInfo[playerid][pPcarkey3] == newcar) { }
                        else { return 1; }
                    }
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509)
                    {
                        return 1;
                    }
                    if(newcar == 59 || newcar == 60)
                    {
                        return 1;
                    }
                    if(newcar >= 135 && newcar <= 154)
                    {
                        if(HireCar[playerid] != newcar)
                        {
                            return 1;
                        }
                    }
                    if(IsAHarvest(newcar))
                    {
                        return 1;
                    }
                    if(IsADrugHarvest(newcar))
                    {
                        return 1;
                    }
                    if(IsAPlane(newcar))
                    {
                        return 1;
                    }
                    if(IsASweeper(newcar))
                    {
                        return 1;
                    }
                    if(gEngine[playerid] == 1) { return 1; }

                    new playerveh = GetPlayerVehicleID(playerid);
                    if(playerveh != INVALID_VEHICLE_ID) {
                    GetVehicleParamsEx(playerveh,engine,lights,alarm,doors,bonnet,boot,objective);
                    SetVehicleParamsEx(playerveh,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
                    }
                    PutPlayerInVehicle(playerid, newcar, 0);
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s starts the vehicle engine.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                    //SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
                    //GameTextForPlayer(playerid, "~w~Starting vehicle engine...",3500,3);
                    SendClientMessage(playerid, COLOR_LIGHTBLUE, "  You started the vehicle's engine.  ");
                    engineOn[GetPlayerVehicleID(playerid)] = true; // remove if wanna use the timer
                    TogglePlayerControllable(playerid, true);      // remove if wanna use the timer
                    gEngine[playerid] = 1;
                    return 1;
                }
            }
        }
    }