• Weapon Selection Menu
    5 replies, posted
I am currently making a Weapon Selection Menu for DarkRP, everything is working great except one problem, i don't know how to detect if a player is scrolling or not, i want scroll up to run ScrollWepMenuUp() and down to ScrollWepMenuDown() I will also have keys for selecting the weapon slots. But first scrolling. Thanks for any help given
Use GM/PlayerBindPress (scroll up/down are binded to invnext/invprev). You can check how I used those binds to make a weapon selection system here.
Wow, that helped a lot! Thank you so much. Quick question though, how would i get the exact weapon i am "hovering" over in the selection? any good ways that is (good meaning simple) Thanks!
iCurPos represents the position in the tCache[iCurSlot] table currently selected. That means if you're looping through to draw all weapons in a particular slot, you'd check if iCurPos == i where i represents the weapon's index number. Example with your code: -- Placeholder surface.CreateFont("LequidFontBold_22", {}) local BOX_HEIGHT = 20 local BOX_WIDTH = 250 local BOX_HALF_WIDTH = BOX_WIDTH / 2 local BOX_CORNER_RADIUS = 10 local colTitleBox = Color(0, 150, 0, 150) local colTitleText = Color(255, 255, 255, 170) local colTitleTextOutline = Color(0, 255, 255, 5) local colLabelBox = Color(80, 80, 80, 150) local colLabelTextActive = Color(0, 255, 255, 255) local colLabelTextInactive = Color(255, 255, 255, 255) local colLabelTextOutline = Color(0, 255, 255, 5) local function DrawWeaponHUD() local x = ScrW() - BOX_WIDTH local y = ScrH() / 4 draw.SimpleTextOutlined("Slot " .. iCurSlot, "LequidFontBold_22", x + BOX_HALF_WIDTH, y, colTitleText, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 0, colTitleTextOutline) draw.RoundedBoxEx(BOX_CORNER_RADIUS, x, y, BOX_WIDTH, BOX_HEIGHT, colTitleBox, true, false, false, false) local tSlot = tCache[iCurSlot] local uSlotWeapons = tCacheLength[iCurSlot] local pSelectedWeapon = tCache[iCurPos] local pPlayer = LocalPlayer() local colDraw = colLabelTextInactive if (pPlayer:IsValid()) then local pActiveWeapon = pPlayer:GetActiveWeapon() if (pActiveWeapon:IsValid() and pActiveWeapon == pSelectedWeapon) then colDraw = colLabelTextActive end end for i = 1, uSlotWeapons do local pWeapon = tSlot[i] if (pWeapon:IsValid()) then y = y + BOX_HEIGHT draw.SimpleTextOutlined(pWeapon:GetPrintName() or "Invalid", "LequidFontBold_22", x + BOX_HALF_WIDTH, y, iCurPos == i and colLabelTextActive or colLabelTextInactive, TEXT_ALIGN_CENTER, TEXT_ALIGN_TOP, 0, colLabelTextOutline) draw.RoundedBoxEx(BOX_CORNER_RADIUS, x, y, BOX_WIDTH, BOX_HEIGHT, colLabelBox, false, false, false, false) end end end
Thank you, you helped a lot! I don't know how to up vote or +rep you so i cant but if i did i would! Thank you again so much!
You can send them a coin on their posts
Sorry, you need to Log In to post a reply to this thread.