Jump to content

[Help] How To Keep From Buggin [ Help]


damien111

Recommended Posts

So i know i didnt think this through, but how can i make my script not bug when more than 1 person is using it? They are suppose to do /startfishing or whatever the command is ( i am constantly changing it ), and it randomly picks a time til they get paid, how much they get paid, but i dont know how to keep that from getting bugged.

Server

showFishignArea = createRadarArea ( 3122.1650390625, -2894.99829, 10000, 10000, 0, 255, 255, 100 ) 
fishingArea = createColRectangle ( 3122.1650390625, -2894.99829, 10000, 10000 ) 
fishingAllowed = nil 
  
local fishTimes = { 
{4000}, 
{4000}, 
{4000}, 
{4000}, 
{6000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{10000}, 
{10000}, 
{10000}, 
{10000}, 
{10000}, 
{2000}, 
{2000}, 
{2000}, 
{2000}, 
{2000}, 
{2000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
} 
  
local fishAmount = { 
{100}, 
{100}, 
{100}, 
{100}, 
{100}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{140}, 
{150}, 
{160}, 
{170}, 
{180}, 
{190}, 
{200} 
} 
  
function unpackTimes() 
return unpack(fishTimes[math.random(#fishTimes)]) 
end 
  
function unpackAmounts() 
return unpack(fishAmount[math.random(#fishAmount)]) 
end 
  
addCommandHandler ( "startfish", 
function(player) 
fishing = true 
local timer = unpackTimes() 
if (getElementData(player, "Class") == "Fisherman") then 
if (fishingAllowed) then 
setPedAnimation ( player, "SWORD", "sword_IDLE") 
payTimer = setTimer( payPlayer, timer, 0 ,player) 
end 
end 
end 
)  
  
addCommandHandler ( "stopfish", 
function(player) ---Required Arguments player 
fishing = false 
setPedAnimation(player,false) 
if isTimer(payTimer) then 
killTimer(payTimer) 
payTimer = nil 
end  
end 
) 
  
function payPlayer(player) 
local amount = unpackAmounts() 
givePlayerMoney( player, amount ) 
resetTimer ( payTimer ) 
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 
) 
  
  
  
  
  
  
  
  
--Anti-AFK 
function afkCancler(player) 
if (fishing) then 
outputChatBox("You Have Been Automatically Stopped Recieving Fish To Prevent Afking, Please Do The Command Again To Start Again!!", source) 
setPedAnimation(source,false) 
if isTimer(payTimer) then 
killTimer(payTimer) 
payTimer = nil 
end  
end 
end 
setTimer( afkCancler, 600000, 0 ) 
Mibbit.com Pasted on 2013-01-12 21:55:02 

Link to comment
showFishignArea = createRadarArea ( 3122.1650390625, -2894.99829, 10000, 10000, 0, 255, 255, 100 ) 
fishingArea = createColRectangle ( 3122.1650390625, -2894.99829, 10000, 10000 ) 
fishingAllowed = { } 
  
local fishTimes = { 
{4000}, 
{4000}, 
{4000}, 
{4000}, 
{6000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{8000}, 
{10000}, 
{10000}, 
{10000}, 
{10000}, 
{10000}, 
{2000}, 
{2000}, 
{2000}, 
{2000}, 
{2000}, 
{2000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
{12000}, 
} 
  
local fishAmount = { 
{100}, 
{100}, 
{100}, 
{100}, 
{100}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{110}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{120}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{130}, 
{140}, 
{150}, 
{160}, 
{170}, 
{180}, 
{190}, 
{200} 
} 
payTimers = { } 
  
function unpackTimes() 
return unpack(fishTimes[math.random(#fishTimes)]) 
end 
  
function unpackAmounts() 
return unpack(fishAmount[math.random(#fishAmount)]) 
end 
  
addCommandHandler ( "startfish", 
function(player) 
fishing = true 
local timer = unpackTimes() 
if (getElementData(player, "Class") == "Fisherman") then 
if (fishingAllowed [ player ]) then 
setPedAnimation ( player, "SWORD", "sword_IDLE") 
payTimers [ player ] = setTimer ( payPlayer, timer, 0, player ) 
end 
end 
end 
) 
  
addCommandHandler ( "stopfish", 
function(player) ---Required Arguments player 
fishing = false 
setPedAnimation(player,false) 
if isTimer(payTimers [ player ]) then 
killTimer(payTimers [ player ]) 
payTimers [ player ] = nil 
end 
end 
) 
  
function payPlayer(player) 
local amount = unpackAmounts() 
givePlayerMoney( player, amount ) 
resetTimer ( payTimers [ player ] ) 
end 
  
addEventHandler ( "onColShapeHit", fishingArea, 
function( thePlayer ) 
if getElementType ( thePlayer ) == "player" then 
fishingAllowed [ thePlayer ] = true 
end 
end 
) 
  
addEventHandler ( "onColShapeLeave", fishingArea, 
function( thePlayer ) 
if getElementType ( thePlayer ) == "player" then 
fishingAllowed [ thePlayer ] = false 
end 
end 
) 
  
--Anti-AFK 
function afkCancler(player) 
if (fishing) then 
outputChatBox("You Have Been Automatically Stopped Recieving Fish To Prevent Afking, Please Do The Command Again To Start Again!!", source) 
setPedAnimation(source,false) 
if isTimer(payTimers [ player ]) then 
killTimer(payTimers [ player ]) 
payTimers [ player ] = nil 
end 
end 
end 
setTimer( afkCancler, 600000, 0 ) 

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...