orcun99 Posted September 10, 2017 Share Posted September 10, 2017 Hi I wanna press H to open marker this resource I try but I can't do .. someone can give me full code ? client.lua local currentSeller = false local sellAble = { {22, 30, 150}, {16, 1, 500}, {25, 16, 250}, {26, 10, 250}, {32, 150, 350}, {28, 150, 400}, {30, 150, 2000}, {31, 150, 2000}, {33, 20, 600}, {34, 20, 4000}, {27, 20, 1000}, {24, 20, 1000}, {29, 120, 1000}, {1, 1, 300}, {10, 1, 250}, {5, 1, 250}, {6, 1, 150} } function startSale(seller) currentSeller = seller exports.xcommands:sendClientMessage("Senin Satıcın ".. getPlayerName(seller), 0,255,0) ammugui = guiCreateWindow(0.39, 0.28, 0.30, 0.52, "Silah Satıcısı", true) guiWindowSetMovable(ammugui, false) guiWindowSetSizable(ammugui, false) label = guiCreateLabel(0.02, 0.06, 0.96, 0.10, "Almak İstediğin silaha tıkla", true, ammugui) guiLabelSetHorizontalAlign(label, "center", false) gridlist = guiCreateGridList(0.07, 0.10, 0.86, 0.76, true, ammugui) weapongrid = guiGridListAddColumn(gridlist, "Silah", 0.4) ammogrid = guiGridListAddColumn(gridlist, "Cephane", 0.3) pricegrid = guiGridListAddColumn(gridlist, "Fiyat", 0.2) buy = guiCreateButton(0.07, 0.89, 0.39, 0.09, "Satın Al", true, ammugui) guiSetProperty(buy, "NormalTextColour", "FFAAAAAA") close = guiCreateButton(0.54, 0.89, 0.39, 0.09, "Kapat", true, ammugui) guiSetProperty(close, "NormalTextColour", "FFAAAAAA") for i, v in ipairs(sellAble) do local id = v[1] local ammo = v[2] local price = math.floor(v[3]/1.5) local name = getWeaponNameFromID(id) if name then row = guiGridListAddRow ( gridlist ) guiGridListSetItemText (gridlist, row, weapongrid, name, false, false ) guiGridListSetItemData (gridlist, row, weapongrid, i) guiGridListSetItemText (gridlist, row, ammogrid, ammo, false, true ) guiGridListSetItemData (gridlist, row, ammogrid, ammo) guiGridListSetItemText (gridlist, row, pricegrid, price, false, true ) guiGridListSetItemData (gridlist, row, pricegrid, price) end end showCursor(true) addEventHandler('onClientGUIClick', ammugui, onClientClick) end addEvent("letThemBuy", true) addEventHandler("letThemBuy", localPlayer, startSale) function onClientClick() if source == close then destroyElement(ammugui) showCursor(false) elseif source == buy then if guiGridListGetSelectedCount(gridlist) > 0 then local row = guiGridListGetSelectedItem(gridlist) local index = tonumber(guiGridListGetItemData(gridlist, row, weapongrid)) local wepid = sellAble[index][1] local ammo = sellAble[index][2] local price = math.floor(sellAble[index][3]/1.5) local name = getWeaponNameFromID(wepid) if getPlayerMoney(getLocalPlayer()) > price or getPlayerMoney(getLocalPlayer()) == price then triggerServerEvent("sellWep", getLocalPlayer(), getLocalPlayer(),wepid,ammo,price, currentSeller) exports.xcommands:sendClientMessage('Başarılı Bir Şekilde aldın '..name, 0,255,0) else exports.xcommands:sendClientMessage('Bu kadar para $'..price.." lazım satın almak için "..name,255,0,0) end end end end server.lua local markers = { } local allowedClasses = { ["Comando_da_Capital HQ"] = true, ["Comando_Da_Capital"] = true, ["Silah Satıcısı"] = true, ["Triads"] = true, ["Soyguncu"] = true, ["Arms_Assassins"] = true } local allowedTeams = {["The Confederate States Army"] = true} function getPositionInfront(element) local x, y, z = getElementPosition ( element ) local a,b,r = getElementRotation ( element ) x = x - math.sin ( math.rad(r) ) * 2 y = y + math.cos ( math.rad(r) ) * 2 return x,y,z end function startSelling(seller) if allowedClasses[getElementData(seller, "class")] or allowedTeams[getTeamName(getPlayerTeam(seller))] then if not markers[seller] and not isPedInVehicle(seller) and not getElementData(seller, "jailed") then --and isPedOnGround(seller) then setElementFrozen(seller, true) local x,y,z = getPositionInfront(seller) markers[seller] = createMarker(x, y, z-1.2, "cylinder", 1.5, 30, 0, 0) addEventHandler("onMarkerHit", markers[seller], newBuyer) setElementData(markers[seller], "armsOwner", seller) setPedAnimation(seller, "DEALER", "DEALER_IDLE", -1, true, false) bindKey(seller, "W", "down", stopSelling, seller) exports.xcommands:sendMessage("Şuan Silah Satıyorsun bozmak için W'ye bas", 255, 255, 255, seller) end end end addCommandHandler("sat", startSelling) function stopSelling(seller) setElementFrozen(seller, false) setPedAnimation(seller) unbindKey(seller, "W", "down", stopSelling) destroyElement(markers[seller]) markers[seller] = nil end function newBuyer(buyer, dim) if dim and getElementType(buyer) == "player" and getElementData(source, "armsOwner") ~= buyer then triggerClientEvent(buyer, "letThemBuy", buyer, getElementData(source, "armsOwner")) end end function givePlayerWeapon(thePlayer, wepid,ammo,price,seller) if isElement(thePlayer) then exports.xcommands:takeMoney(thePlayer, price) exports.xcommands:giveMoney(seller, price /2) giveWeapon(thePlayer, wepid, ammo, true) exports.xcommands:sendMessage(getPlayerName(thePlayer) .." cephane ".. ammo .." ".. getWeaponNameFromID(wepid) .." için $".. fiyat, 255, 255, 255, seller) end end addEvent('sellWep', true) addEventHandler('sellWep', getRootElement(), givePlayerWeapon) local isWithinMarker = false local marker = createMarker(x, y, z, "cylinder") --The Marker addEventHandler("onClientMarkerHit", marker, function(player, sameDimension) if player == localPlayer and sameDimension then isWithinMarker = true end end) addEventHandler("onClientMarkerLeave", marker, function(player, sameDimension) if player == localPlayer and sameDimension then isWithinMarker = false end end) bindKey("k", "down", function() if isWithinMarker then guiSetVisible(ammugui,true) showCursor(true) end end) function onQuit() if isElement(markers[source]) then destroyElement(markers[source]) unbindKey(source, "W", "down", destroy) markers[source] = nil end end addEventHandler("onPlayerWasted", root, onQuit) addEventHandler("onPlayerLogout", root, onQuit) addEventHandler("onPlayerQuit", root, onQuit) Link to comment
DNL291 Posted September 10, 2017 Share Posted September 10, 2017 bindKey( "h", "down", function() if isElement(ammugui) and guiGetVisible(ammugui) then destroyElement( ammugui ) showCursor( false ) elseif not isElement(ammugui) then startSale() end end ) Try that. Link to comment
orcun99 Posted September 11, 2017 Author Share Posted September 11, 2017 7 hours ago, DNL291 said: bindKey( "h", "down", function() if isElement(ammugui) and guiGetVisible(ammugui) then destroyElement( ammugui ) showCursor( false ) elseif not isElement(ammugui) then startSale() end end ) Try that. I add this code client side but still if someone in marker then gui open but when I press h gui is closed Link to comment
DNL291 Posted September 11, 2017 Share Posted September 11, 2017 If you don't want it to work with marker, then just remove it from the code and all codes related to the marker as well. Link to comment
orcun99 Posted September 12, 2017 Author Share Posted September 12, 2017 I want if player with in marker dxdrawtext : Press H to open marker and when player press H open gui Link to comment
DNL291 Posted September 13, 2017 Share Posted September 13, 2017 Use addEventHandler + "onClientRender" when player hits the marker in order to keep the text visible. And removeEventHandler when player leaves the mark or when player opens the window. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now