damien111 Posted January 11, 2013 Share Posted January 11, 2013 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
Cornelis Posted January 11, 2013 Share Posted January 11, 2013 I'm not sure, but I think this is a bit unnecessary: resetTimer ( payTimer ) Link to comment
damien111 Posted January 11, 2013 Author Share Posted January 11, 2013 It is, i just realised that Link to comment
MR.S3D Posted January 11, 2013 Share Posted January 11, 2013 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
GhostXoP Posted January 12, 2013 Share Posted January 12, 2013 fishingAllowed = nil Doncha think that's a little pointless? Link to comment
damien111 Posted January 12, 2013 Author Share Posted January 12, 2013 Thanks guys, it worked, i took out some of the pointless tuff, Link to comment
damien111 Posted January 12, 2013 Author Share Posted January 12, 2013 Now i have a new problem, so i took the comment away from infront of if (getElementData(player, "class") == "Fisherman") then added the end, etc. Now nobody can fish. Yes i set the data using runcode, help me? Link to comment
Castillo Posted January 12, 2013 Share Posted January 12, 2013 Any errors? are you sure that "class" is set? Link to comment
damien111 Posted January 12, 2013 Author Share Posted January 12, 2013 no errors :\ and ye, i triple checked. Link to comment
damien111 Posted January 12, 2013 Author Share Posted January 12, 2013 Aha! THe problem was i set the data to Class not class, Thanks guys! 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