02.03.2011, 17:08
Hey i was making a reversing horn but if i use it its not working... This is my code:
^ Thats the top ^
^Thats Key state change^
This is what it should do but the alarm doesnt go on when driving backwards anyone know how to fix this?
pawn Код:
new Reversing[MAX_PLAYERS];
forward ReverseHorn(playerid,vehicleid);
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
#define HOLDING(%0) \
((newkeys & (%0)) == (%0))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
if (HOLDING(KEY_JUMP) && IsPlayerInAnyVehicle(playerid) && Reversing[playerid] == 0) {
Reversing[playerid] = 1;
}
if (RELEASED(KEY_JUMP)&& IsPlayerInAnyVehicle(playerid)) {
Reversing[playerid] = 0;
}
return 1;
}
pawn Код:
public ReverseHorn(playerid, vehicleid)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
if (Reversing[playerid] == 1) {
SetVehicleParamsEx(vehicleid, engine, lights, true, doors, bonnet, boot, objective);
}
else {
SetVehicleParamsEx(vehicleid, engine, lights, false, doors, bonnet, boot, objective);
}
}