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

Wysłany: 2020-02-11, 14:13


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

znowu ja, t?py ja. witam bardzo serdecznie. Prosto z beczki: chodzi o to, ?e gracz wpisuje komende /wyslijapelacje <jakisteam>, i pokazuje mu sie na czacie wiadomsc, ze wyslal apelacje do tego teamu. A pragne tez, zeby gracz ktory jest w grupie acl "lidergang1" przez wlasnie wpisanie tej komendy przez gracza pierwszego (thePlayer) otrzymywal wiadomosc, ze gracz ktory wpisa? komend?, apeluje o do??czenie do teamu. Nah,dam ten kod, mam nadzieje nic na tym nie strace xD (dam piwko i respekt za pomoc oczywiscie ^.^)

function wyslijApelacje(thePlayer, cmd, ...)
if (not ...) then
    outputChatBox("#FFFFcaPodaj nazwe gangu, do ktorego chcesz dolaczyc", thePlayer, 255, 255, 255, true)
    else
if ... ~= "gang1" and ... ~= "gang2" and ... ~= "gang3" and ... ~= "gang4" and ... ~= "gang5" and ... ~= (not ...) then
outputChatBox("#FFFFcaGang o podanej nazwie nie istnieje", thePlayer, 255, 255, 255, true)
else
    if ... == "gang1"
    or ... == "gang2"
    or ... == "gang3"
    or ... == "gang4"
    or ... == "gang5" then
    outputChatBox("#FFFFcaWys?a?e? apelacje o gang ".. ..., thePlayer, 255, 255, 255, true)
else
if ... == "gang1" then
    setElementData(thePlayer, "chcedogang1", true)
    setElementData(thePlayer, "chcedogang2", false)
    setElementData(thePlayer, "chcedogang3", false)
    setElementData(thePlayer, "chcedogang4", false)
    setElementData(thePlayer, "chcedogang5", false)
    local accName = getAccountName ( getPlayerAccount ( ... ) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Lidergang1" ) )
        or isObjectInACLGroup ("user."..accName, aclGetGroup ( "ViceLidergang1" ) ) then
        local nickGracza = getPlayerName(thePlayer)
            outputChatBox(nickGracza.."#FFFFca wys?a? apelacje o do??czenie do gangu.",  co tu poda???, 255, 255, 255, true)
else
    if ... == "gang2" then
    setElementData(thePlayer, "chcedogang2", true)
    setElementData(thePlayer, "chcedogang1", false)
    setElementData(thePlayer, "chcedogang3", false)
    setElementData(thePlayer, "chcedogang4", false)
    setElementData(thePlayer, "chcedogang5", false)
    local accName = getAccountName ( getPlayerAccount ( gracz ) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Lidergan2" ) )
        or isObjectInACLGroup ("user."..accName, aclGetGroup ( "ViceLidergang2" ) ) then
            outputChatBox(nickGracza.."#FFFFca wys?a? apelacje o do??czenie do gangu.", co tu poda??, 255, 255, 255, true)
else
    if ... == "gang3" then
    setElementData(thePlayer, "chcedogang3", true)
    setElementData(thePlayer, "chcedogang2", false)
    setElementData(thePlayer, "chcedogang1", false)
    setElementData(thePlayer, "chcedogang4", false)
    setElementData(thePlayer, "chcedogang5", false)
    local accName = getAccountName ( getPlayerAccount ( gracz ) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Lidergang3" ) )
        or isObjectInACLGroup ("user."..accName, aclGetGroup ( "ViceLidergang3" ) ) then
            outputChatBox(nickGracza.."#FFFFca wys?a? apelacje o do??czenie do gangu.",  co tu poda????, 255, 255, 255, true)
else
    if ... == "gang4" then
    setElementData(thePlayer, "chcedogang4", true)
    setElementData(thePlayer, "chcedogang2", false)
    setElementData(thePlayer, "chcedogang3", false)
    setElementData(thePlayer, "chcedogang1", false)
    setElementData(thePlayer, "chcedogang5", false)
    local accName = getAccountName ( getPlayerAccount ( gracz ) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Lidergang4" ) )
        or isObjectInACLGroup ("user."..accName, aclGetGroup ( "ViceLidergang4" ) ) then
            outputChatBox(nickGracza.."#FFFFca wys?a? apelacje o do??czenie do gangu.",  co tu poda????, 255, 255, 255, true)
else
    if ... == "gang5" then
    setElementData(thePlayer, "chcedogang5", true)
    setElementData(thePlayer, "chcedogang2", false)
    setElementData(thePlayer, "chcedogang3", false)
    setElementData(thePlayer, "chcedogang4", false)
    setElementData(thePlayer, "chcedogang1", false)
    local accName = getAccountName ( getPlayerAccount ( gracz ) )
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Lidergang5" ) )
        or isObjectInACLGroup ("user."..accName, aclGetGroup ( "ViceLidergang5" ) ) then
            outputChatBox(nickGracza.."#FFFFca wys?a? apelacje o do??czenie do gangu.",  co tu poda????, 255, 255, 255, true)
        end
    end
end
end
end
end
end
end
end
end
end
end
end
end
addCommandHandler("gangdolacz", wyslijApelacje)


Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-11, 14:25


Wilq







Wiek: 24
Na forum: 4569 dni
Posty: 3409

Piwa: 739

Respekt: 1225,8
Respekt: 1225,8

Ju? ci opisa?em Tw?j problem ale chyba jednak dalej ci??ko...
Zle definiujesz to co gracz wpisa?. Ju? wcze?niej dosta?e? gotowy kod do zastosowania.

?eby znale?? gracza z ACL u?ywasz

Więcej informacji znajdziesz w Wikipedii MTA:

aclGroupListObjects


Więcej informacji znajdziesz w Wikipedii MTA:

getAccount


Więcej informacji znajdziesz w Wikipedii MTA:

getAccountPlayer


No i musisz przebudowa? ca?kiem te warunki sprawdzaj?ce bo te? s? bez sensu.

Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Szyszka947
Wysłany: 2020-02-11, 14:56


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

no ok, wstawi?em te
local text = table.concat({...}, " ")
i wsz?dzie zamiast ... wstawiam text, ale jak mam u?y? tych trzech funkcji? Tych przyk?ad?w z wiki kompletnie nie kumam, szczegolnie jesli chodzi o to, co chce osiagnac

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-11, 16:08


Gorn5







Wiek: 26
Na forum: 4416 dni
Posty: 22
Nick w MP: Rayzer

Piwa: 6

Respekt: 100
Respekt: 100

Dodaj do skryptu:


function getPlayersInACLGroup (GroupName)
    local aTable = {}
    assert ( tostring ( GroupName ) , "Bad Argument At Argument #1 Group Moust String" )
    assert ( aclGetGroup ( tostring ( GroupName ) ) , "Bad Argument At Argument #1 Group not Found "  )
    
    for i , player_ in ipairs ( getElementsByType ( "player" ) ) do
        local TheAcc =  getPlayerAccount ( player_ )
        if not isGuestAccount ( TheAcc ) then
            if isObjectInACLGroup ( "user." ..getAccountName ( TheAcc ) , aclGetGroup ( tostring ( GroupName ) ) ) then
                table.insert ( aTable , player_ )
            end
        end
    end
    return aTable
end


Zamie? sw?j kod na ten:


function joinRequest(player, command, teamName)
    if not teamName then outputChatBox("#FFFFcaPodaj nazw? gangu, do kt?rego chcesz do??czy?.", player, 255, 255, 255, true) return end
    if getTeamFromName(teamName) then
        outputChatBox("#FFFFcaWys?a?e? pro?b? o do??czenie do gangu o nazwie "..teamName, player, 255, 255, 255, true)
        setElementData(player, "joinrequest:"..teamName, true)

        local accountName = getAccountName(getPlayerAccount(player))
        local ACLPlayers = getPlayersInACLGroup("Lider "..teamName)

        for __, members in ipairs(ACLPlayers) do
            local o = getAccountName(getPlayerAccount(members))
            if isObjectInACLGroup("user."..o, aclGetGroup("Lider "..teamName)) or isObjectInACLGroup("user."..o, aclGetGroup ("ViceLider "..teamName)) then
                outputChatBox("#FFFFcaGracz o nicku "..accountName.." wys?a? pro?b? o do??czenie do gangu.", members, 255, 255, 255, true)
            end
        end
    else
        outputChatBox("#FFFFcaGang o podanej nazwie nie istnieje", player, 255, 255, 255, true)
    end
end
addCommandHandler("request", joinRequest)


Postaw piwo autorowi tego posta
 

 
Więcej szczegółów
Wystawiono 1 piw(a):
Szyszka947
Wysłany: 2020-02-11, 16:22


Szyszka947

ASP NET Core / Lua






Wiek: 19
Na forum: 2720 dni
Posty: 288

Piwa: 16

Respekt: 90

Wow, wtf, szok, niedowierzanie, brak s??w. Dziekuj?. Ale napotka?em te? jeden problem, mianowicie w acl mam wszystko niby okej:

<group name="Lider#1GangDoWynajecia"></group>
    <group name="Lider#2GangDoWynajecia">
        <object name="user.Szyszka"></object>
    </group>
    <group name="Lider#3GangDoWynajecia"></group>
    <group name="Lider#4GangDoWynajecia"></group>
    <group name="Lider#4GangDoWynajecia"></group>
    <group name="ViceLider#1GangDoWynajecia"></group>
    <group name="ViceLider#2GangDoWynajecia"></group>
    <group name="ViceLider#3GangDoWynajecia"></group>
    <group name="ViceLider#4GangDoWynajecia"></group>
    <group name="ViceLider#5GangDoWynajecia"></group>

a nie dostaje wiadomosci o tym, ?e ten kto? wys?a? apelacje. Czy to mo?e dlatego, ?e testuje sam na sobie? Tak mi si? wydaje, lecz nie jestem pewien.
Okej, naprawi?em xD Po prostu by?y w kodzie spacje co sprawia?o, ?e Lider by? odzielony spacj? od nazwy gangu. Sorki za zamieszanie, jeszcze raz dzieki. :D

Postaw piwo autorowi tego posta
 

 
Wysłany: 2020-02-11, 20:47


Gorn5







Wiek: 26
Na forum: 4416 dni
Posty: 22
Nick w MP: Rayzer

Piwa: 6

Respekt: 100
Respekt: 100

Przesy?am ni?ej odpowied? dot. pytania, kt?re zada?e? mi na PW: jak usun?? graczy z gang?w. Niestety przez ograniczenie silnika nie mog?em tam odpowiedzie?.

Odpowied?: To zale?y na jakiej zasadzie u Ciebie dzia?a system gang?w. Je?li w ca?o?ci jest oparty na teamach, to przygotowa?em kr?tki kod, kt?ry by? mo?e pomo?e Ci rozwi?za? sw?j problem.


function removePlayer(commandPlayer, command, target, team, reason)
    if not target or not team or not reason then
        outputChatBox("Prawid?owe u?ycie: /removeplayer <nick gracza> <nazwa gangu> <pow?d>", commandPlayer, 255, 0, 0, true)
        return
    else
        local target = getPlayerFromName(target)

        local acc = getAccountName(getPlayerAccount(commandPlayer))
        if not getPlayerTeam(commandPlayer) then
            outputChatBox("Nie nale?ysz do ?adnego gangu.", commandPlayer, 255, 0, 0, true)
        else
            local cPlayerTeam = getTeamName(getPlayerTeam(commandPlayer))
            if cPlayerTeam ~= false and cPlayerTeam == getTeamName(getTeamFromName(team)) then
                if isObjectInACLGroup("user."..getPlayerName(commandPlayer), aclGetGroup("Lider "..team)) or isObjectInACLGroup("user."..getPlayerName(commandPlayer), aclGetGroup ("ViceLider "..team)) then
                    if getElementType(target) == "player" then
                        local targetTeam = getTeamName(getPlayerTeam(target))
                        if targetTeam == getTeamName(getTeamFromName(team)) then
                            setPlayerTeam(target, nil)

                            outputChatBox("Gracz "..getPlayerName(target).." zosta? usuni?ty z gangu przez: "..acc, commandPlayer, 0, 255, 0, true)
                            outputChatBox("Zosta?e? usuni?ty z gangu "..targetTeam.." przez "..acc.." za: "..tostring(reason)..".", target, 255, 0, 0, true)
                        else
                            outputChatBox("Ten gracz nie jest cz?onkiem Twojego gangu.", commandPlayer, 255, 0, 0, true)
                        end
                    end
                end
            else
                outputChatBox("Nie nale?ysz do tego gangu.", commandPlayer, 255, 0, 0, true)
                return
            end
        end
    end
end
addCommandHandler("removeplayer", removePlayer)


Natomiast je?li Tw?j system gang?w dzia?a w inny spos?b, to daj zna?.

Postaw piwo autorowi tego posta
 

 
Tagi: rozroznianie :: graczy
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






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