Laluis23 Posted March 7, 2019 Share Posted March 7, 2019 Oi gente, gostaria de saber como fazer um chat de vendas, por exemplo assim: Quando o jogador digitar /olx carro sem doc, vai aparecer no chat "O jogador "tal", está vendendo carro sem doc. E assim vai Mas queria saber como faço para depois disso ele possa adicionar um valor do veiculo e iria ficar + ou - assim, Exemplo: ,/olx carro sem doc 4000 O jogador X está vendendo carro sem doc por R$4000. Tentei fazer a parte dos números mas n consegui ComandoDoChatGlobal = "olx" function adminchat ( thePlayer, _, ... ) local message = table.concat ( { ... }, " " ) if ( isPlayerOnGroup ( thePlayer ) ) then for _, player in ipairs ( getElementsByType ( "player" ) ) do if ( isPlayerOnGroup ( player ) ) then conta = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Console" ) ) then outputChatBox("#838B83[ #A020F0O#9ACD32L#FFA500X #838B83]#ffffff #00FF00» : #ffffffO Jogador #00FF00"..getPlayerName(thePlayer).. ", #ffffffestá vendendo #ffffff #DAA520"..message, player, 255, 255, 255, true) elseif isObjectInACLGroup ("user."..conta, aclGetGroup ( "Everyone" ) ) then outputChatBox("#838B83[ #A020F0O#9ACD32L#FFA500X #838B83]#ffffff #00FF00» : #ffffffO Jogador #00FF00"..getPlayerName(thePlayer).. ", #ffffffestá vendendo #ffffff #DAA520"..message, player, 255, 255, 255, true) end end end end setElementData ( thePlayer, "Chat:Avisado", true ) setElementData ( thePlayer, "Chat:Delay1",true ) setTimer ( setElementData, 5000, 1, thePlayer, "Chat:Delay1", false ) end addCommandHandler ( ComandoDoChatGlobal, adminchat ) -------------------------------------------------------------------------------------------- function isPlayerOnGroup ( thePlayer ) local account = getPlayerAccount ( thePlayer ) local inGroup = false for _, group in ipairs ( { "Everyone" } ) do if isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( group ) ) then inGroup = true break end end return inGroup end Link to comment
Other Languages Moderators Lord Henry Posted March 7, 2019 Other Languages Moderators Share Posted March 7, 2019 Faça o valor antes do texto. /olx 40000 carro sem doc function adminchat (thePlayer, _, valor, ...) 1 Link to comment
Laluis23 Posted March 7, 2019 Author Share Posted March 7, 2019 @Lord Henry, eu digo fazer assim /olx carro sem doc 40, dai aparece no chat carro sem doc por R$40... Como eu faço isso ? perdão por algum erro, sou iniciante.. Link to comment
Other Languages Moderators Lord Henry Posted March 7, 2019 Other Languages Moderators Share Posted March 7, 2019 Após o texto não dá pra inserir novos parâmetros. Pelo menos não sem gambiarra. Link to comment
[M]ister Posted March 7, 2019 Share Posted March 7, 2019 Se o valor estiver sempre no final pode ser usado: function adminchat ( thePlayer, _, ... ) local tbl = {...} local valor = tbl[#tbl] table.remove(tbl) local message = table.concat ( tbl, " " ) if ( isPlayerOnGroup ( thePlayer ) ) then -- resto do código Link to comment
Laluis23 Posted March 7, 2019 Author Share Posted March 7, 2019 tentei mas n deu tipo era pra ser assim /olx carro sem doc 30.00 dai ia aparecer no final "jogar x esta vendendo carro sem doc por R$30.00" ComandoDoChatGlobal = "olx" function adminchat ( thePlayer, _, ... ) local tbl = {...} local valor = tbl[#tbl] table.remove(tbl) local message = table.concat ( tbl, " " ) if ( isPlayerOnGroup ( thePlayer ) ) then conta = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup ("user."..conta, aclGetGroup ( "Console" ) ) then outputChatBox("#838B83[ #A020F0O#9ACD32L#FFA500X #838B83 ]#ffffff #00FF00» : #ffffffO Jogador #00FF00"..getPlayerName(thePlayer).. ", #ffffffestá vendendo #ffffff #DAA520"..message, player, 255, 255, 255, true) elseif isObjectInACLGroup ("user."..conta, aclGetGroup ( "Everyone" ) ) then outputChatBox("#838B83[ #A020F0O#9ACD32L#FFA500X #838B83 ]#ffffff #00FF00» : #ffffffO Jogador #00FF00"..getPlayerName(thePlayer).. ", #ffffffestá vendendo #ffffff #DAA520"..message, player, 255, 255, 255, true) end end end end setElementData ( thePlayer, "Chat:Avisado", true ) setElementData ( thePlayer, "Chat:Delay1",true ) setTimer ( setElementData, 5000, 1, thePlayer, "Chat:Delay1", false ) end addCommandHandler ( ComandoDoChatGlobal, adminchat ) -------------------------------------------------------------------------------------------- function isPlayerOnGroup ( thePlayer ) local account = getPlayerAccount ( thePlayer ) local inGroup = false for _, group in ipairs ( { "Everyone" } ) do if isObjectInACLGroup ( "user.".. getAccountName ( account ), aclGetGroup ( group ) ) then inGroup = true break end end return inGroup end Link to comment
Jonas^ Posted March 7, 2019 Share Posted March 7, 2019 Me parece que tem uns end a mais ali na função 'adminchat' 1 Link to comment
Other Languages Moderators Lord Henry Posted March 7, 2019 Other Languages Moderators Share Posted March 7, 2019 14 minutes ago, Laluis23 said: "jogar x esta vendendo carro sem doc por R$30.00" Vc usa sistema monetário com centavos no servidor? Link to comment
DNL291 Posted March 7, 2019 Share Posted March 7, 2019 2 minutes ago, OverKILL said: Me parece que tem uns end a mais ali na função 'adminchat' Sim. @Laluis23 Lembre-se de usar o comando /debugscript 3 in-game da próxima vez. 1 Link to comment
Jonas^ Posted March 7, 2019 Share Posted March 7, 2019 (edited) Tente indentar o código @Laluis23 pra ficar mais fácil de entender e achar os erros exemplo: local ComandoDoChatGlobal = "olx" function adminchat (thePlayer, _, ...) local tbl = {...} local valor = tbl[#tbl] table.remove(tbl) local message = table.concat (tbl, " ") if (isPlayerOnGroup (thePlayer)) then conta = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup ("user."..conta, aclGetGroup ("Console")) then outputChatBox ("#838B83[ #A020F0O#9ACD32L#FFA500X #838B83 ]#ffffff #00FF00» : #ffffffO Jogador #00FF00"..getPlayerName(thePlayer).. ", #ffffffestá vendendo #ffffff #DAA520"..message, player, 255, 255, 255, true) elseif isObjectInACLGroup ("user."..conta, aclGetGroup ("Everyone")) then outputChatBox ("#838B83[ #A020F0O#9ACD32L#FFA500X #838B83 ]#ffffff #00FF00» : #ffffffO Jogador #00FF00"..getPlayerName(thePlayer).. ", #ffffffestá vendendo #ffffff #DAA520"..message, player, 255, 255, 255, true) end end setElementData (thePlayer, "Chat:Avisado", true) setElementData (thePlayer, "Chat:Delay1", true) setTimer (setElementData, 5000, 1, thePlayer, "Chat:Delay1", false) end addCommandHandler (ComandoDoChatGlobal, adminchat) function isPlayerOnGroup (thePlayer) local account = getPlayerAccount (thePlayer) local inGroup = false for _, group in ipairs ( { "Everyone" } ) do if isObjectInACLGroup ( "user.".. getAccountName (account), aclGetGroup (group)) then inGroup = true break end end return inGroup end Edited March 7, 2019 by OverKILL Correção. Link to comment
Jonas^ Posted March 7, 2019 Share Posted March 7, 2019 Tem +1 problema aí, use /debugscript 3 tente descobrir. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now