SA-MP Forums Archive
When pressing 2 it won't fix my vehicle.. - 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: When pressing 2 it won't fix my vehicle.. (/showthread.php?tid=200483)



When pressing 2 it won't fix my vehicle.. - Seven. - 18.12.2010

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & 1024)
    {
    SetVehicleHealth(playerid, 1000.0); SM(playerid,rose,"You have fixed your vehicle.");
    }
    return 1;
}
What's wrong with the code? It didn't happen to me in 0.3b but in 0.3c it won't work anymore


Re: When pressing 2 it won't fix my vehicle.. - WillyP - 18.12.2010

'Cause you've done it wrong.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
    SetVehicleHealth(playerid, 1000.0); SM(playerid,rose,"You have fixed your vehicle.");
    }
    return 1;
}



Re: When pressing 2 it won't fix my vehicle.. - Seven. - 18.12.2010

Thanks!


Re: When pressing 2 it won't fix my vehicle.. - HyperZ - 18.12.2010

[FU]Victious's code isn't wrong but
This one is better
Check if the player is in a specific vehicle.
pawn Код:
if (IsPlayerInAnyVehicle(playerid))
Code:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   if(newkeys & KEY_FIRE)
    {
        if (IsPlayerInAnyVehicle(playerid)) {
        SetVehicleHealth(playerid, 1000.0); SM(playerid,rose,"You have fixed your vehicle.");
        }
    }
    return 1;
}



Re: When pressing 2 it won't fix my vehicle.. - Jefff - 18.12.2010

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_FIRE)
    {
        new veh = GetPlayerVehicleID(playerid);
        if(veh) {
            SM(playerid,rose,"You have fixed your vehicle."),PlayerPlaySound(playerid,1133,0.0,0.0,0.0);
            return RepairVehicle(veh);
        }
    }
    return 1;
}



Re: When pressing 2 it won't fix my vehicle.. - poging_hacker - 28.07.2011

how to change the key "2" to another one so that when you press another specific key it will repair


Re: When pressing 2 it won't fix my vehicle.. - iPLEOMAX - 28.07.2011

Quote:
Originally Posted by poging_hacker
Посмотреть сообщение
how to change the key "2" to another one so that when you press another specific key it will repair
Bumping old topics isn't a good idea.

Anyway, look at this: Key List

To make your own key, just use this code to see what key(s) you are pressing.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new debugg[64];
format(debugg,sizeof(debugg),"Total Value of Key(s) Pressed %d", newkeys);
SendClientMessage(playerid, -1, debugg);
return true;
}

//Then you can use if newkeys == 128 or whatever..