sckatchof Posted October 23, 2012 Share Posted October 23, 2012 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
50p Posted October 23, 2012 Share Posted October 23, 2012 CreateColid is a local variable in OnresourceOpen function in a loop. So, if( source == CreateColid) in OnPlayerOnColHit will never be true. Link to comment
sckatchof Posted October 23, 2012 Author Share Posted October 23, 2012 CreateColid is a local variable in OnresourceOpen function in a loop. So, if( source == CreateColid) in OnPlayerOnColHit will never be true. thnx , how can i fix it Link to comment
50p Posted October 23, 2012 Share Posted October 23, 2012 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
Anderl Posted October 23, 2012 Share Posted October 23, 2012 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
sckatchof Posted October 23, 2012 Author Share Posted October 23, 2012 thank guys for help , but i try many times and still don't work . Link to comment
sckatchof Posted October 23, 2012 Author Share Posted October 23, 2012 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
Anderl Posted October 23, 2012 Share Posted October 23, 2012 Didn't I just send you fixed(?, not tested but it's fixed ) code? Link to comment
sckatchof Posted October 23, 2012 Author Share Posted October 23, 2012 Didn't I just send you fixed(?, not tested but it's fixed ) 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
Anderl Posted October 23, 2012 Share Posted October 23, 2012 Saying that it doesn't work without telling any more infos doesn't really help. Link to comment
sckatchof Posted October 23, 2012 Author Share Posted October 23, 2012 Saying that it doesn't work without telling any more infos doesn't really help. More info ! what you mean i post that server side and i think that should work ?!! Link to comment
Mossy Posted October 23, 2012 Share Posted October 23, 2012 Have you tried using /debugscript ? Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now