Como encender un vehнculo con una tecla
#2

Un ejemplo, no te hare todo:
pawn Код:
// ** INCLUDES

#include <a_samp>
#include <zcmd>

// ** DEFINES

// *** KEY SIMULATIONS

#define PRESSED(%0) (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))

// ** VARIABLES

// *** PER-PLAYER VARIABLES

// **** GENERAL

new bool:pNoFuel[MAX_PLAYERS] = false;

// ** MAIN

main()
{
    print("Loaded \"no_fuel_key.amx\".");
}

// ** CALLBACKS

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(PRESSED(KEY_YES))
    {
        if(pNoFuel[playerid])
        {
            TogglePlayerControllable(playerid, true);
            RemovePlayerFromVehicle(playerid);

            pNoFuel[playerid] = false;
        }
    }
    return 1;
}

// ** COMMANDS

CMD:nofuel(playerid, params[])
{
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "You must be inside a vehicle to use this command.");
    if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "You must be driving the vehicle to use this command.");

    if(!pNoFuel[playerid])
    {
        TogglePlayerControllable(playerid, false);

        pNoFuel[playerid] = true;
    }
    else
    {
        TogglePlayerControllable(playerid, true);

        pNoFuel[playerid] = false;
    }
    return 1;
}
pressed = presionу
key_yes = la tecla "Y"
Teclas: https://sampwiki.blast.hk/wiki/Keys
Reply


Messages In This Thread
Como encender un vehнculo con una tecla - by Axl1999 - 27.12.2015, 19:04
Re: Como encender un vehнculo con una tecla - by SickAttack - 27.12.2015, 19:19
Respuesta: Como encender un vehнculo con una tecla - by OTACON - 27.12.2015, 19:36
Respuesta: Como encender un vehнculo con una tecla - by Axl1999 - 27.12.2015, 20:14

Forum Jump:


Users browsing this thread: 1 Guest(s)