Jump to content

Bioshock Fire-Skill ( Table contains local player )


Maurize

Recommended Posts

Hello Community Members,

I´ve created a little Skill like the player in Bioshock got.

At first, I am creating a Fire Power. Players should be able to fire

other players arround them.

Please give me some hints what can be done better.

And how can i get the closesest player?

My Problem is, that my created table contains EVERY PLAYER ( the local player, too ).

So the local player gets fired, too. Is there a way to remove the local player out of the table?

Here my code:

 

****JR10 fixed Version**** 

Edited by Guest
Link to comment

Try this:

Spieler = getRootElement() 
  
function BindAbility( thePlayer ) 
    bindKey( thePlayer, "1", "down", Abilities ) 
    setElementData( thePlayer, "power_fire", true ) 
    setElementData( thePlayer, "power_energy", 100 ) 
    setElementData( thePlayer, "power_level", 5 ) 
end 
addCommandHandler( "test2", BindAbility ) 
  
function Abilities( player ) 
if ( getElementData( player, "power_fire" ) == true ) then 
if ( getElementData( player, "power_energy" ) > 19 ) then 
    setTimer( setElementData, 1500, 1, player, "power_fire", true ) 
    setElementData( player, "power_fire", false ) 
    setElementData( player, "power_energy", tonumber( getElementData( player, "power_energy" ) ) - 20 ) 
    outputChatBox( "Jetzt seit ihr dran!", player, 155, 155, 0 ) 
    px, py, pz = getElementPosition( player ) 
    detec = createColSphere( px, py, pz, getElementData( player, "power_level" ) * 1.5 ) 
    victims = getElementsWithinColShape( detec, "ped" ) 
    destroyElement( detec ) 
for index, victim in ipairs( victims ) do 
    if victim ~= getLocalPlayer() then 
         x, y, z = getElementPosition( victim ) 
         createExplosion( x, y, z, 0 ) 
     end 
    end  
end 
else 
    outputChatBox( "Ich habe nicht genug Eve im Blut!", player, 155, 155, 0 ) 
    setTimer( setElementData, 2000, 5, player, "power_energy", tonumber( getElementData( player, "power_energy" ) ) + 20 ) 
    end 
end 

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