When pressing 2 it won't fix my vehicle..
#1

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
Reply
#2

'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;
}
Reply
#3

Thanks!
Reply
#4

[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;
}
Reply
#5

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;
}
Reply
#6

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

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..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)