27.12.2015, 19:19
Un ejemplo, no te hare todo:
pressed = presionу
key_yes = la tecla "Y"
Teclas: https://sampwiki.blast.hk/wiki/Keys
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;
}
key_yes = la tecla "Y"
Teclas: https://sampwiki.blast.hk/wiki/Keys