Jump to content

como bloquear el usos de armas en la carcel


JuanM27

Recommended Posts

Posted

hola, quisiera saber como poder bloquear el uso de armas, y de golpe cuando un player esta en la carcel?

busque en la wiki y no encontre nada relacionado.

si conocen la pag de la wiki que explique su funcion me lo podrian dar

o algun ejemplo si esa informacion no esta en la wiki.

saludos y gracias

Posted
Usa la funcion:
toggleControl("fire", false) 

dale muchas gracias, hay me funciono y con la wiki le puse para que tambien no permita el cambio de armas.

tengo 1 consulta

no saben cual es el id del Spray que usa el medico para currar en varios server? yo probe con el id 41 que es el Spraycan

pero ese hace daño al currar al otro player,

o como seria para que el Spray no haga daño a los players?

saludos y muchas gracias

Posted

Para cambiar el arma al slot 0: https://wiki.multitheftauto.com/wiki/SetPedWeaponSlot

Se usa el Spray Can ID: 41, pero cancelamos el daño en onClientPlayerDamage.

Ejemplo de como lo hice en el servidor SAUR:

-- client side:

addEventHandler("onClientPlayerDamage", localPlayer, 
function (attacker, weapon, bodypart, loss) 
    if (attacker and getElementType(attacker) == "player" and weapon == 41) then 
        local team = getPlayerTeam(attacker) 
        if (team and getTeamName(team) == "Medic") then 
            cancelEvent() 
        end 
    end 
end) 

Posted

hola si pongo ese codigo en el cliente

addEventHandler("onClientPlayerDamage", localPlayer, 
function (attacker, weapon, bodypart, loss) 
    if (attacker and getElementType(attacker) == "player" and weapon == 41) then 
        local team = getPlayerTeam(attacker) 
        if (team and getTeamName(team) == "Medicos") then 
            cancelEvent() 
        end 
    end 
end) 

no hace daño, pero no cura.

la parte que cura lo tengo en el lado del server que es la siguiente

function heal(attacker, attackerweapon, bodypart, loss) 
  theHealth = getElementHealth (source) 
  if (attackerweapon == 41) and (loss > 1) and ( theHealth < 90 ) then  -- el real era (if (attackerweapon == 14) and (loss > 1) and ( theHealth < 80 ) then) 
    setElementHealth ( source, 100 ) 
    takePlayerMoney (source, 100) 
    givePlayerMoney (attacker, 100) 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), heal ) 

pero trate de modificarlo, quitando la parte del server

y agregando en el cliente esto

addEventHandler("onClientPlayerDamage", localPlayer, 
function (attacker, weapon, bodypart, loss) 
    if (attacker and getElementType(attacker) == "player" and weapon == 41) then 
        local team = getPlayerTeam(attacker) 
        if (team and getTeamName(team) == "Medicos") then 
            setElementHealth ( localPlayer, 100 ) 
            takePlayerMoney (localPlayer, 100) 
            givePlayerMoney (attacker, 100) 
            cancelEvent() 
        end 
    end 
end) 

pero tampoco cura,

me darias una mano, para hacerlo funcionar?

gracias

Posted

-- client side.

addEventHandler("onClientPlayerDamage", localPlayer, 
function (attacker, weapon, bodypart, loss) 
    if (attacker and getElementType(attacker) == "player" and weapon == 41) then 
        local team = getPlayerTeam(attacker) 
        if (team and getTeamName(team) == "Medicos") then 
            cancelEvent() 
            if (not isTimer(timer)) then 
                local health = getElementHealth(localPlayer) 
                if (health < 99) then 
                triggerServerEvent("medic_heal", localPlayer, attacker) 
                timer = setTimer(function() end, 1000, 1) 
                end 
            end 
        end 
    end 
end) 

-- server side:

addEvent("medic_heal", true) 
addEventHandler("medic_heal", root, 
function (medic) 
    if (getElementHealth(source) < 100) then 
        local newHP = getElementHealth(source) + 20 
        setElementHealth(source, newHP) 
        if (newHP > 100) then 
             setElementHealth(source, 100) 
        end 
        givePlayerMoney(medic, 100) 
        takePlayerMoney(source, 100) 
    end 
end) 

  • Recently Browsing   0 members

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