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

Wysłany: 2017-08-29, 03:11


Avenged

Młodszy Szkrypter






Wiek: 24
Na forum: 3651 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1572

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

A wi?c po stronie klienta mam takie co?:
addEventHandler("onClientClick", root, function(b, s)
  if b ~= "state" and s ~= "down" then return end
  if mysz(screenW * 0.44, screenH * 0.50, screenW * 0.12, screenH * 0.05) then
    triggerServerEvent("zaloguj_psp", localPlayer)
  elseif mysz(screenW * 0.44, screenH * 0.58, screenW * 0.13, screenH * 0.05) then
    triggerServerEvent("wyloguj_psp", localPlayer)
  end
end)


Strona servera:
function zaloguj (source)
local theTeam = createTeam ( PSP )
  if theTeam then                      
    setPlayerTeam ( source, PSP)  
end
end
addEvent( "zaloguj_psp", true )
addEventHandler( "zaloguj_psp", resourceRoot, zaloguj ) 


I nie wiem czemu nie zak?ada tego teamu i nie dodaje po klikni?ciu tego przycisku co wyliczy?em pozycj? myszy na ekranie. (DB 3 czyste)

Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-08-29, 04:17


nanKy







Wiek: 23
Na forum: 4007 dni
Posty: 498
Nick w MP: nanky

Piwa: 1775

Respekt: 239
Respekt: 239Respekt: 239

function zaloguj (source)

zamien na
function zaloguj()


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-08-29, 04:44


Avenged

Młodszy Szkrypter






Wiek: 24
Na forum: 3651 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1572

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

NankY., teraz gdy klikam przycisk to nie dzieje si? nic.

[ Dodano: 2017-08-29, 04:46 ]
Strona Clienta:
local screenW, screenH = guiGetScreenSize()
local sx, sy = guiGetScreenSize()

local p = {}
local panel = false

function mysz(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 guiB()
       dxDrawRectangle(screenW * 0.3202, screenH * 0.3029, screenW * 0.3595, screenH * 0.3952, tocolor(0, 0, 0, 103), false)
        dxDrawLine(screenW * 0.3202, screenH * 0.6981, screenW * 0.6792, screenH * 0.6981, tocolor(255, 255, 255, 255), 3, false)
        dxDrawRectangle(screenW * 0.4387, screenH * 0.5848, screenW * 0.1250, screenH * 0.0448, tocolor(105, 105, 105, 232), false)
        dxDrawRectangle(screenW * 0.4387, screenH * 0.5019, screenW * 0.1238, screenH * 0.0467, tocolor(105, 105, 105, 232), false)
        dxDrawText("Zaloguj", screenW * 0.4774, screenH * 0.5114, screenW * 0.5804, screenH * 0.5390, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false)
        dxDrawText("Wyloguj", 797, 624, 957, 654, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false)
        dxDrawText("Pa?stowa Stra? Po?arna ", screenW * 0.3310, screenH * 0.3267, screenW * 0.6714, screenH * 0.4019, tocolor(210, 0, 0, 232), 4.00, "default", "left", "top", false, false, false, false, false)
        dxDrawText("Wyloguj", screenW * 0.4744, screenH * 0.5943, screenW * 0.5696, screenH * 0.6229, tocolor(255, 255, 255, 255), 1.50, "default", "left", "top", false, false, false, false, false)
end

addEventHandler("onClientClick", root, function(b, s)
  if b ~= "state" and s ~= "down" then return end
  if mysz(screenW * 0.44, screenH * 0.50, screenW * 0.12, screenH * 0.05) then
    triggerServerEvent("zaloguj_psp", localPlayer)
  elseif mysz(screenW * 0.44, screenH * 0.58, screenW * 0.13, screenH * 0.05) then
    triggerServerEvent("wyloguj_psp", localPlayer)
  end
end)

addEvent("open_gui", true)
addEventHandler("open_gui", root, function(t)
    if t == "p" then
        addEventHandler("onClientPreRender", root, guiB)
        showCursor(true, false)
        panel = true
    elseif t == "s" then
        removeEventHandler("onClientPreRender", root, guiB)
        showCursor(false)
        panel = false
    end
end)


Strona servera:
local marker = createMarker(1481.60461, -1730.17285, 13.38281, "cylinder", 1.05, 155, 155, 155, 125)

addEventHandler("onMarkerHit", marker, function(hit)
    if getElementType(hit) ~= "player" then return end
    if isPedInVehicle(hit) then return end
    triggerClientEvent(hit, "open_gui", hit, "p")
end)

addEventHandler("onMarkerLeave", marker, function(hit)
    if getElementType(hit) ~= "player" then return end
    if isPedInVehicle(hit) then return end
    triggerClientEvent(hit, "open_gui", hit, "s")
end)


function zaloguj()
local theTeam = createTeam ( PSP )
  if theTeam then                      
    setPlayerTeam ( source, PSP)  
end
end
addEvent( "zaloguj_psp", true )
addEventHandler( "zaloguj_psp", resourceRoot, zaloguj ) 

function wyloguj ()                  
    removePlayerTeam ( source, PSP)  
end
addEvent( "wyloguj_psp", true )
addEventHandler( "wyloguj_psp", resourceRoot, wyloguj ) 


Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-08-29, 11:02


Kalizman







Wiek: 24
Na forum: 3793 dni
Posty: 1394

Piwa: 4624

Respekt: 358,8
Respekt: 358,8Respekt: 358,8Respekt: 358,8Respekt: 358,8


function zaloguj()
local theTeam = createTeam ( PSP )
  if theTeam then                      
    setPlayerTeam ( source, PSP)  
end
end
addEvent( "zaloguj_psp", true )
addEventHandler( "zaloguj_psp", root, zaloguj ) 


[ Dodano: 2017-08-29, 11:02 ]
A i dodam ?e ?le wype?ni?e? funkcj? createTeam

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-08-29, 13:20


maciek3286

LUA Developer






Wiek: 26
Na forum: 5342 dni
Posty: 230
Nick w MP: maciek00

Piwa: 3211

Respekt: 101,5
Respekt: 101,5

Zamiast source polecam u?ywa? client.

Dlaczego w wylogowaniu deklarujesz resourceRoot? a w zaloguj root? Lepiej jest u?ywa? resourceRoot. Ale wtedy po stronie clienta te? musisz zadeklarowa? resourceRoot w triggerze.

function zaloguj()
local theTeam = createTeam("PSP")
   if theTeam then                      
      setPlayerTeam(client, theTeam)  
   end
end
addEvent( "zaloguj_psp", true )
addEventHandler( "zaloguj_psp", resourceRoot, zaloguj) 


A po 2 gdzie ty w MTA widzia?e? funcje removePlayerTeam?

function wyloguj()                  
   setPlayerTeam(client, nil)  
end
addEvent("wyloguj_psp", true)
addEventHandler("wyloguj_psp", resourceRoot, wyloguj) 


A tak powinny wygl?da? triggery:

addEventHandler("onClientClick", root, function(b, s)
  if b ~= "state" and s ~= "down" then return end
  if mysz(screenW * 0.44, screenH * 0.50, screenW * 0.12, screenH * 0.05) then
    triggerServerEvent("zaloguj_psp", resourceRoot)
  elseif mysz(screenW * 0.44, screenH * 0.58, screenW * 0.13, screenH * 0.05) then
    triggerServerEvent("wyloguj_psp", resourceRoot)
  end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-08-29, 17:34


Avenged

Młodszy Szkrypter






Wiek: 24
Na forum: 3651 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1572

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

maciek3286, a jak zrobi? ?eby wi?cej ni? jedna osoba mog?a si? zalogowa?. Bo aktualnie jest tak ?e jak jedna osoba kliknie zaloguj to go loguje ale gdy kliknie druga osoba to nic si? nie dzieje.

Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-08-30, 21:03


maciek3286

LUA Developer






Wiek: 26
Na forum: 5342 dni
Posty: 230
Nick w MP: maciek00

Piwa: 3211

Respekt: 101,5
Respekt: 101,5

Spr?buj tak:

function zaloguj()
if not getTeamFromName("PSP") then
   theTeam = createTeam("PSP")
end
   if theTeam then                      
      setPlayerTeam(client, getTeamFromName("PSP"))  
   end
end
addEvent( "zaloguj_psp", true )
addEventHandler( "zaloguj_psp", resourceRoot, zaloguj) 


Postaw piwo autorowi tego posta
 

 
Wysłany: 2017-08-31, 04:09


Avenged

Młodszy Szkrypter






Wiek: 24
Na forum: 3651 dni
Posty: 654
Nick w MP: Avenged

Piwa: 1572

Respekt: 326,3
Respekt: 326,3Respekt: 326,3Respekt: 326,3

maciek3286, Dzi?ki ci bardzo maciek ;)

[ Dodano: 2017-08-31, 04:09 ]
Mo?na @LOCK

Podpis
LUA, JS, PHP



Zapraszam do skorzystania z moich usług: Klik

Postaw piwo autorowi tego posta
 

 
Tagi: triggery :: 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 Ten temat jest zablokowany bez możliwości zmiany postów lub pisania odpowiedzi

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