SA-MP Forums Archive
Press 2 To Repair Help - 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: Press 2 To Repair Help (/showthread.php?tid=289802)



Press 2 To Repair Help - TyThaBomb - 13.10.2011

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



Re: Press 2 To Repair Help - Jefff - 13.10.2011

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



Re: Press 2 To Repair Help - TyThaBomb - 13.10.2011

Wanna give me an easier explanation of that?


Re: Press 2 To Repair Help - Joe Staff - 13.10.2011

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