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

Wysłany: 2019-12-15, 11:38


Fl!k







Wiek: 26
Na forum: 3733 dni
Posty: 162

Piwa: 18

Respekt: 50

Witam posiadam skrypt na kupno broni lecz gdy wchodze w marker wyskakuje gui wszyskim :/
client.lua
-- Enkanet Scripting Lab © 2015 - All rights are reserved.
local shopkeeper = createPed(179,269.01456, 2027.36646, 17.64063)
setElementFrozen(shopkeeper, true)
local weaponmarker = createMarker(268.99280, 2029.25427, 16.64063, 'cylinder', 2.0, 255, 0, 0, 150)
local player = getLocalPlayer()

function weaponGui ()
        local screenW, screenH = guiGetScreenSize()
        guiwindow = guiCreateWindow( 400, 250, 663, 162, "Weapon Shop System - Enkanet v1.0.0 [5.1.2015]", false)
        guiWindowSetSizable(guiwindow, false)

        button1 = guiCreateButton(10, 32, 164, 54, "Colt 45 - Ammo 200 \n$1250 \nBuy", false, guiwindow)
        button2 = guiCreateButton(184, 32, 164, 54, "Desert Eagle - Ammo 200 \n$1750\nBuy", false, guiwindow)
        button3 = guiCreateButton(358, 32, 164, 54, "M4 - Ammo 200 \n$3000\nBuy", false, guiwindow)
        button4 = guiCreateButton(529, 32, 124, 54, "Sniper - Ammo 200 \n$7000\nBuy", false, guiwindow)
        button5 = guiCreateButton(10, 101, 164, 42, "Close", false, guiwindow)
        addEventHandler("onClientGUIClick", button5, btnClose, false)
        addEventHandler("onClientGUIClick", button1, btnColt, false)
        addEventHandler("onClientGUIClick", button2, btnDeagle, false)
        addEventHandler("onClientGUIClick", button3, btnM4, false)
        addEventHandler("onClientGUIClick", button4, btnSniper, false)
end
addEventHandler("onClientResourceStart", getRootElement(), weaponGui)
addEventHandler("onClientResourceStart", getRootElement(), function() guiSetVisible(guiwindow, false) end)

function markerhit (player, weaponmarker)
    guiSetVisible(guiwindow, true)
    showCursor(true)
end
addEventHandler("onClientMarkerHit", weaponmarker, markerhit)

function btnClose(button5)
    guiSetVisible(guiwindow, false)
    showCursor(false)
end

function btnColt(button1, thePlayer)
    local money = getPlayerMoney(thePlayer)
    if (money > 1250) or (money == 1250) then
        triggerServerEvent("giveweaponPistol", root)
    else
        outputChatBox("You can't afford to buy this Colt 45", 255, 0,0)    
    end
end

function btnDeagle(button2, thePlayer)
    local money = getPlayerMoney(thePlayer)
    if (money > 1750) or (money == 1750) then
        triggerServerEvent("giveweaponDeagle", root)
    else
        outputChatBox("You can't afford to buy this Desert Eagle", 255, 0,0)    
    end
end

function btnM4(button3, thePlayer)
    local money = getPlayerMoney(thePlayer)
    if (money > 3000) or (money == 3000) then
        triggerServerEvent("giveweaponM4", root)
    else
        outputChatBox("You can't afford to buy this M4", 255, 0,0)    
    end
end

function btnSniper(button4, thePlayer)
    local money = getPlayerMoney(thePlayer)
    if (money > 7000) or (money == 7000) then
        triggerServerEvent("giveweaponSniper", root)
    else
        outputChatBox("You can't afford to buy this Sniper", 255, 0,0)    
    end
end
-- Enkanet Scripting Lab © 2015 - All rights are reserved.


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-15, 12:43


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Sprawd? czy gracz, kt?ry wszed? w marker to lokalny gracz (localPlayer lub getLocalPlayer()).

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-15, 14:52


Fl!k







Wiek: 26
Na forum: 3733 dni
Posty: 162

Piwa: 18

Respekt: 50

No to jest tutaj localplayer:
-- Enkanet Scripting Lab © 2015 - All rights are reserved.
local shopkeeper = createPed(179,269.01456, 2027.36646, 17.64063)
setElementFrozen(shopkeeper, true)
local weaponmarker = createMarker(268.99280, 2029.25427, 16.64063, 'cylinder', 2.0, 255, 0, 0, 150)
local player = getLocalPlayer()


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-15, 15:28


BlueCry

ŚĆRIPTER LUJA






Wiek: 25
Na forum: 4147 dni
Posty: 78
Nick w MP: BlueCry

Piwa: 2178

Respekt: 110
Respekt: 110

Podmie?
function markerhit (player, weaponmarker)
    guiSetVisible(guiwindow, true)
    showCursor(true)
end
addEventHandler("onClientMarkerHit", weaponmarker, markerhit)

Na
addEventHandler("onClientMarkerHit", weaponmarker, function(el,md)
        if el==localPlayer then
 guiSetVisible(guiwindow, true)
    showCursor(true)
end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-15, 16:09


Fl!k







Wiek: 26
Na forum: 3733 dni
Posty: 162

Piwa: 18

Respekt: 50

Dzieki juz dzia?a tylko teraz jest problem z tym ze jak kupisz bron to kazy to widzi i kazy ja dostaje a nie tylko dana osoba :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-12-15, 16:19


Wilq







Wiek: 24
Na forum: 4570 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Triggeruj event (triggerServerEvent) tylko dla lokalnego gracza, a nie wszystkich (u siebie masz root w kodzie). Mo?e teraz sam co? zrobisz? :mrgreen:
Rozwi?zanie podane:

Więcej informacji znajdziesz w Wikipedii MTA:

triggerServerEvent


Postaw piwo autorowi tego posta
 

 
Tagi: 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 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