Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function BuyCommand(PlayerID, ...)
- local ItemName = table.concat(arg, " ")
- local ItemID = (arg[1]) and getItemID(ItemName)
- local ItemPrice, ItemAreas, ItemMaxAmount
- if ItemID then
- ItemPrice = getItemPrice(ItemID)
- ItemAreas = getItemAreas(ItemID)
- ItemMaxAmount = getItemMaxAmount(ItemID)
- end
- local PlayerCash = mgGetPlayerCash(PlayerID)
- local PlayerArea = getPlayerArea(PlayerID)
- local PlayerItemAmount = getPlayerItemAmount(PlayerID, ItemID)
- if not ItemName then
- -- type item name!
- elseif not ItemID then
- -- item not found man!
- elseif PlayerCash < ItemPrice then
- -- not enuf cash
- elseif isPlayerSpawned(PlayerID) == 0 or not vinTable(ItemAreas, PlayerArea) then
- -- not in the right area to buy this item!
- elseif PlayerItemAmount == ItemMaxAmount then
- -- cant buy anymore!
- else
- -- valid
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement