orcun99 Posted August 30, 2017 Share Posted August 30, 2017 (edited) for example: https://prnt.sc/gez70w the text turkish says: " press 'h' to open window" if player in marker then press k to open window I wanna my resources.. sorry for bad english 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, ["ALLAHU AKBAR"] = 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) 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) Edited August 30, 2017 by orcun99 Link to comment
ForLaXPy Posted August 30, 2017 Share Posted August 30, 2017 Try to merge those functions with your script 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) Link to comment
orcun99 Posted August 30, 2017 Author Share Posted August 30, 2017 7 minutes ago, ForLaXPy said: Try to merge those functions with your script 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) don't work is this server side right? Link to comment
ForLaXPy Posted August 30, 2017 Share Posted August 30, 2017 ye this is client sided as you can see in the events , but you can use addEventHandler( "onMarkerHit", . instread of addEventHandler("onClientMarkerHit", you will ned to use : getElementType( hitElement ) too Link to comment
orcun99 Posted August 30, 2017 Author Share Posted August 30, 2017 can u edit my full code pls? 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