Press 2 To Repair Help
#1

Well, I have this script, but I want to do it where you DON'T have to let off of W to flip/add nos/repair. Any help would be appreciated!
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(IsPlayerConnected(playerid))
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(newkeys == KEY_SUBMISSION && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            new Float:z,
            vehicle = GetPlayerVehicleID(playerid);
            GetVehicleZAngle(vehicle, z);
            if(IsPlayerInVehicle(playerid, vehicleid))
            {
                SetVehicleZAngle(vehicle, z+0.1);
                SetVehicleHealth(vehicleid,1000.0);
                RepairVehicle(GetPlayerVehicleID(playerid));
                AddVehicleComponent(vehicleid,1010);

            }
            return 1;
        }
    }
}
Reply
#2

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
printf("key: %d",newkeys);
....
rest
press W and 2 together then print

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(key number))
    {
        if(!GetPlayerVehicleSeat(playerid))
        {
            new Float:z,veh;
            veh = GetPlayerVehicleID(playerid);
            GetVehicleZAngle(veh, z);
            SetVehicleZAngle(veh, z+0.1);
            //SetVehicleHealth(veh,1000.0);
            RepairVehicle(veh);
            AddVehicleComponent(veh,1010);
            return 1;
        }
    }
    return 1;
}
Reply
#3

Wanna give me an easier explanation of that?
Reply
#4

pawn Код:
if((newkeys&KEY_SUBMISSION)&&!(oldkeys&KEY_SUBMISSION))
    {
        //repair vehicle
    }
That's all you need
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)