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

Wysłany: 2019-02-04, 21:23


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Witam mam skrypt pod drzwi lecz jest problem poniewa? jest on pod ACL a ja potrzebuje pod MYSQL ;/

KOD DRZWI :
function sprawdzPolicjanta(login)
    if login then
        if isObjectInACLGroup("user."..loginaclGetGroup("Policja")) then
        --outputChatBox
        return true
    else return false 
    end
end
end

local kategoria_animacji "CRIB"
local animacja "CRIB_Use_Switch"

local brama1 createObject(30891532.5, -1677.59997558599838.9003906250090)

-- 1 Marker
local markerbrama1 createMarker(1532.10, -1677.829838.55"cylinder"0.40000)
-- 2 Marker
local markerbrama12 createMarker(1533.09, -1675.739838.55"cylinder"0.40000)


function otworzbrama1(thePlayer)
local login getAccountName(getPlayerAccount(thePlayer))
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
        if sprawdzPolicjanta(loginthen
            moveObject brama130001532.5, -16799838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("ob1"otworzbrama1)

function zamknijbrama1(thePlayer)
local login getAccountName(getPlayerAccount(thePlayer))
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
        if sprawdzPolicjanta(loginthen
            moveObject brama130001532.5, -1677.59997558599838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("zb1"zamknijbrama1)
-----------------------------------------------------------------------------------------------------
addEventHandler("onPlayerJoin",root,function()
    
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end)

function onStart()
for ksource in pairs(getElementsByType("player")) do
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-04, 22:12


Gravgor







Wiek: 22
Na forum: 3619 dni
Posty: 380
Nick w MP: 1944

Piwa: 702

Respekt: 57,8

Mo?esz podczas logowania na duty nadawa? elementdate je?li gracz jest w kolumnie przyk?adowo SAPD, a nast?pnie w?a?nie w tym skrypcie odczytywa? za pomoc?.


Więcej informacji znajdziesz w Wikipedii MTA:

getElementData


Podpis
Portfolio marceliborowczak.me
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-04, 22:22


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

M?g? by? mi to zrobi? bo nie za bardzo rozumiem :/

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 17:23


Gravgor







Wiek: 22
Na forum: 3619 dni
Posty: 380
Nick w MP: 1944

Piwa: 702

Respekt: 57,8

"Szym34kKacperQ" napisał/a:

M?g? by? mi to zrobi? bo nie za bardzo rozumiem :/






function connect()
    dbdbConnect"mysql""dbname=DBNAME;host=HOST;charset=utf8""USERNAME""PASSWORD" )
    if (not dbthen
        outputDebugString("Error: Failed to establish connection to the MySQL database server")
    else
        outputDebugString("Success: Connected to the MySQL database server")
    end
end

addEventHandler("onResourceStart",resourceRootconnect)

--- uzywam db z wikimta

function logowanie()

local q dbQuery(db"SELECT * from sapd WHERE login=?"client)
local wynik dbPoll(q, -1)
  if wynik and #wynik > 0 then
        for _,v in ipairs(wynik) do
                  setElementData(client"sapd"v["sapd"]) - ustawiamy mu edate wraz z rang?, je?li takowa jest wstawania w bazie danych

                  outputChatBox("Zalogowa?e? si? na duty"client255255255) --

end 
end 
end 
addCommandHandler("duty"resourceRootlogowanie)

--- jest to przyk?admusisz przerobisw?j skrypt





function sprawdzPolicjanta()
        if getElementData(client,"sapd") == true then  
        --outputChatBox
        return true
    else return false 
end
end

local kategoria_animacji "CRIB"
local animacja "CRIB_Use_Switch"

local brama1 createObject(30891532.5, -1677.59997558599838.9003906250090)

-- 1 Marker
local markerbrama1 createMarker(1532.10, -1677.829838.55"cylinder"0.40000)
-- 2 Marker
local markerbrama12 createMarker(1533.09, -1675.739838.55"cylinder"0.40000)


function otworzbrama1(thePlayer)
local login getAccountName(getPlayerAccount(thePlayer))
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
        if sprawdzPolicjanta() then
            moveObject brama130001532.5, -16799838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("ob1"otworzbrama1)

function zamknijbrama1(thePlayer)
local login getAccountName(getPlayerAccount(thePlayer))
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
        if sprawdzPolicjanta() then
            moveObject brama130001532.5, -1677.59997558599838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("zb1"zamknijbrama1)
-----------------------------------------------------------------------------------------------------
addEventHandler("onPlayerJoin",root,function()
    
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end)

function onStart()
for ksource in pairs(getElementsByType("player")) do
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end
end


Podpis
Portfolio marceliborowczak.me
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 17:42


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Em to jest na komende ? /duty ;p ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 17:45


Gravgor







Wiek: 22
Na forum: 3619 dni
Posty: 380
Nick w MP: 1944

Piwa: 702

Respekt: 57,8

"Szym34kKacperQ" napisał/a:

Em to jest na komende ? /duty ;p ?


Tak, ale jak napisa?em jest to jedynie przyk?ad.

[ Dodano: 2019-02-05, 17:46 ]
Je?li posiadasz system frakcji, to poka? kod od SAPD i zrobimy to pod tw?j serwer.

Podpis
Portfolio marceliborowczak.me
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 18:05


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Frakcja SAPD
frakcja-policja >> s_duty


local licz = {}
local t=createElement('text')
setElementData(t,'name',"Policja\nRozpoczynanie s?u?by")
setElementDimension(t0)
setElementInterior(t0)
setElementPosition(t,-1610.40690.041337.95+1)


function isPlayerInPoliceFaction(plr)
 local uid=getElementData(plr,'player:uid')
 if not uid then return end

 local result=exports['ogrpg-db']:dbGet('SELECT 1 FROM ogrpg_factions WHERE code=? AND uid=? LIMIT 1;'"Policja"uid)
 if result[1then
  return true
 else
  return false
 end
end


addEvent("RozpocznijSAPD",true)
addEventHandler("RozpocznijSAPD",root,function(el)
    if isPlayerInPoliceFaction(elthen
        if not getElementData(el,'player:duty'then
            setElementHealth(el,100)
            giveWeapon(el,4)
            --setElementModel(el,277)
            --setPlayerNametagColor(el,0,0,255)
            exports['frakcja']:rozpocznijnaliczanie(el)
            setElementData(el,'player:duty','Policja')
            local rank exports['frakcja']:getPlayerFactionRank(el,'Policja')
            setElementData(el,"player:rank",rank)
            exports["noti2"]:noti("Rozpoczynasz s?u?b?"el)

            -------------------- nie dotyka? 
                            local uid=getElementData(el,"player:uid")
            exports['ogrpg-db']:dbSet('UPDATE ogrpg_factions set actived=NOW() WHERE code=? AND uid=? LIMIT 1;'"Policja"uid)


            ------------------------------------------------------


        else
            exports['frakcja']:zatrzymajnaliczanie(el)
            takeWeapon(el,4)
            removeElementData(el'player:duty')
            removeElementData(el,"player:rank")
            local skin=getElementData(el,"player:skin")
            exports["noti2"]:noti("Zakonczy?e? s?u?b?"el)
            setPlayerNametagColor(el255,255,255)
            setElementModel(elskin)
        end
    else
        exports["noti2"]:noti("Nie nale?ysz do Policji"el)
    end
end)



--trigg
function naliczanie(el)
    if isElement(elthen
   local x getElementData(el,"player:workinjob") or 0
   setElementData(el,"player:workinjob",x+1)
   else
    if isTimer(licz[el]) then
    killTimer(licz[el])
    licz[el] = nil
    end
   end
end

local t=createElement('text')
setElementData(t,'name','Policja\nSkin: Posterunkowy')
setElementDimension(t0)
setElementInterior(t0)
setElementPosition(t,-1651.52,712.85,1337.95+1)    
    
local dutyPickup createPickup(  -1651.52,712.85,1337.95,3,1275,1000 )
local fractionSkin 275
addEventHandler("onPickupHit",dutyPickup,function (hit)
if hit and getElementType(hit)=="player" then
if getElementData(hit,"player:duty")=="Policja" then
if not getElementData(hit,"player:duty"then
    else
        setElementModel(hit,280)
        setElementData(hit,"temp:fractionduty",fractionVehiclePrefix)
        exports["noti2"]:noti("Zmieniasz ubranie s?u?bowe na: Posterunkowy"hit)
    end
else
    exports["noti2"]:noti("Zako?cz s?u?b? innej frkacji lub pracy urz?dowej.")
end
else
    exports["noti2"]:noti("Nie nale?ysz do tej frakcji.")

end
end)    




local t=createElement('text')
setElementData(t,'name','Policja\nSkin: OPP')
setElementDimension(t0)
setElementInterior(t0)
setElementPosition(t,-1648.87,708.96,1337.95+1)    
    
local dutyPickup createPickup(  -1648.87,708.96,1337.95,3,1275,1000 )
local fractionSkin 275
addEventHandler("onPickupHit",dutyPickup,function (hit)
if hit and getElementType(hit)=="player" then
if getElementData(hit,"player:duty")=="Policja" then
if not getElementData(hit,"player:duty"then
    else
        setElementModel(hit,281)
        setElementData(hit,"temp:fractionduty",fractionVehiclePrefix)
        exports["noti2"]:noti("Zmieniasz ubranie s?u?bowe na: OPP"hit)
    end
else
    exports["noti2"]:noti("Zako?cz s?u?b? innej frkacji lub pracy urz?dowej.")
end
else
    exports["noti2"]:noti("Nie nale?ysz do tej frakcji.")

end
end)


local t=createElement('text')
setElementData(t,'name','Policja\nSkin: Kamizelka')
setElementDimension(t0)
setElementInterior(t0)
setElementPosition(t,-1640.56,709.06,1337.95+1)    
    
local dutyPickup createPickup(  -1640.56,709.06,1337.95,3,1275,1000 )
local fractionSkin 275
addEventHandler("onPickupHit",dutyPickup,function (hit)
if hit and getElementType(hit)=="player" then
if getElementData(hit,"player:duty")=="Policja" then
if not getElementData(hit,"player:duty"then
    else
        setElementModel(hit,282)
        setElementData(hit,"temp:fractionduty",fractionVehiclePrefix)
        exports["noti2"]:noti("Zmieniasz ubranie s?u?bowe na: Kamizelka"hit)
    end
else
    exports["noti2"]:noti("Zako?cz s?u?b? innej frkacji lub pracy urz?dowej.")
end
else
    exports["noti2"]:noti("Nie nale?ysz do tej frakcji.")

end
end)


local t=createElement('text')
setElementData(t,'name','Policja\nSkin: BOA')
setElementDimension(t0)
setElementInterior(t0)
setElementPosition(t,-1631.04,709.12,1337.95+1)    
    
local dutyPickup createPickup(  -1631.04,709.12,1337.95,3,1275,1000 )
local fractionSkin 275
addEventHandler("onPickupHit",dutyPickup,function (hit)
if hit and getElementType(hit)=="player" then
if getElementData(hit,"player:duty")=="Policja" then
if not getElementData(hit,"player:duty"then
    else
        setElementModel(hit,283)
        setElementData(hit,"temp:fractionduty",fractionVehiclePrefix)
        exports["noti2"]:noti("Zmieniasz ubranie s?u?bowe na: BOA"hit)
    end
else
    exports["noti2"]:noti("Zako?cz s?u?b? innej frkacji lub pracy urz?dowej.")
end
else
    exports["noti2"]:noti("Nie nale?ysz do tej frakcji.")

end
end)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 18:12


Gravgor







Wiek: 22
Na forum: 3619 dni
Posty: 380
Nick w MP: 1944

Piwa: 702

Respekt: 57,8



local kategoria_animacji "CRIB"
local animacja "CRIB_Use_Switch"

local brama1 createObject(30891532.5, -1677.59997558599838.9003906250090)

-- 1 Marker
local markerbrama1 createMarker(1532.10, -1677.829838.55"cylinder"0.40000)
-- 2 Marker
local markerbrama12 createMarker(1533.09, -1675.739838.55"cylinder"0.40000)


function otworzbrama1(thePlayer)
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
       if getElementData(thePlayer'player:duty','Policja') == true then 
            moveObject brama130001532.5, -16799838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("ob1"otworzbrama1)

function zamknijbrama1(thePlayer)
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
        if getElementData(thePlayer'player:duty','Policja') == true then 
            moveObject brama130001532.5, -1677.59997558599838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("zb1"zamknijbrama1)
-----------------------------------------------------------------------------------------------------
addEventHandler("onPlayerJoin",root,function()
    
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end)

function onStart()
for ksource in pairs(getElementsByType("player")) do
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end
end


Podpis
Portfolio marceliborowczak.me
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 18:39


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Nie dzia?a

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 18:44


Gravgor







Wiek: 22
Na forum: 3619 dni
Posty: 380
Nick w MP: 1944

Piwa: 702

Respekt: 57,8

"Szym34kKacperQ" napisał/a:

Nie dzia?a


db3?

Podpis
Portfolio marceliborowczak.me
Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 18:46


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Debugscript 3


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 18:48


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Spr?buj tego:


local kategoria_animacji "CRIB"
local animacja "CRIB_Use_Switch"

local brama1 createObject(30891532.5, -1677.59997558599838.9003906250090)

-- 1 Marker
local markerbrama1 createMarker(1532.10, -1677.829838.55"cylinder"0.40000)
-- 2 Marker
local markerbrama12 createMarker(1533.09, -1675.739838.55"cylinder"0.40000)


function otworzbrama1(thePlayer)
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
       if getElementData(thePlayer'player:duty') == 'Policja' then 
            moveObject brama130001532.5, -16799838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("ob1"otworzbrama1)

function zamknijbrama1(thePlayer)
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
        if getElementData(thePlayer'player:duty') == 'Policja' then 
            moveObject brama130001532.5, -1677.59997558599838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("zb1"zamknijbrama1)
-----------------------------------------------------------------------------------------------------
addEventHandler("onPlayerJoin",root,function()
    
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end)

function onStart()
for ksource in pairs(getElementsByType("player")) do
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end
end


Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-05, 18:49


Gravgor







Wiek: 22
Na forum: 3619 dni
Posty: 380
Nick w MP: 1944

Piwa: 702

Respekt: 57,8

A, dobra, sory. M?j b??d, teraz masz dobry kod.

local kategoria_animacji "CRIB"
local animacja "CRIB_Use_Switch"

local brama1 createObject(30891532.5, -1677.59997558599838.9003906250090)

-- 1 Marker
local markerbrama1 createMarker(1532.10, -1677.829838.55"cylinder"0.40000)
-- 2 Marker
local markerbrama12 createMarker(1533.09, -1675.739838.55"cylinder"0.40000)


function otworzbrama1(thePlayer)
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
      if getElementData(thePlayer"player:duty") == "Policja" then 
            moveObject brama130001532.5, -16799838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("ob1"otworzbrama1)

function zamknijbrama1(thePlayer)
    if isElementWithinMarker(thePlayermarkerbrama1) or isElementWithinMarker(thePlayermarkerbrama12then
        if getElementData(thePlayer"player:duty") == "Policja" then 
            moveObject brama130001532.5, -1677.59997558599838.900390625 )
            setTimer(setPedAnimation1066.661thePlayer)
            setPedAnimation(thePlayer,kategoria_animacji,animacja,true,false,false)
        end
    end
end
addCommandHandler("zb1"zamknijbrama1)
-----------------------------------------------------------------------------------------------------
addEventHandler("onPlayerJoin",root,function()
    
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end)

function onStart()
for ksource in pairs(getElementsByType("player")) do
    bindKey(source,"mouse_wheel_up","both",otworzbrama1)
    bindKey(source,"mouse_wheel_down","both",zamknijbrama1)
end
end


Podpis
Portfolio marceliborowczak.me
Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Fl!k
Wysłany: 2019-02-06, 15:54


Fl!k







Wiek: 26
Na forum: 3592 dni
Posty: 162

Piwa: 18

Respekt: 50

Dzieki mordo :D a mam pytanie jak zrobi? 2 pary drzwi pod 1 przycisk :D ?

Postaw piwo autorowi tego posta
 

 
Wysłany: 2019-02-06, 17:09


Wilq







Wiek: 24
Na forum: 4428 dni
Posty: 3410

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Stw?rz drug? par? drzwi i sprawdzaj, przy kt?rych drzwiach gracz jest bli?ej.
Otwieraj te, przy kt?rych jest bli?ej.

Postaw piwo autorowi tego posta
 

 
Tagi: dzwi :: pod :: mysql
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » Dzwi pod MYSQL 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