27.12.2015, 19:04
Tengo una GM (Ciudad Prohibida) donde quiero aprender a Scriptear y me gustarнa saber como puedo hacer que el vehнculo encienda las luces con la tecla "2" y encienda/apague el vehiculo con un Click.
// ** 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;
}
enum vInfo{
bool:pLuces,
bool:pMotor,
};
new pFunctionVehicles[MAX_VEHICLES][vInfo];
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys){
static
engine,lights,alarm,doors,bonnet,boot,objective;
new
vehicleid = GetPlayerVehicleID(playerid);
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
// luces
if( newkeys & KEY_SUBMISSION ){
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "no estas en un vheiculo");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "no eres conductor");
if( !pFunctionVehicles[vehicleid][pLuces] ){
pFunctionVehicles[vehicleid][pLuces] = true;
SetVehicleParamsEx(vehicleid,engine,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
}else{
pFunctionVehicles[vehicleid][pLuces] = false;
SetVehicleParamsEx(vehicleid,engine,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
}
}
// motor
if( newkeys & KEY_FIRE ){
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "no estas en un vheiculo");
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, -1, "no eres conductor");
if( !pFunctionVehicles[vehicleid][pMotor] ){
pFunctionVehicles[vehicleid][pMotor] = true;
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective);
}else{
pFunctionVehicles[vehicleid][pMotor] = false;
SetVehicleParamsEx(vehicleid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective);
}
}
return true;
}
function GiveArmorToPlayer(playerid, Float:armour)
{
SetPlayerArmour(playerid, Float:armour);
HasArmor[playerid] = 1;
ScriptArmor[playerid] = armour;
if(Team_LSPD(playerid)){SetPlayerAttachedObject(playerid,1,19142,1,0.099258,0.031748,-0.015871,360.000000,358.979064,357.476074,1.072590,1.239796,-1.046599);}
else{SetPlayerAttachedObject(playerid, 1, 373, 1, 0.300327, -0.004779, -0.178271, 73.442504, 25.958881, 32.691726);}
Att_Obj_Slot_1[playerid] = "Chaleco";
return 1;
}
#define Skin SetPlayerSkin