sckatchof Posted October 23, 2012 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
50p Posted October 23, 2012 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
sckatchof Posted October 23, 2012 Author 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
50p Posted October 23, 2012 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 ... - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Anderl Posted October 23, 2012 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. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
sckatchof Posted October 23, 2012 Author Posted October 23, 2012 thank guys for help , but i try many times and still don't work .
Anderl Posted October 23, 2012 Posted October 23, 2012 Show your whole code. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
sckatchof Posted October 23, 2012 Author 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
Anderl Posted October 23, 2012 Posted October 23, 2012 Didn't I just send you fixed(?, not tested but it's fixed ) code? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
sckatchof Posted October 23, 2012 Author 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
Anderl Posted October 23, 2012 Posted October 23, 2012 Saying that it doesn't work without telling any more infos doesn't really help. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
sckatchof Posted October 23, 2012 Author 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 ?!!
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