Zaloguj się by uzyskać pełen dostęp. Nie masz jeszcze konta? Założ je już teraz w kilka sekund.

Wysłany: 2020-11-01, 17:31


kazet12383







Wiek: 30
Na forum: 2199 dni
Posty: 14
Nick w MP: toja



Respekt: 50

Mam zrobiony darkshop i jest on niezla amatorka przerobiona przeze mnie... i problem odkrylem dzis taki, ze jak zaladuje sobie obojetne jakie gui np. F1 XD i nacisne w miejsce, w ktorym mam "kup teraz" w darkshopie... to zakupie sobie bron, i tak przy uzyciu kazdego gui... Jak to naprawic?


Client
 --[[
    Author:Ramper
    All rights resived!
]]

local t=createElement('text')
setElementData(t,'name','Dark Shop \nWcisnij F3 by kupic bron!')
setElementDimension(t0)
setElementInterior(t0)
setElementPosition(t,-1684.261062.2616.59)

local screenWscreenH guiGetScreenSize()
local marker1 createMarker(-1684.261062.2615.59"cylinder"1.53514235)
local sx,sy=guiGetScreenSize()

function isMouseIn(psx,psy,pssx,pssy,abx,aby)
    if not isCursorShowing() then return end
    cx,cy=getCursorPosition()
    cx,cy=cx*sx,cy*sy
    if cx >= psx and cx <= psx+pssx and cy >= psy and cy <= psy+pssy then
        return true,cx,cy
    else
        return false
    end
end

function draw ()
    dxDrawRectangle(screenW 0.3547screenH 0.0533screenW 0.2906screenH 0.8933tocolor(300222), false)
    dxDrawImage(screenW 0.3547screenH 0.0783screenW 0.0641screenH 0.0467"AK47.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3531screenH 0.1417screenW 0.6461screenH 0.1417tocolor(191773222), 1false)
    dxDrawText("AK-47 - niezbednik kazdego porzadnego napastnika Koszt:5000zl"screenW 0.4281screenH 0.0650screenW 0.5531screenH 0.1333tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
   if not isMouseIn(screenW 0.5586screenH 0.0733screenW 0.0789screenH 0.0517then   dxDrawRectangle(screenW 0.5586screenH 0.0733screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else  dxDrawRectangle(screenW 0.5586screenH 0.0733screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.0800screenW 0.6375screenH 0.1167tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3547screenH 0.1583screenW 0.0656screenH 0.0467"Rifle.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3531screenH 0.2283screenW 0.6461screenH 0.2283tocolor(191773222), 1false)
    dxDrawText("MP5 - poreczna i szybkostrzelna.Koszt:3500zl"screenW 0.4250screenH 0.1567screenW 0.5555screenH 0.2217tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
    if not isMouseIn(screenW 0.5586screenH 0.1567screenW 0.0789screenH 0.0517then dxDrawRectangle(screenW 0.5586screenH 0.1567screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.1567screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.1683screenW 0.6375screenH 0.2050tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3547screenH 0.2517screenW 0.0656screenH 0.0367"Sniper.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3547screenH 0.3050screenW 0.6477screenH 0.3050tocolor(191773222), 1false)    
    dxDrawText("Snajperka - i plan nabiera nowego znaczenia!. \nKoszt:10000zl"screenW 0.4250screenH 0.2283screenW 0.5555screenH 0.2933tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
     if not isMouseIn(screenW 0.5586screenH 0.2417screenW 0.0789screenH 0.0517then dxDrawRectangle(screenW 0.5586screenH 0.2417screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.2417screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.2517screenW 0.6375screenH 0.2883tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3531screenH 0.3100screenW 0.0406screenH 0.0550"Mac10.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3547screenH 0.3817screenW 0.6477screenH 0.3817tocolor(191773222), 1false)
    dxDrawText("Deagle - poreczny, zmiesci sie wszedzie! \nKwota:1500zl"screenW 0.4250screenH 0.3050screenW 0.5555screenH 0.3700tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
     if not isMouseIn(screenW 0.5586screenH 0.3217screenW 0.0789screenH 0.0517then dxDrawRectangle(screenW 0.5586screenH 0.3217screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.3217screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.3283screenW 0.6375screenH 0.3650tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3547screenH 0.4050screenW 0.0672screenH 0.0333"Shotgun.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3547screenH 0.4550screenW 0.6477screenH 0.4550tocolor(252005222), 1false) 
    dxDrawText("Bron niedostepna!"screenW 0.4250screenH 0.3817screenW 0.5555screenH 0.4467tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
    if not isMouseIn(screenW 0.5586screenH 0.3950screenW 0.0789screenH 0.0517then dxDrawRectangle(screenW 0.5586screenH 0.3950screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.3950screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.4017screenW 0.6375screenH 0.4383tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3555screenH 0.4783screenW 0.0617screenH 0.0417"Spas12.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3523screenH 0.5283screenW 0.6453screenH 0.5283tocolor(191773222), 1false)
    dxDrawText("Bron niedostepna!"screenW 0.4250screenH 0.4550screenW 0.5555screenH 0.5200tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
      if not isMouseIn(screenW 0.5586screenH 0.4683screenW 0.0789screenH 0.0517then  dxDrawRectangle(screenW 0.5586screenH 0.4683screenW 0.0789screenH 0.0517tocolor(191773222), false)
     else dxDrawRectangle(screenW 0.5586screenH 0.4683screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.4750screenW 0.6375screenH 0.5117tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3547screenH 0.5367screenW 0.0695screenH 0.0417"Bat.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3523screenH 0.5950screenW 0.6453screenH 0.5950tocolor(191773222), 1false)
    dxDrawText("Bron niedostepna!"screenW 0.4250screenH 0.5300screenW 0.5555screenH 0.5950tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
   if not isMouseIn(screenW 0.5586screenH 0.5367screenW 0.0789screenH 0.0517then dxDrawRectangle(screenW 0.5586screenH 0.5367screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.5367screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.5417screenW 0.6375screenH 0.5783tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3570screenH 0.6117screenW 0.0602screenH 0.0400"Knife.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3523screenH 0.6683screenW 0.6453screenH 0.6683tocolor(191773222), 1false)
    dxDrawText("Bron niedostepna!"screenW 0.4250screenH 0.5950screenW 0.5555screenH 0.6600tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
   if not isMouseIn(screenW 0.5586screenH 0.6050screenW 0.0789screenH 0.0517then  dxDrawRectangle(screenW 0.5586screenH 0.6050screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.6050screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.6117screenW 0.6375screenH 0.6483tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3563screenH 0.6833screenW 0.0688screenH 0.0467"Katana.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3523screenH 0.7400screenW 0.6453screenH 0.7400tocolor(191773222), 1false)
    dxDrawText("Bron niedostepna!"screenW 0.4250screenH 0.6750screenW 0.5555screenH 0.7400tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
    if not isMouseIn(screenW 0.5586screenH 0.6767screenW 0.0789screenH 0.0517then dxDrawRectangle(screenW 0.5586screenH 0.6767screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.6767screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.6850screenW 0.6375screenH 0.7217tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
    dxDrawImage(screenW 0.3570screenH 0.7567screenW 0.0719screenH 0.0433"Shovel.png"000tocolor(255255255255), false)
    dxDrawLine(screenW 0.3523screenH 0.8167screenW 0.6453screenH 0.8167tocolor(191773222), 1false)
    dxDrawText("Bron niedostepna!"screenW 0.4250screenH 0.7517screenW 0.5555screenH 0.8167tocolor(255255255255), 1.00"default""center""center"falsetruefalsefalsefalse)
   if not isMouseIn(screenW 0.5586screenH 0.7567screenW 0.0789screenH 0.0517then dxDrawRectangle(screenW 0.5586screenH 0.7567screenW 0.0789screenH 0.0517tocolor(191773222), false)
    else dxDrawRectangle(screenW 0.5586screenH 0.7567screenW 0.0789screenH 0.0517tocolor(252005222), falseend
    dxDrawText("Kup"screenW 0.5594screenH 0.7633screenW 0.6375screenH 0.8000tocolor(255255255255), 1.00"default""center""center"falsefalsefalsefalsefalse)
end

addEventHandler("onClientMarkerHit"marker1, function(hitPlayer)
    if (localPlayer == hitPlayerthen
        addEventHandler("onClientRender"rootdraw)
    end
end)
addEventHandler "onClientMarkerLeave"marker1, function(leftPlayer)
if(localPlayer == leftPlayerthen
removeEventHandler("onClientRender"rootdraw)
end
end)
addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.0733screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("ak47"localPlayer, function()
end)
end
end
end)

addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.1567screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("MP5"localPlayer, function()
end)
end
end
end)addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.2417screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("snipe"localPlayer, function()
end)
end
end
end)
addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.3217screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("deagle"localPlayer, function()
end)
end
end
end)
addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.4683screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("spa"localPlayer, function()
end)
end
end
end)
addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.5367screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("base"localPlayer, function()
end)
end
end
end)
addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.6050screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("knife"localPlayer, function()
end)
end
end
end)
addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.6767screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("katana"localPlayer, function()
end)
end
end
end)
addEventHandler("onClientClick"root, function(btn,state)
    local screenWscreenH guiGetScreenSize()
    if btn=="left" and state=="down" then
        if isMouseIn(screenW 0.5586screenH 0.7567screenW 0.0789screenH 0.0517)  then
        triggerServerEvent("shovel"localPlayer, function()
end)
end
end
end




Server
--[[
    Author:Ramper
    All rights resived!
]]
addEvent("ak47"true)
addEventHandler("ak47"root, function()
local hajs =getPlayerMoney(source)
if hajs<500000 then
outputChatBox("Nie sta?&#8225; ci?&#8482; na to!"source,255,255,255)
else
giveWeapon (source3060)
takePlayerMoney(source,500000)
outputChatBox("Zakupi?&#8218;e?&#8250;/a?&#8250; bro?&#8222; AK-47"source,255,255,255)
end
end)

addEvent("MP5"true)
addEventHandler("MP5"root, function()
local hajs =getPlayerMoney(source)
if hajs<350000 then
outputChatBox("Nie sta?&#8225; ci?&#8482; na to!"source,255,255,255)
else
giveWeapon (source2990)
takePlayerMoney(source,350000)
outputChatBox("Zakupi?&#8218;e?&#8250;/a?&#8250; bro?&#8222; MP5"source,255,255,255)
end
end)

addEvent("snipe"true)
addEventHandler("snipe"root, function()
local hajs =getPlayerMoney(source)
if hajs<1000000 then
outputChatBox("Nie sta?&#8225; ci?&#8482; na to!"source,255,255,255)
else
giveWeapon (source3410)
takePlayerMoney(source,1000000)
outputChatBox("Zakupi?&#8218;e?&#8250;/a?&#8250; bro?&#8222; Snipe"source,255,255,255)
end
end)

addEvent("deagle"true)
addEventHandler("deagle"root, function()
local hajs =getPlayerMoney(source)
if hajs<15000 then
outputChatBox("Nie sta?&#8225; ci?&#8482; na to!"source,255,255,255)
else
giveWeapon (source2414)
takePlayerMoney(source,15000)
outputChatBox("Zakupi?&#8218;e?&#8250;/a?&#8250; bro?&#8222; Deagle"source,255,255,255)
end
end)


  
function zapiszBron(graczkonto) 
if gracz and konto then 
    for i=0,12 do 
        local bron getPedWeapon(graczi) 
        local amunicja getPedTotalAmmo(graczi) 
        setAccountData(konto,"bronKonto"..tonumber(i), bron) 
        setAccountData(konto,"amunicjaKonto"..tonumber(i), amunicja) 
    end 
    takeAllWeapons(gracz) 
    end 
end 
  
addEventHandler("onPlayerQuit",root,function () zapiszBron(sourcegetPlayerAccount(source)) endaddEventHandler("onPlayerLogout",root,function(prevzapiszBron(sourceprevend) 
  
addEventHandler("onPlayerLogin",root, 
function () 
    local konto getPlayerAccount(source) 
    if not konto or isGuestAccount(kontothen return end 
    for i=0,12 do 
        local bron getAccountData(konto,"bronKonto"..tonumber(i)) 
        local amunicja getAccountData(konto,"amunicjaKonto"..tonumber(i)) 
        if bron and amunicja then 
            setTimer(giveWeapon10001sourcetonumber(bron), tonumber(amunicja), true) 
        end 
    end 
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-11-01, 19:32


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

W ka?dym evencie onClientClick musisz sprawdza? czy GUI jest rysowane, lub czy gracz jest w markerze -

Więcej informacji znajdziesz w Wikipedii MTA:

isElementWithinMarker


Abstrahuj?c - po co robisz wi?cej ni? 1 event onClientClick, skoro w jednej funkcji podpi?tej pod jeden event mo?esz zrobi? kilka warunk?w z funkcj? isMouseInPosition? Zb?dny kod.
Tak samo eventy po serwerze, zr?b jeden i w argumencie funkcji pod eventem wprowadzaj zmienn? decyduj?c? o zakupie broni.

Postaw piwo autorowi tego posta
 

 
Tagi: zly :: kod :: dostosowuje :: sie :: pod :: kazde :: gui.
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Zly kod - dostosowuje sie pod kazde gui. Odpowiedz do tematu

Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach
Dodaj temat do Ulubionych
Wersja do druku