Jump to content

[Aporte] DM Car detector


Recommended Posts

Estaba algo aburrido scripteando e hice un pequeño sistema para mi servidor. Lo que hace este mini-sistema es comprobar el ultimo golpe realizado a un vehiculo. Así también almacena el arma con el que se han realizado los daños. Bueno, si más, abajo dejo los códigos por separado.

Cliente

addEventHandler ( "onClientVehicleDamage", root, 
    function (attacker, weapon, _, _, _, _, _) 
        if attacker and weapon then 
            triggerServerEvent ( "onDañarVehiculo", root, source, attacker, weapon ) 
        end 
    end 
) 
  

Servidor

local ultimoGolpeAlVehiculo = { } -- Tabla para almacenar el golpe 
  
-- Recogemos los datos obtenidos del cliente y los almacenamos en una tabla. 
  
addEventHandler ( "onDañarVehiculo", root, 
    function ( vehiculo, responsable, arma ) 
        local nombreArma = getWeaponNameFromID ( arma ) 
        if nombreArma then 
            ultimoGolpeAlVehiculo [ vehiculo ] = { nombre = getPlayerName ( responsable ):gsub ( "_"," " ), arma = nombreArma  } 
        end 
    end 
) 
  
-- Comando para comprobar 
  
addCommandHandler ( "ultimogolpe", 
    function ( player, commandName ) 
        local vehicle = getPedOccupiedVehicle ( player ) 
        if vehicle then 
            local data = ultimoGolpeAlVehiculo [ vehicle ] 
            if data == nil then 
                outputChatBox ( "No se han realizado golpes al vehiculo.", player, 0, 255, 0 ) 
            else 
                local nombre = data.nombre 
                local arma = data.arma 
                outputChatBox ( "El jugador "..nombre.." realizó un daño usando un/a "..arma, player, 255, 145, 0 ) 
            end 
        else 
            outputChatBox ( "Debes estar en un vehiculo para comprobar su último golpe.", player, 255, 0, 0 ) 
        end 
    end 
) 

Link to comment
addEventHandler ( "onClientVehicleDamage", root, 
    function (attacker, weapon, _, _, _, _, _) 
        if attacker and weapon then 
            triggerServerEvent ( "onDañarVehiculo", root, source, attacker, weapon ) 
        end 
    end 
) 

Y si no hay un atacante :?:

Link to comment
  • 4 weeks later...
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...