Jump to content

Help with colShape Table


Kenix

Recommended Posts

script does not work :(

  
  
  
local anomalstp1 = 
{ 
{286.05, 1319.48, 3}, 
} 
  
  
function anomalys( thePlayer, matchingDimension ) 
                local fX = anomalstp1[1] 
                local fY = anomalstp1[2] 
                local radius = anomalstp1[3] 
                colShape[id]  = createColCircle ( fX, fY, radius )  
outputChatBox("1")               
end 
addEventHandler ( "onResourceStart", getRootElement(), anomalys ) 
  
function onAnomalyHit() 
outputChatBox("1") 
end 
addEventHandler ( "onColShapeHit", anomalstp1, onAnomalyHit ) 
  

Link to comment
What do you put as the second argument at line 22? A table?

https://wiki.multitheftauto.com/wiki/AddEventHandler

What's the "id" argument for colShape table at line 14? Is it really defined? Is the colShape a table?

thx function anomalys( thePlayer, matchingDimension ) WORKS

Now how do I do that when you come into colShape table * anomalstp1

obtain a function outputChatBox?

here I am done but not working :(

  
  
  
  
local anomalstp1 = 
{ 
{286.05, 1319.48, 3}, 
} 
  
  
function anomalys( thePlayer, matchingDimension ) 
                local fX = anomalstp1[1] 
                local fY = anomalstp1[2] 
                local radius = anomalstp1[3] 
                createColCircle ( fX, fY, radius )  
outputChatBox("1")               
end 
addEventHandler ( "onResourceStart", getRootElement(), anomalys ) 
  
function onAnomalyHit() 
if anomalstp1 == true then 
outputChatBox("1") 
end 
addEventHandler ( "onColShapeHit", getRootElement(), onAnomalyHit ) 
  

300 post :D

Link to comment

Even while the colshape is created, you can't use it since you have no variable defined for it at line 15. Should be like:

myColCircle = createColCircle ( fX, fY, radius ) 

Then, at line 21 you check if the colShape a player entered is myColCIrcle:

replace line 21 with

if source == myColCircle then 

Read https://wiki.multitheftauto.com/wiki/Event_system after and make sure to understand what does "source" mean, It's crucial. When you do it must be clear why using

if anomalstp1 == true then 

is incorrect.

Link to comment
  • Moderators

Hi volk-us ( again :lol: ),

local anomalstp1 = 
{ 
{286.05, 1319.48, 3}, 
} 
  
  
function anomalys( thePlayer, matchingDimension ) 
    local fX = anomalstp1[1] 
    local fY = anomalstp1[2] 
    local radius = anomalstp1[3] 
    local colcircle = createColCircle ( fX, fY, radius ) 
    setElementID( colcircle, "anomalstp1" ) 
    outputChatBox("1")               
end 
addEventHandler ( "onResourceStart", getRootElement(), anomalys ) 
  
function onAnomalyHit() 
    if anomalstp1 == true then 
        outputChatBox("1") 
    end 
end 
addEventHandler ( "onColShapeHit", getRootElement(), onAnomalyHit ) 

Replace by this:

local anomalstp1 = 
{ 
{286.05, 1319.48, 3}, 
} 
  
 function onAnomalyHit( hitElement, matchingDimension ) 
    --instructions 
end 
  
function anomalys( thePlayer, matchingDimension ) 
    local fX = anomalstp1[1] 
    local fY = anomalstp1[2] 
    local radius = anomalstp1[3] 
    local colcircle = createColCircle ( fX, fY, radius ) 
    addEventHandler ( "onColShapeHit", colcircle, onAnomalyHit ) 
    outputChatBox("1")               
end 
addEventHandler ( "onResourceStart", getRootElement(), anomalys ) 

It should works

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