Jump to content

[HELP] Player bullet Shield


Recommended Posts

Hi guys, i'm here for an obvious problem

I have this idea in my mind and I want to spare it with all of you.

I want to build an Active Protection Shield (APS) for a specific class on MTA and i was thinking about doing an object, a sphere in this case and make a COL file and it must behave as following:

- the player that's using the APS must be able to shoot from inside to the outside enemies, so he/she can kill'em;

- other enemies can't shoot to the player that's using the APS, well they can but their bullets must be stopped by the shield;

- all players can walk, run, jump through the shield as it must ignore collisions with everything except for bullets.

Now the model is already done, but i dont know how to ignore shoot collision for the player using the APS and activate shoot collision for enemies outside it.

For better explanation i put an image below.

11glfnp.png

I hope someone can help me and thanks in advance :)

Link to comment

try this

Client.lua

addEventHandler ( "onClientPlayerDamage",root, 
function () 
    if getElementData(source,"invincible") then 
        cancelEvent() 
    end 
end) 
  
addEventHandler("onClientPlayerStealthKill",localPlayer, 
function (targetPlayer) 
    if getElementData(targetPlayer,"invincible") then 
        cancelEvent() 
    end 
end) 
bindKey("1","down","protect") 

Server.lua

function togglestaff(thePlayer) 
local account = getPlayerAccount(thePlayer) 
if (not account or isGuestAccount(account)) then return end 
local accountName = getAccountName(account) 
if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then 
    if getElementData(thePlayer,"invincible") then 
        setElementData(thePlayer,"invincible",false) 
            outputChatBox("#00BFFFA Protect of: #FF0000".. getPlayerName(thePlayer) .." #FF0000OFF", getRootElement(),255,0,0,true) 
    else 
        setElementData(thePlayer,"invincible",true) 
            outputChatBox("#00BFFFA Protect of: #FF0000".. getPlayerName(thePlayer) .." #00FF00ON", getRootElement(),255,0,0,true) 
        end 
    end 
end 
addCommandHandler("protect",togglestaff) 

Link to comment

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