Jump to content

[Help] Turf/Colission


damien111

Recommended Posts

Well i am trying to make a script that checks if a player is in a collison box, and also checks what class they are in, and if they are in the class and the box, it allows the to do the /fish command, which puts the player into a animation, randomly choosing from some times, for a timer, that gives the player random amounts of money for thier fish! I get a argument error for all the events that use the player/source , sucha as givePlayerMoney, setPedAnimation , and getElementData, heres my code, i hope you guys can help me!

Server

showFishignArea = createRadarArea ( 3122.1650390625, -1563.978515625, 300, 300, 0, 255, 255, 100  ) 
fishingArea = createColRectangle ( 3122.1650390625, -1563.978515625, 300, 300 ) 
  
  
local fishTimes = 
{ 
    {4000}, 
    {6000}, 
    {8000}, 
    {10000}, 
    {2000}, 
    {12000} 
} 
  
local fishAmount = 
{ 
    {3}, 
    {4}, 
    {5}, 
    {6}, 
    {7} 
} 
  
  
function unpackTimes() 
    return unpack(fishTimes[math.random(#fishTimes)]) 
end 
  
function unpackAmounts() 
    return unpack(fishAmount[math.random(#fishAmount)]) 
end 
  
function startFishing() 
        local timer = unpackTimes() 
        --if (getElementData(player, "class") == "Fisherman") then 
        if (fishingAllowed) then 
            setPedAnimation ( source, "SWORD", "sword_part") 
            payTimer = setTimer( payPlayer, timer, 0 ) 
        end 
    end  
addCommandHandler ( "fish", startFishing ) 
  
function stopfishing() 
setPedAnimation(source,false) 
killTimer(payTimer) 
end 
addCommandHandler ( "stopfish", stopfishing ) 
  
function payPlayer() 
        local amount = unpackAmounts() 
        givePlayerMoney( source, amount ) 
        resetTimer ( payTimer ) 
end 
function hill_Enter ( thePlayer, matchingDimension ) 
        if getElementType ( thePlayer ) == "player" then 
             
            fishingAllowed = true 
             
        end 
end 
addEventHandler ( "onColShapeHit", fishingArea, hill_Enter ) 
  
function hill_Exit ( thePlayer, matchingDimension ) 
        if getElementType ( thePlayer ) == "player" then 
           
            fishingAllowed = false   
            
        end 
end 
addEventHandler ( "onColShapeLeave", fishingArea, hill_Exit ) 

Link to comment
showFishignArea = createRadarArea ( 3122.1650390625, -1563.978515625, 300, 300, 0, 255, 255, 100  ) 
fishingArea = createColRectangle ( 3122.1650390625, -1563.978515625, 300, 300 ) 
fishingAllowed = nil 
  
local fishTimes = { 
    {4000}, 
    {6000}, 
    {8000}, 
    {10000}, 
    {2000}, 
    {12000}, 
} 
  
local fishAmount = { 
    {3}, 
    {4}, 
    {5}, 
    {6}, 
    {7}, 
} 
  
function unpackTimes() 
    return unpack(fishTimes[math.random(#fishTimes)]) 
end 
  
function unpackAmounts() 
    return unpack(fishAmount[math.random(#fishAmount)]) 
end 
  
addCommandHandler ( "fish", 
function(player)  --Required Arguments player 
        local timer = unpackTimes() 
        --if (getElementData(player, "class") == "Fisherman") then 
        if (fishingAllowed) then 
            setPedAnimation ( player, "SWORD", "sword_part") 
            payTimer = setTimer( payPlayer, timer, 0 ,player) 
        end 
    end  
)    
  
addCommandHandler ( "stopfish", 
    function(player) ---Required Arguments player 
        setPedAnimation(player,false) 
        if isTimer(payTimer) then 
            killTimer(payTimer) 
            payTimer = nil 
        end  
    end 
) 
  
function payPlayer(player)  --- here element player 
    local amount = unpackAmounts() 
    givePlayerMoney( player, amount ) 
    resetTimer ( payTimer )  --- I think this is  unnecessary 
end 
  
addEventHandler ( "onColShapeHit", fishingArea, 
    function( thePlayer ) 
        if getElementType ( thePlayer ) == "player" then     
            fishingAllowed = true  
        end 
    end 
) 
  
addEventHandler ( "onColShapeLeave", fishingArea, 
    function( thePlayer ) 
        if getElementType ( thePlayer ) == "player" then 
              fishingAllowed = false      
        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...