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

Wysłany: 2015-09-16, 17:40


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

Witam, Mam kod na PM lecz chcia?bym doda? aby pisa?o si? pm ID/nick tre??.

Dam kod :


function privateMessage(thePlayer,commandName,sendToName,...)
    local pmWords = { ... }
    local pmMessage table.concatpmWords" " )
    if sendToName then
        if (getPlayerFromParticalName (sendToName)) then
        toPlayer = (getPlayerFromParticalName (sendToName))
            if not (toPlayer == thePlayerthen
                if not (pmMessage == ""then
                    outputChatBox("#0044FF[PM]#FFFFFF Wiadomo?? do #FFFFFF" .. getPlayerName(toPlayer) .. "#FFFFFF: " .. pmMessagethePlayer255255255true)
                    outputChatBox("#0044FF[PM]#FFFFFF Wiadomo?? od #FFFFFF" .. getPlayerName(thePlayer) .. "#FFFFFF: " .. pmMessagetoPlayer255255255true)
                else
                    outputChatBox("#0044FF[PM]#FFFFFF ?le napisa?e?! u?yj:#FFFFFF /pm [Nick] [wiadomosc]"thePlayer255255255true)
                    return false
                end
            else
                outputChatBox("#0044FF[PM]#FFFFFF Nie mo?esz sobie wys?a? PM#FFFFFF!"thePlayer255255255true)
                return false
            end
        else
            outputChatBox("#0044FF[PM]#FFFFFF Nie ma takiego gracza! #FFFF00(#FFFFFF"..sendToName.."#FFFF00)"thePlayer255255255true)
            return false
        end
    else
        outputChatBox("#0044FF[PM]#FFFFFF ?le napisa?e?! u?yj:#FFFFFF /pm [Nick] [Wiadomo??]"thePlayer255255255true)
        return false
    end
end
addCommandHandler("pm"privateMessage)


function getPlayerFromParticalName(thePlayerName)
    local thePlayer getPlayerFromName(thePlayerName)
    if thePlayer then
        return thePlayer
    end
    for _,thePlayer in ipairs(getElementsByType("player")) do
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x"""), thePlayerName:lower(), 1truethen
            return thePlayer
        end
    end
return false
end


Za pomoc daj? :arrow: :piwo: :piwo: oraz R* R*

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-16, 18:36


#404







Wiek: 26
Na forum: 4771 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%
W kodzie dodajesz sprawdzanie czy "sendToName" jest liczb?, je?eli tak = szukasz gracza o podanym id i do niego wysy?asz wiadomo??. Mo?e Ci z tym pom?c taka funkcja jak tonumber ( 1 argument to zmienna, z kt?rej ma zosta? wyci?gni?ta liczba). Je?eli liczba nie zostanie wyci?gni?ta zwraca false - czyli wtedy szukasz po nicku.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-16, 19:39


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

DestroY, a mo?esz jaki? przyk?ad :)

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-16, 20:14


#404







Wiek: 26
Na forum: 4771 dni
Posty: 1438

Piwa: 2512

Respekt: 833,5
Respekt: 833,5Respekt: 833,5

Ostrzeżeń: 60%


function privateMessage(thePlayer,commandName,sendToName,...)
    local pmWords = { ... }
    local pmMessage table.concatpmWords" " )
    if sendToName then
            if not tonumber(sendToNamethen
                                if (getPlayerFromParticalName (sendToName)) then
                                toPlayer = (getPlayerFromParticalName (sendToName))
                                                if not (toPlayer == thePlayerthen
                                                            if not (pmMessage == ""then
                                                                outputChatBox("#0044FF[PM]#FFFFFF Wiadomo?? do #FFFFFF" .. getPlayerName(toPlayer) .. "#FFFFFF: " .. pmMessagethePlayer255255255true)
                                                                outputChatBox("#0044FF[PM]#FFFFFF Wiadomo?? od #FFFFFF" .. getPlayerName(thePlayer) .. "#FFFFFF: " .. pmMessagetoPlayer255255255true)
                                                            else
                                                                outputChatBox("#0044FF[PM]#FFFFFF ?le napisa?e?! u?yj:#FFFFFF /pm [Nick] [wiadomosc]"thePlayer255255255true)
                                                                return false
                                                            end
                                                else
                                                    outputChatBox("#0044FF[PM]#FFFFFF Nie mo?esz sobie wys?a? PM#FFFFFF!"thePlayer255255255true)
                                                    return false
                                                end
                                else
                                    outputChatBox("#0044FF[PM]#FFFFFF Nie ma takiego gracza! #FFFF00(#FFFFFF"..sendToName.."#FFFF00)"thePlayer255255255true)
                                    return false
                                end
            else
                toPlayer =  GraczZID(tonumber(sendToName))
               if not (toPlayer == thePlayerthen
                        if not (pmMessage == ""then
                            outputChatBox("#0044FF[PM]#FFFFFF Wiadomo?? do #FFFFFF" .. getPlayerName(toPlayer) .. "#FFFFFF: " .. pmMessagethePlayer255255255true)
                            outputChatBox("#0044FF[PM]#FFFFFF Wiadomo?? od #FFFFFF" .. getPlayerName(thePlayer) .. "#FFFFFF: " .. pmMessagetoPlayer255255255true)
                        else
                            outputChatBox("#0044FF[PM]#FFFFFF ?le napisa?e?! u?yj:#FFFFFF /pm [Nick] [wiadomosc]"thePlayer255255255true)
                            return false
                        end
                else
                    outputChatBox("#0044FF[PM]#FFFFFF Nie mo?esz sobie wys?a? PM#FFFFFF!"thePlayer255255255true)
                    return false
                end            
            
            end
    
    else
        outputChatBox("#0044FF[PM]#FFFFFF ?le napisa?e?! u?yj:#FFFFFF /pm [Nick] [Wiadomo??]"thePlayer255255255true)
        return false
    end
end
addCommandHandler("pm"privateMessage)

function GraczZID(id)
         IDDocelowe id

        for k,v in ipairs (getElementsByType("player")) do
                 if getElementData(v"TUNAZWAID") == IDDocelowe then
                 return v
                    else
                 end
        end
end

function getPlayerFromParticalName(thePlayerName)
    local thePlayer getPlayerFromName(thePlayerName)
    if thePlayer then
        return thePlayer
    end
    for _,thePlayer in ipairs(getElementsByType("player")) do
        if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x"""), thePlayerName:lower(), 1truethen
            return thePlayer
        end
    end
return false
end


Tylko nie gwarantuj?, ?e to b?dzie dzia?a?, robi? to w przerwie mi?dzy rankedami i nie testowa?em.

Postaw piwo autorowi tego posta
 

 
Wysłany: 2015-09-16, 20:26


sebik2303

Mapper :)






Wiek: 25
Na forum: 4160 dni
Posty: 298
Nick w MP: sebik2303

Piwa: 899

Respekt: 55,3

DestroY, jest DB


Postaw piwo autorowi tego posta
 

 
Tagi: oraz :: nick
Anonymous





Na forum: 245 dni
Posty: 1



Anonymous Koniecznie zajrzyj na:






Skocz do:  
Wyświetl posty z ostatnich:   
GTAONLINE.PL » JĘZYKI PROGRAMOWANIA » LUA » pm na ID oraz nick 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