Advertisement
NanoBob

Weapon storage code

Jul 31st, 2015
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. function cabinetUsed(key,old)
  2.     local objectWithData=getElementAttachedTo(source)
  3.     if objectWithData==nil or objectWithData==false then return end
  4.     if objects[objectWithData]==nil then return end
  5.     if objects[objectWithData].cabinetUsed==false then return end
  6.     local new=getElementData(source,key)
  7.     if weapons[key]==nil then
  8.         removeEventHandler("onElementDataChange",source,cabinetUsed)
  9.         for _,player in pairs(getElementsByType("player")) do
  10.             if getElementData(player,"currentCol")==source then
  11.                 if old==false or old==nil then
  12.                     old=0
  13.                 end
  14.                 setTimer(setElementData,200,1,player,key,getElementData(player,key))
  15.                 break
  16.             end
  17.         end
  18.         setElementData(source,key,old)
  19.         addEventHandler("onElementDataChange",source,cabinetUsed)
  20.     end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement