How to make when player press 2, to start the car engine ?
#1

When press 2 to process the CMD:engine
Reply
#2

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new engine, lights, alarm, doors, bonnet, boot, objective;
    new vehicleid = GetPlayerVehicleID(playerid);
    if (GetPlayerVehicleSeat(playerid) == 0)
    {
        if (newkeys & EXAMPLE_KEY) //Change your key here
        {
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, objective);
            SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle's engine is now turned [ON].");
        }

    }
    return 1;
}
Reply
#3

Only possible with keys from this list:

https://sampwiki.blast.hk/wiki/Keys

pawn Код:
IsKeyJustDown(key, newkeys, oldkeys)
{
    if((newkeys & key) && !(oldkeys & key))  return 1;
    return 0;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsKeyJustDown(KEY_FIRE, newkeys, oldkeys))
    {
        return cmd_engine(playerid,param);
    }
    return 1;
}
Reply
#4

error 017: undefined symbol "param" i used your code,@Stefand
Reply
#5

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if ((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
    {
        cmd_engine(playerid, "");
    }
    return 1;
}
Reply
#6

(iOxide)You can't use his code directly.He just gave an idea and you were supposed to change the key.(Stefand Code)He assumes that you have a command engine already.And change the param to ""(I think so).You were supposed to fix youself because you know about your command better than us.If you still haven't done your code use this code...

A little change to I oxide's code, replace the existing callback in your script with this one.This code will turn off the engine if it was on and turn on if it was off.
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (GetPlayerVehicleSeat(playerid) == 0)
    {
        if (newkeys & KEY_SUBMISSION) 
        {
               return cmd_engine(playerid,"");
        }

    }
    return 1;
}
And paste this anywhere in the script.
Код:
CMD:engine(playerid,params[])
{
            new engine, lights, alarm, doors, bonnet, boot, objective;
            new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(i))
{
            GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
            SetVehicleParamsEx(vehicleid, !engine, lights, alarm, doors, bonnet, boot, objective);
            SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle's engine is now turned [ON].");
}
else
{
        //Send a message telling he is not in a vehicle to manipulate an engine
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)