Jump to content

I need help


sckatchof

Recommended Posts

i work for turf system but i have some problem when i enter to turf zone output don't work !

part of server side :

  
... 
.. 
.. 
function OnresourceOpen (player) 
local ColSize = 10.0 
  for ID in pairs(Turfids) do  
     local fX, fY, fZ = Turfids[ID][1], Turfids[ID][2], Turfids[ID][3] 
     local CreateColid = createColCuboid ( fX, fY, fZ, ColSize, ColSize, ColSize ) 
       if CreateColid then 
        addEventHandler("onColShapeHit", CreateColid, OnPlayerOnColHit) 
end 
end 
end 
addEventHandler("onResourceStart", resourceRoot, OnresourceOpen) 
  
  
 function OnPlayerOnColHit (player)  
      local money = math.random(2580, 4950) 
          if( source == CreateColid ) then 
         if getElementData( player, "YouAreTurfing") then  
         outputChatBox("You already Turfing.",player,255,0,0)  
         return  
         end 
       outputChatBox("balblabla", player, 0,255,255) 
        setElementData(player,"YouAreTurfing",true) 
        triggerClientEvent (player,"tn:Turfing",getRootElement()) 
         setRadarAreaFlashing ( pArea, true ) 
          TurfTimers[ player ] = setTimer(  
         function() 
         ..... 
         .. 
         .. 
        end, 300000, 1 ) 
end 
end      
  

Link to comment
turfShapes = { }; -- make it global - outside functions 
... 
  
turfShapes[ CreateColid ] = 1; -- once cuboid is created, add it to the turfs table, having element as table index is easier for later use in if statements 
... 
  
if ( turfShapes[ source ] ) then -- in your OnPlayerOnColHit to check if the hit shape is a a turf col shape 
... 

Link to comment
addEventHandler( "onResourceStart", resourceRoot, 
    function() 
         
        --create cuboids         
        local fX, fY, fZ; 
         
        for index, value in pairs( Turfids ) do --TODO: Might not work if table is indexed 
            fX, fY, fZ = value[1], value[2], value[3] -- less code in params means better organization 
             
            local cCuboid = createColCuboid( fX, fY, fZ, 10, 10, 10 ); 
             
            if cCuboid then 
             
                --add handlers 
                addEventHandler( "onColShapeHit", cCuboid, cuboidHit, false ); 
            end 
        end 
         
    end 
) 
  
function cuboidHit( p ) 
  
    --check whether the player is turfing already or not (what?) 
    if getElementData( p, "YouAreTurfing" ) then 
        outputChatBox( "You are already turfing!", p, 255, 0, 0, false ) 
        return 
    end 
     
    --some random debug code 
    outputChatBox( "blablabla", p, 0, 255, 255, false ) 
     
    --turf shit 
    setElementData( player, "YouAreTurfing", true ) 
    triggerClientEvent( player, "tn:Turfing", root ) 
     
    setRadarAreaFlashing( pArea, true ) 
     
    local theMoney = math.random(2580, 4930) 
    TurfTimers[ p ] = setTimer( 
        function() 
            --some code  
        end,  
    300000, 1) 
     
end 

Not tested.

Link to comment
Show your whole code.

i want just to test but it's don't work . (sorry for bad english )

server side ( Testing part ) :

function OnresourceOpen (player) 
  for ID in pairs(Turfids) do 
     local fX, fY, fZ = Turfids[ID][1], Turfids[ID][2], Turfids[ID][3] 
     CreateColid = createColCuboid ( fX, fY, fZ, 10.0, 10.0, 10.0 ) 
  if CreateColid then 
         addEventHandler( "onColShapeHit", CreateColid, cuboidHit, false ); 
end 
end 
end 
addEventHandler("onResourceStart", resourceRoot, OnresourceOpen) 
         
function cuboidHit (player) 
        outputChatBox ( "Test 1", player, 255, 0, 0 ) 
end 

Link to comment
Didn't I just send you fixed(?, not tested but it's fixed xD) code?

still don't work i tested it then i make that to test simple script but still don't work ! i want in this script when i enter to turf zone it show that msg " test 1 "

  
.. 
.. 
--{Tabel} 
.. 
  
function OnresourceOpen (player) 
  for ID in pairs(Turfids) do 
     local fX, fY, fZ = Turfids[ID][1], Turfids[ID][2], Turfids[ID][3] 
     CreateColid = createColCuboid ( fX, fY, fZ, 10.0, 10.0, 10.0 ) 
  if CreateColid then 
         addEventHandler( "onColShapeHit", CreateColid, cuboidHit, false ); 
end 
end 
end 
addEventHandler("onResourceStart", resourceRoot, OnresourceOpen) 
         
function cuboidHit (player) 
        outputChatBox ( "Test 1", player, 255, 0, 0 ) ---{ Just for test }--- 
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...