Como encender un vehнculo con una tecla
#1

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.
Reply
#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
#3

PHP код:
enum vInfo{
    
bool:pLuces,
    
bool:pMotor,
};
new 
pFunctionVehicles[MAX_VEHICLES][vInfo];
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys){
    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;

Reply
#4

Tengo estos errores:

(39) : error 079: inconsistent return types (array & non-array)
(621) : error 029: invalid expression, assumed zero
(621) : error 017: undefined symbol "GiveArmorToPlayer"
(621) : error 029: invalid expression, assumed zero
(621) : fatal error 107: too many error messages on one line


Linea 621 hasta la 630:
PHP код:
function GiveArmorToPlayer(playeridFloat:armour)
{
    
SetPlayerArmour(playeridFloat: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(playerid137310.300327, -0.004779, -0.17827173.44250425.95888132.691726);}
    
Att_Obj_Slot_1[playerid] = "Chaleco";
    return 
1;

Linea 39
PHP код:
#define Skin                            SetPlayerSkin 
No se por que me tiro esos errores....
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)