Reversing horn
#1

Hey i was making a reversing horn but if i use it its not working... This is my code:
pawn Код:
new Reversing[MAX_PLAYERS];
forward ReverseHorn(playerid,vehicleid);
^ Thats the top ^
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;
}
^Thats Key state change^
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);
    }
}
This is what it should do but the alarm doesnt go on when driving backwards anyone know how to fix this?
Reply
#2

BUMP
Reply
#3

BUMP Come on is this so difficult?
Reply
#4

Hello someone gave me this code:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP) && GetPlayerVehicleID(playerid) != 0)
    {
        SetPVarInt(playerid, "ReverseHorn", 1);
        ReverseHorn(GetPlayerVehicleID(playerid), 1);
    }
    if((oldkeys & KEY_JUMP) && !(newkeys & KEY_JUMP) && GetPlayerVehicleID(playerid) != 0)
    {
        if(GetPVarInt(playerid, "ReverseHorn") == 0) return 1;
        SetPVarInt(playerid, "ReverseHorn", 0);
        ReverseHorn(GetPlayerVehicleID(playerid), 0);
    }
    return 1;
}

ReverseHorn(vehicleid, bool:status)
{
    switch(status)
    {
        case 0:
        {
            SetVehicleParamsEx(vehicleid, -1, -1, 0, -1, -1, -1, -1); //engine, lights, alarm, doors, bonnet, boot, objective
        }
        case 1:
        {
            SetVehicleParamsEx(vehicleid, -1, -1, 1, -1, -1, -1, -1); //engine, lights, alarm, doors, bonnet, boot, objective
        }
    }
}
BUt i get these warnings:
Код:
C:\Users\Thimo\Desktop\Programmas\Mappen\Samp 2\gamemodes\PPC_Trucking.pwn(1223) : warning 213: tag mismatch
C:\Users\Thimo\Desktop\Programmas\Mappen\Samp 2\gamemodes\PPC_Trucking.pwn(1229) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
These lines are this:
pawn Код:
if((newkeys & KEY_JUMP) && !(oldkeys & KEY_JUMP) && GetPlayerVehicleID(playerid) != 0)
    {
        SetPVarInt(playerid, "ReverseHorn", 1);
        ReverseHorn(GetPlayerVehicleID(playerid), 1); //this is the warning message
    }
    if((oldkeys & KEY_JUMP) && !(newkeys & KEY_JUMP) && GetPlayerVehicleID(playerid) != 0)
    {
        if(GetPVarInt(playerid, "ReverseHorn") == 0) return 1;
        SetPVarInt(playerid, "ReverseHorn", 0);
        ReverseHorn(GetPlayerVehicleID(playerid), 0); //this is the warning message too
    }
Could anyone please help? thank you
Its working but it gives warnings! :S
Reply
#5

Try to get the vehicleid before, like... new vehicleid = getplayervehicleid..
and then use ReverseHorn(vehicleid, 1);
Reply
#6

Has no sense :S
Reply
#7

From
Код:
bool:status
to
Код:
status
Reply
#8

ty it works
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)