Jump to content

Zone (antiwp)


Recommended Posts

Posted

Hello everyone

I made a zone of PVP, I create for it an anti weapon for example (Minigun, Rocket Launcher...) etc

but it doesn't work

anyone help please?

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted

Client

local antiWeapon = {[0] = true, [1] = true, [2] = true, [4] = true, [5] = true, [6] = true, [8] = true, [9] = true, [10] = true, [12] = true, [14] = true, [34] = true, [35] = true, [36] = true, [37] = true, [38] = true, [16] = true, [17] = true, [18] = true, [39] = true, [14] = true, [40] = true, [41] = true} 
  
addEventHandler("onClientPedDamage", root, 
function  (attacker, weapon) 
    local pvp = getElementData(source, "PVP") 
    if pvp and antiWeapon[weapon] then 
        cancelEvent() 
    end 
end) 
  
addEventHandler("onClientPlayerWeaponSwitch", localPlayer,  
function (prevSlot, newSlot) 
    for _, pvp in ipairs(getElementsByType("player")) do 
        if getElementData(pvp, "PVP") then 
            local px, py, pz = getElementPosition(localPlayer) 
            local x, y, z = getElementPosition(pvp) 
            local dist = getDistanceBetweenPoints3D(px, py, pz, x, y, z) 
            if dist < 300 and antiWeapon[getPedWeapon(getLocalPlayer())] then 
                outputChatBox("No se puede utilizar esta arma en PVP Zona", 255, 0, 0) 
                toggleControl("fire", false) 
                return 
            else 
                toggleControl("fire", true) 
            end 
        end 
    end 
end) 
  
  
addEventHandler("onClientPlayerWeaponFire", localPlayer, 
function (weapon, _, _, _, _, _, hitElement ) 
    if hitElement and getElementData(hitElement, "PVP") and antiWeapon[weapon] then 
        outputChatBox("No se puede utilizar esta arma en PVP Zona", 255, 0, 0) 
        toggleControl("fire", false) 
    end 
end) 
  
  
  
  
  
addEventHandler("onClientPlayerDamage", localPlayer, 
function (attacker,weapon, bodypart) 
    if (attacker) and (isElement(attacker)) and not (attacker == source) then 
        if (getElementType(attacker) == "vehicle") then  
            attacker = getVehicleController(attacker) or false 
        end 
        if (attacker) and (getElementType(attacker) == "player") then 
            local ff1, ff2, bag1, bag2 = getElementData(source, "friendlyFire"), getElementData(attacker, "friendlyFire"), getElementData(source, "bag"), getElementData(attacker, "bag") 
            if (bag1 or bag2) then return end 
            if (ff1 or ff2) then return end 
            cancelEvent() 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerStealthKill", localPlayer, 
function (attacker,weapon, bodypart) 
    if (attacker) and (getElementType(attacker) == "player") then 
        local ff1, ff2 = getElementData(source, "friendlyFire"), getElementData(attacker, "friendlyFire") 
        if not (ff1 or ff2) then 
            cancelEvent() 
        end 
    end 
end) 
  
  
addEventHandler("onClientPlayerSpawn", root, 
function ( ) 
    if not (source == localPlayer) then 
        setElementCollidableWith(source, localPlayer, false) 
    end 
end) 
  
addEventHandler("onClientResourceStart", resourceRoot, 
function ( ) 
    for _, thePlayer in ipairs(getElementsByType("player"))do 
        if not (thePlayer == localPlayer) then 
            setElementCollidableWith(thePlayer, localPlayer, false) 
        end 
    end 
end)  

76561198387870432.png

ZI ZOMBIE INFECTION: mtasa://5.196.7.163:22003

560x95_FFFFFF_FF9900_000000_000000.png

Posted
The debug is clean ._.

Try using outputDebugString to see what the problem is.

And try this

local antiWeapon = {[0] = true, [1] = true, [2] = true, [4] = true, [5] = true, [6] = true, [8] = true, [9] = true, [10] = true, [12] = true, [14] = true, [34] = true, [35] = true, [36] = true, [37] = true, [38] = true, [16] = true, [17] = true, [18] = true, [39] = true, [14] = true, [40] = true, [41] = true} 
  
addEventHandler("onClientPlayerDamage",localPlayer, 
function  (attacker, weapon) 
    if (attacker and getElementType(attacker) == "player" and attacker ~= source) then 
        local pvp = getElementData(source, "PVP") 
        if pvp and antiWeapon[weapon] then 
            cancelEvent() 
        end 
    end  
end) 
  
addEventHandler("onClientPlayerWeaponSwitch", localPlayer, 
function (prevSlot, newSlot) 
    for _, pvp in ipairs(getElementsByType("player")) do 
        if getElementData(pvp, "PVP") then 
            local px, py, pz = getElementPosition(localPlayer) 
            local x, y, z = getElementPosition(pvp) 
            local dist = getDistanceBetweenPoints3D(px, py, pz, x, y, z) 
            if dist < 300 and antiWeapon[getPedWeapon(getLocalPlayer())] then 
                outputChatBox("No se puede utilizar esta arma en PVP Zona", 255, 0, 0) 
                toggleControl("fire", false) 
                return 
            else 
                toggleControl("fire", true) 
            end 
        end 
    end 
end) 
  
  
addEventHandler("onClientPlayerWeaponFire", localPlayer, 
function (weapon, _, _, _, _, _, hitElement ) 
    if hitElement and getElementData(hitElement, "PVP") and antiWeapon[weapon] then 
        outputChatBox("No se puede utilizar esta arma en PVP Zona", 255, 0, 0) 
        toggleControl("fire", false) 
    end 
end) 
  
  
addEventHandler("onClientPlayerDamage", localPlayer, 
function (attacker,weapon, bodypart) 
    if (attacker) and (isElement(attacker)) and not (attacker == source) then 
        if (getElementType(attacker) == "vehicle") then 
            attacker = getVehicleController(attacker) or false 
        end 
        if (attacker) and (getElementType(attacker) == "player") then 
            local ff1, ff2, bag1, bag2 = getElementData(source, "friendlyFire"), getElementData(attacker, "friendlyFire"), getElementData(source, "bag"), getElementData(attacker, "bag") 
            if (bag1 or bag2) then return end 
            if (ff1 or ff2) then return end 
            cancelEvent() 
        end 
    end 
end) 
  
addEventHandler("onClientPlayerStealthKill", localPlayer, 
function (attacker,weapon, bodypart) 
    if (attacker) and (getElementType(attacker) == "player") then 
        local ff1, ff2 = getElementData(source, "friendlyFire"), getElementData(attacker, "friendlyFire") 
        if not (ff1 or ff2) then 
            cancelEvent() 
        end 
    end 
end) 
  
  
addEventHandler("onClientPlayerSpawn", root, 
function ( ) 
    colliDable(source) 
end) 
  
addEventHandler("onClientResourceStart", resourceRoot, 
function ( ) 
    for _, thePlayer in ipairs(getElementsByType("player"))do 
        colliDable(thePlayer) 
    end 
end) 
  
function colliDable(player) 
    if not (player == localPlayer) then  
        setElementCollidableWith(player, localPlayer, false) 
    end  
end  

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted
nothing in debug

not work:/

You can't see every thing using debugscript 3 , Try using outputDebugString to see what the problem is.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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...