Advertisement
NanoBob

Fishing job

Mar 19th, 2014
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.21 KB | None | 0 0
  1. function startFishingJob(player)
  2.     x=math.random(0,750)
  3.     y=math.random(0,750)
  4.     fishingMarker=createMarker(x-3000,y-3750,0,"cylinder",30,0,0,120,150)
  5.     sellFishMarker=createMarker(0,0,0,"cylinder",2,0,0,120,150)
  6.     outputChatBox("Go to the marked fishing spot and go do some fishing")
  7.     addEventHandler("onMarkerHit",fishingMarker,
  8.         function(player)
  9.             if player==getLocalPlayer() and getElementData(player,"playerType")=="fisherman" then
  10.                 vehicle=getPedOccupiedVehicle(player)
  11.                 if vehicle~=false then
  12.                     setElementFrozen(vehicle,true)
  13.                     setElementData(getLocalPlayer(),"playerFishingBoat",vehicle,true)
  14.                     setElementData(getLocalPlayer(),"isFishing",true,true)             
  15.                 end
  16.             end
  17.         end)
  18.     addEventHandler("onMarkerHit",sellFishmarker,
  19.         function(player)
  20.             if player==getLocalPlayer() and getElementData(getLocalPlayer(),"ammountOfFish")>0 then
  21.                 fishes=getElementData(getLocalPlayer(),"ammountOfFish")
  22.                 fishMoney=fishes*math.random(1,25)
  23.                 setElementData(getLocalPlayer(),"FGNMoney",getElementData(getLocalPlayer(),"FGNMoney")+fishMoney)
  24.                 setElementData(getLocalPlayer(),"ammountOfFish",0)
  25.                
  26.             end
  27.         end)
  28.    
  29. end
  30.  
  31. function checkFishingProgress()
  32.     fishingProgress=getElementData(getLocalPlayer,()"fishingProgress")
  33.     if fishingProgress<100 then
  34.         fishingProgress=fishingProgress+10
  35.         setElementData(getLocalPlayer(),"fishingProgress",fishingProgress)
  36.     else
  37.         boat=getElementData(getLocalPlayer(),"playerFishingBoat")
  38.         setElementFrozen(boat,false)
  39.         ammountOfFish=getElementData(getLocalPlayer(),"ammountOfFish")
  40.         if ammountOfFish==false then
  41.             ammountOfFish=0
  42.         end
  43.         fishCaught=math.random(0,100)
  44.         ammountOfFish=ammountOfFish+fishCaught
  45.         setElementData(getLocalPlayer(),"ammountOfFish",ammountOfFish)
  46.         if fishCaught==0 then
  47.             outputChatBox("You caught no fish at all!",100,0,0)
  48.         else
  49.             outputChatBox("You caught "..ammountOfFish.." fish!",100,0,0)
  50.         end
  51.         destroyElement(fishingMarker)
  52.         destroyElement(sellFishMarker)
  53.         startFishingJob(getLocalPlayer())
  54.        
  55.     end
  56. end
  57.  
  58. function stopFishingJob()
  59.     destroyElement(fishingMarker)
  60.     destroyElement(sellFishMarker)
  61.     outputChatBox("Your job has been canceled",255,0,0)
  62. end
  63.  
  64. function playerEnteredBoat(vehicle,seat)
  65.     player=source
  66.     if getElementModel(vehicle)==453 and getElementData(player,"playerType")=="fisherman" then
  67.         startFishingJob(player)
  68.     end
  69. end
  70. addEventHandler("onPlayerVehicleEnter",getRootElement(),playerEnteredBoat)
  71.  
  72. function drawFishingStuff()
  73.     screenx,screeny=guiGetScreenSize()
  74.     if getElementData(player,"isFishing") then
  75.         dxDrawRectangle(screenx*0.05-5,screeny*0.4-5,310,60,tocolor(255,255,255,100),true)
  76.         dxDrawRectangle(screenx*0.05,screeny*0.4,getElementData(getLocalPlayer(),"fishingProgress")*3,50,tocolor(255,255,255,100),true)
  77.     end
  78.     if getElementData(player,"playerType")=="fisherman" then
  79.         dxDrawRectangle(screenx*0.9,screeny*0.4,screenx*0.1,screeny*0.1,tocolor(200,200,200,150),true)
  80.         dxDrawImage(screenx*0.94,screeny*0.405,screenx*0.08,screeny*0.04,"images/fish.png")
  81.         dxDrawText(math.floor(getElementData(getLocalPlayer(),"ammountOfFish")+0.5),screenx*0.91,screeny*0.425,screenx,screeny,tocolor(0,0,0,255),2,"default")     
  82.     end
  83. end
  84. addEventHandler("onClientRender",getRootElement(),drawFishingStuff)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement