Jump to content

isElementWithinColShape issue


icarus

Recommended Posts

Posted

i was trying to make that when a player that is inside a colshape after a timer get warped to a place.

I dont know whats wrong with this.

function warpplayer ( thePlayer ) 
        if isElementWithinColShape ( thePlayer, Bankcol ) then 
    setElementPosition ( thePlayer, 2655, 2706, 411 ) 
end 
end 

Also tryed this, actually i tyed this first

function warpplayer ( source ) 
        if isElementWithinColShape ( source, Bankcol ) then 
    setElementPosition ( source, 2655, 2706, 411 ) 
end 

The debugscript 3 message is always the same: Bad argument @ "isElementWithinColShape" [Expected element at argument 1]

Can someone help me at this ?

Posted

i think this is what you looking for.

function warpplayer() 
     for i,player in ipairs(getElementsByType("player")) do 
          if isElementWithinColShape(player, Bankcol) then 
               setElementPosition(player, 2655, 2706, 411) 
          end 
     end 
end 

Posted

thanks, it works , i have other question, if i wanted to match a random place how could i do it.

Like in this

function (attacker, gun) 
  if getTeamName(getPlayerTeam(attacker)) == "Police" then -- if attacker was a cop 
   if gun == 23 or gun == 3 then -- if it was a tazer or stick 
    setElementPosition(source, -643.82635498047, 1945.7033691406, 2) 
    setElementPosition(source, -1980, 4991, 39)-- set there position 
   end 
end 
end 
) 
  
  

i wanted to make it to warp it or to a place or to the other

Posted
local positions = 
    { 
        { -643.82635498047, 1945.7033691406, 2 }, 
        { -1980, 4991, 39 } 
    } 
  
function (attacker, gun) 
  if getTeamName(getPlayerTeam(attacker)) == "Police" then -- if attacker was a cop 
   if gun == 23 or gun == 3 then -- if it was a tazer or stick 
    setElementPosition(source, unpack ( positions [ math.random ( #positions ) ] ) ) 
   end 
end 
end 
) 

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