seb-c

Untitled

Apr 22nd, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.45 KB | None | 0 0
  1. ----------------------------------------------------------------------------------------
  2. -- Author: Sebastian 'Seb' Cronberg
  3. -- Project Start Date: 22/04/12
  4. -- Project End Date: None Set
  5. -- Purpose: An ammunation shop, easy to modify.
  6. -- Progress: 5%
  7. -- Rights: Allowed to be edited if you have permission from the author.
  8. ----------------------------------------------------------------------------------------
  9. -- random variables
  10. local money = getPlayerMoney
  11. local cant_afford = "You can't afford this weapon, please come back when you have enough cash."
  12. -- below will give every weapon id a variable (easier for me ( the scripter ) to edit/add )
  13. local deagle = 24
  14. local silenced =23
  15. local colt = 22
  16. local uzi = 25
  17. local tec9 = 32
  18. local ak = 30
  19. local m4 = 31
  20. local satchel = 39
  21. local grande = 16
  22. local rpg = 36
  23. local spaz = 27
  24. local shotgun = 25
  25.  
  26. -- below will obviously set how much a weapon will cost.
  27.  
  28. local deagleCost = 2500
  29. local silencedCost = 850
  30. local coltCost = 850
  31. local uziCost = 1450
  32. ---Stopped here
  33. local tec9Cost = 1450
  34. local akCost = 2000
  35. local m4Cost = 2000
  36. local satchelCost = 5500
  37. local granadeCost = 5500
  38. local rpgCost = 100000
  39. local spazCost = 1500
  40. local shotgunCost = 1500
  41.  
  42. -- below will obviously set how much ammo the player should get when buying any weapon.
  43. local deagleAmmo = 150
  44. local silencedAmmo = 25
  45. local coltAmmo = 25
  46. local uziAmmo = 100
  47. local tecAMmo = 100
  48. local akAmmo = 150
  49. local m4Ammo = 150
  50. local satchelAmmo = 10
  51. local grandeAmmo = 10
  52. local rpgAmmo = 1
  53. local spazAmmo = 25
  54. local shotgunAmmo = 25
  55.  
  56.  
  57. local dglMsg = "You have purchased " ..deagleAmmo.. " shots of Deagle for $" ..deagleCost
  58. local silencedMsg = "You have purchased" ..silencedAmmo.. " shots of Silenced for $" ..silencedCost
  59. local coltMsg = "You have purchased " ..coltAmmo.. " shots of Colt for $" ..coltCost
  60. local uziMsg = "You have purchased " ..uziAmmo.. " shots of uzi for $" ..uziCost
  61.  
  62. -- below will create a table which will determinate which posx, posy and which it should have, also which interior and dimension.
  63.  
  64. local markers = {
  65.     -- { posx , posy , posz , interior , dimension } ,
  66.     { 207.48498535156 , -101.42776489258 , 1004.2578125 , 15 , 0 } ,
  67.     { 207.10119628906 , -130.03713989258 , 1002.5078125 , 3 , 0 } ,
  68.     { 204.33052062988 , -159.76615905762 , 999.5234375 , 14 , 0 } ,
  69.     { 161.4536895752 , -84.164611816406 , 1000.8046875 , 18 , 0 } ,
  70. }
  71.  
  72. -- below will create the markers and set the given posx, posy, posz, dimension and interior.
  73.  
  74. addEventHandler ( "onResourceStart" , resourceRoot ,
  75.     function ( )
  76.         for index , marker in pairs ( markers ) do
  77.             local wepMarker = createMarker ( marker [ 1 ] , marker [ 2 ] , marker [ 3 ] , "cylinder" , 1.5 , 255 , 255 , 0 , 255 )
  78.             setElementInterior ( wepMarker , marker [ 4 ] )
  79.             setElementDimension ( wepMarker , marker [ 5 ] )
  80.         end
  81.     end
  82. )
  83.  
  84.  
  85. addEvent ( "dglBuy", true )
  86. function dglBuy ()
  87.     if ( money (source) >= deagleCost ) then
  88.     giveWeapon ( client, deagle, deagleAmmo )
  89.     takePlayerMoney ( client, deagleCost )
  90.     outputChatBox ( dglMsg, client, 0, 255, 30, true )
  91.     else
  92.     outputChatBox ( cant_afford, client, 255, 0, 0, true )
  93.     end
  94. end
  95. addEventHandler ( "dglBuy", root, dglBuy )
  96.  
  97. addEvent ( "silencedBuy", true )
  98. function silencedBuy ()
  99.     if ( money (source) >= silencedCost ) then
  100.     giveWeapon ( client, silenced, silencedAmmo )
  101.     outputChatBox ( silencedMsg, client, 255, 255, 0, true )
  102.     else
  103.     outputChatBox ( cant_afford, client, 255, 0, 0, true )
  104.     end
  105. end
  106. addEventHandler ( "silencedBuy", root, silencedBuy )
  107.  
  108. addEvent ( "coltBuy", true )
  109. function coltBuy ()
  110.     if ( money (source) >= coltCost ) then
  111.     giveWeapon ( client, colt, coltAmmo )
  112.     outputChatBox ( coltMsg, client, 255, 255, 0, true )
  113.     else
  114.     outputChatBox ( cant_afford, client, 255, 0, 0, true )
  115.     end
  116. end
  117. addEventHandler ( "coltBuy", root, coltBuy )
  118.  
  119. addEvent ( "uziBuy", true)
  120. function uziBuy ()
  121.     if ( money (source) >= uziCost ) then
  122.     giveWeapon ( client, uzi, uziAmmo )
  123.     outputChatBox ( uziMsg, client, 255, 255, 0, true )
  124.     else
  125.     outputChatBox ( cant_afford, client, 255, 0, 0, true )
  126.     end
  127. end
  128. addEventHandler ( "uziBuy", root, uziBuy )
  129.  
  130. addEvent ( "tec9Buy", true )
  131. function tec9Buy ()
  132.     if ( money (source) >= tec9Cost ) then
  133.     giveWeapon ( client, tec9, tec9Ammo )
  134.     takePlayerMoney ( client, tec9Cost )
  135.     outputChatBox ( tec9Msg, client, 255, 255, 0, true)
  136.     else
  137.     otuputChatBox ( cant_afford, client, 255, 0, 0, true)
  138.      end
  139. end
  140. addEventHandler ( "tec9Buy", root, tec9Buy )
Advertisement
Add Comment
Please, Sign In to add comment