zThyPvpTK Posted July 11, 2019 Author Posted July 11, 2019 11 hours ago, DNL291 said: Tem o isElement ali acima, se você mudar pra uma boolean vai precisar revisar essa linha. Remova também o "local thePlayer = getPlayerFromPartialName (playerName )" do código já que esse não será usado. Tente: function comprarv (source, cmd) if venda[source] then outputChatBox ( "* Erro: So Pode Comprar Uma Venda!", source ) else if getPlayerMoney(source) >= 1000 then -- verifique o dinheiro já que se trata de uma compra outputChatBox ( "* Venda Comprada /vendar [Jogador]", source ) venda[source] = true takePlayerMoney( source, 1000 ) else outputChatBox( "["..Comando_Revistar2.."] Dinheiro insuficiente!", source, 230, 30, 30 ) end endendaddCommandHandler ( Comando_Revistar2, comprarv ) bom oque tenho que colocar no inicio venda[source] = false e deu erro no debuscript 3 dai coloquei venda = false saiu o erro soque dai deu outro erro no if venda[source] then
DNL291 Posted July 11, 2019 Posted July 11, 2019 5 hours ago, zThyPvpTK said: e deu erro no debuscript 3 dai coloquei venda = false Isso é uma variável, mas deve ser uma tabela, então é lógico que não vai funcionar. O que deve ser feito é o outro comando, após utilizar o comando, você remove o valor de venda[ thePlayer ]
zThyPvpTK Posted July 11, 2019 Author Posted July 11, 2019 45 minutes ago, DNL291 said: Isso é uma variável, mas deve ser uma tabela, então é lógico que não vai funcionar. O que deve ser feito é o outro comando, após utilizar o comando, você remove o valor de venda[ thePlayer ] coloquei isso no começo para começar como false n precisa colocar aquilo no começo ?
DNL291 Posted July 11, 2019 Posted July 11, 2019 Seguindo a lógica do seu código, você deve colocar venda[source] = nil no comando de usar a venda. Exemplo: function cmdvendar ( source, cmd ) if not venda[source] then return outputChatBox( "Você não possui venda!", source ) end outputChatBox ( "Você Foi Vendado", source ) venda[source] = nil end addCommandHandler ( "vendar", cmdvendar )
zThyPvpTK Posted July 12, 2019 Author Posted July 12, 2019 Just now, DNL291 said: Seguindo a lógica do seu código, você deve colocar venda[source] = nil no comando de usar a venda. Exemplo: function cmdvendar ( source, cmd ) if not venda[source] then return outputChatBox( "Você não possui venda!", source ) end outputChatBox ( "Você Foi Vendado", source ) venda[source] = nil end addCommandHandler ( "vendar", cmdvendar ) venda[source] = nil e true ? e tenho que tirar o venda = false do começo ?
DNL291 Posted July 12, 2019 Posted July 12, 2019 No topo do script só é criada a table. local venda = {} O jogador comprou venda? venda[source] = true quando usar: venda[source] = nil -- Mostre o seu código completo.
zThyPvpTK Posted July 13, 2019 Author Posted July 13, 2019 (edited) 16 hours ago, DNL291 said: No topo do script só é criada a table. local venda = {} O jogador comprou venda? venda[source] = true quando usar: venda[source] = nil -- Mostre o seu código completo. ve agr se ta certo tudo -------------------------------------------------------------------------------------------- local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) Comando_Revistar = "vendar" Comando_Revistar2 = "comprar" local venda = {} function getPlayerFromPartialName ( name ) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function comprarv (source, cmd) if venda[source] then outputChatBox ( "* Erro: So Pode Comprar Uma Venda!", source ) else if getPlayerMoney(source) >= 1000 then -- verifique o dinheiro já que se trata de uma compra outputChatBox ( "* Venda Comprada /vendar [Jogador]", source ) venda[source] = true takePlayerMoney( source, 1000 ) else outputChatBox( "["..Comando_Revistar2.."] Dinheiro insuficiente!", source, 230, 30, 30 ) end end end addCommandHandler ( Comando_Revistar2, comprarv ) function Revistar ( source, cmd, player ) if venda[source] then if not player then return outputChatBox( "Sintaxe: /"..Comando_Revistar.." <jogador>", source ) else local Jogador = getPlayerFromPartialName ( player ) if Jogador then local cx,cy,cz = getElementPosition(Jogador) local x,y,z = getElementPosition(source) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if dist <= 5 then outputChatBox ( "Você Vendou Um Jogador [-1 Venda]", source ) outputChatBox ( "Você Foi Vendado", Jogador ) fadeCamera( Jogador, false, 1 ) local playerX, playerY, playerZ = getElementPosition ( localPlayer ) -- Get our player's coordinates. local playerZoneName = getZoneName ( playerX, playerY, playerZ ) -- Get name of the zone the player is in. dxDrawText ( playerZoneName, 44, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) venda[source] = nil else outputChatBox("#bebebeChegue mais perto do jogador!", source, 255, 255, 255, true) end end end end end addCommandHandler ( Comando_Revistar, Revistar ) Edited July 13, 2019 by zThyPvpTK
DNL291 Posted July 13, 2019 Posted July 13, 2019 A tabela venda + verificação tá certo, mas essas funções você vai ter que fazer no lado cliente: guiGetScreenSize dxDrawText E chame o evento cliente com triggerClientEvent E no comando vendar você vai precisar verificar se o jogador alvo é diferente do que usou o comando.
zThyPvpTK Posted July 13, 2019 Author Posted July 13, 2019 1 hour ago, DNL291 said: A tabela venda + verificação tá certo, mas essas funções você vai ter que fazer no lado cliente: guiGetScreenSize dxDrawText E chame o evento cliente com triggerClientEvent E no comando vendar você vai precisar verificar se o jogador alvo é diferente do que usou o comando. testei sem o dram txt e o outro so pra dar uma msg e deu erro no debugscript 3 falando que local venda = {} ta faltando " "
DNL291 Posted July 13, 2019 Posted July 13, 2019 Qual erro mostra exatamente? Essa linha não tem nenhum erro.
zThyPvpTK Posted July 13, 2019 Author Posted July 13, 2019 1 hour ago, DNL291 said: Qual erro mostra exatamente? Essa linha não tem nenhum erro. e que to traduzindo mais ta falando que ta faltando "" esses negocio ai n to com mta aberto se n te mandava print
DNL291 Posted July 14, 2019 Posted July 14, 2019 Manda aqui seu código atualizado, você disse que removeu as funções, depois disso deve ter aparecido o bug.
zThyPvpTK Posted July 14, 2019 Author Posted July 14, 2019 11 minutes ago, DNL291 said: Manda aqui seu código atualizado, você disse que removeu as funções, depois disso deve ter aparecido o bug. -------------------------------------------------------------------------------------------- local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) Comando_Revistar = "vendar" Comando_Revistar2 = "comprar" local venda = "{}" function quitPlayer ( quitType ) -- send the message to the server telling players that the player has left. outputChatBox ( getPlayerName(source).. " has left the server (" .. quitType .. ")" ) entrar[source] = true end addEventHandler ( "onPlayerQuit", root, quitPlayer ) function getPlayerFromPartialName ( name ) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function comprarv (source, cmd) if venda[source] then outputChatBox ( "* Erro: So Pode Comprar Uma Venda!", source ) else if getPlayerMoney(source) >= 1000 then -- verifique o dinheiro já que se trata de uma compra outputChatBox ( "* Venda Comprada /vendar [Jogador]", source ) venda[source] = true takePlayerMoney( source, 1000 ) else outputChatBox( "["..Comando_Revistar2.."] Dinheiro insuficiente!", source, 230, 30, 30 ) end end end addCommandHandler ( Comando_Revistar2, comprarv ) function Revistar ( source, cmd, player ) if venda[source] then if not player then return outputChatBox( "Sintaxe: /"..Comando_Revistar.." <jogador>", source ) else local Jogador = getPlayerFromPartialName ( player ) if Jogador then local cx,cy,cz = getElementPosition(Jogador) local x,y,z = getElementPosition(source) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if dist <= 5 then outputChatBox ( "Você Vendou Um Jogador [-1 Venda]", source ) outputChatBox ( "Você Foi Vendado", Jogador ) venda[source] = nil else outputChatBox("#bebebeChegue mais perto do jogador!", source, 255, 255, 255, true) end end end end end addCommandHandler ( Comando_Revistar, Revistar ) coloquei os "" pra ver se ia e deu erro
Other Languages Moderators Lord Henry Posted July 14, 2019 Other Languages Moderators Posted July 14, 2019 Essa sua linha 6 não faz sentido. Você só está chutando código sem entender o que está fazendo.
DNL291 Posted July 14, 2019 Posted July 14, 2019 É por causa desta linha: local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) Remova ela, como eu disse; o erro não foi com a tabela e a sua modificação foi totalmente errada. 4 hours ago, DNL291 said: guiGetScreenSize dxDrawText Elas vão em outro arquivo de script que será o client. E também a linha 11, onde está: entrar[source] = true Vai ocorrer erro, remova isso. E "onPlayerQuit" você deve fazer assim na verdade: function quitPlayer( ) if venda[source] then venda[source] = nil end end addEventHandler ( "onPlayerQuit", root, quitPlayer )
zThyPvpTK Posted July 14, 2019 Author Posted July 14, 2019 21 minutes ago, DNL291 said: É por causa desta linha: local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) Remova ela, como eu disse; o erro não foi com a tabela e a sua modificação foi totalmente errada. Elas vão em outro arquivo de script que será o client. E também a linha 11, onde está: entrar[source] = true Vai ocorrer erro, remova isso. E "onPlayerQuit" você deve fazer assim na verdade: function quitPlayer( ) if venda[source] then venda[source] = nil end end addEventHandler ( "onPlayerQuit", root, quitPlayer ) remover o local screenWidth, screenHeight = guiGetScreenSize ( ) o quit player e outra coisa que vo fazer e outra variavel 25 minutes ago, Lord Henry said: Essa sua linha 6 não faz sentido. Você só está chutando código sem entender o que está fazendo. sim realmente como deu erro e não queria mais incomodar vcs tentei colocar "" pra ver se ia
DNL291 Posted July 14, 2019 Posted July 14, 2019 5 minutes ago, zThyPvpTK said: remover o local screenWidth, screenHeight = guiGetScreenSize ( ) o quit player e outra coisa que vo fazer e outra variavel sim realmente como deu erro e não queria mais incomodar vcs tentei colocar "" pra ver se ia Resumindo, tente este: -------------------------------------------------------------------------------------------- Comando_Revistar = "vendar" Comando_Revistar2 = "comprar" local venda = {} function quitPlayer( ) if venda[source] then venda[source] = nil end end addEventHandler ( "onPlayerQuit", root, quitPlayer ) function comprarv (source, cmd) if venda[source] then outputChatBox ( "* Erro: So Pode Comprar Uma Venda!", source, 230, 30, 30 ) else if getPlayerMoney(source) >= 1000 then -- verifique o dinheiro já que se trata de uma compra outputChatBox ( "* Venda Comprada /vendar [Jogador]", source, 0, 230, 0 ) venda[source] = true takePlayerMoney( source, 1000 ) else outputChatBox( "["..Comando_Revistar2.."] Dinheiro insuficiente!", source, 230, 30, 30 ) end end end addCommandHandler ( Comando_Revistar2, comprarv ) function Revistar ( source, cmd, player ) if venda[source] then if not player then return outputChatBox( "Sintaxe: /"..Comando_Revistar.." <jogador>", source ) end local Jogador = getPlayerFromPartialName ( player ) if isElement(Jogador) then local cx,cy,cz = getElementPosition(Jogador) local x,y,z = getElementPosition(source) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if dist <= 5 then outputChatBox ( "Você Vendou Um Jogador [-1 Venda]", source ) outputChatBox ( "Você Foi Vendado", Jogador ) venda[source] = nil else outputChatBox("#bebebeChegue mais perto do jogador!", source, 255, 255, 255, true) end end end end addCommandHandler ( Comando_Revistar, Revistar ) function getPlayerFromPartialName ( name ) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Se funcionar você parte para a outra etapa, do trigger.
zThyPvpTK Posted July 14, 2019 Author Posted July 14, 2019 39 minutes ago, DNL291 said: Resumindo, tente este: --------------------------------------------------------------------------------------------Comando_Revistar = "vendar"Comando_Revistar2 = "comprar"local venda = {}function quitPlayer( ) if venda[source] then venda[source] = nil endendaddEventHandler ( "onPlayerQuit", root, quitPlayer )function comprarv (source, cmd) if venda[source] then outputChatBox ( "* Erro: So Pode Comprar Uma Venda!", source, 230, 30, 30 ) else if getPlayerMoney(source) >= 1000 then -- verifique o dinheiro já que se trata de uma compra outputChatBox ( "* Venda Comprada /vendar [Jogador]", source, 0, 230, 0 ) venda[source] = true takePlayerMoney( source, 1000 ) else outputChatBox( "["..Comando_Revistar2.."] Dinheiro insuficiente!", source, 230, 30, 30 ) end endendaddCommandHandler ( Comando_Revistar2, comprarv )function Revistar ( source, cmd, player ) if venda[source] then if not player then return outputChatBox( "Sintaxe: /"..Comando_Revistar.." <jogador>", source ) end local Jogador = getPlayerFromPartialName ( player ) if isElement(Jogador) then local cx,cy,cz = getElementPosition(Jogador) local x,y,z = getElementPosition(source) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if dist <= 5 then outputChatBox ( "Você Vendou Um Jogador [-1 Venda]", source ) outputChatBox ( "Você Foi Vendado", Jogador ) venda[source] = nil else outputChatBox("#bebebeChegue mais perto do jogador!", source, 255, 255, 255, true) end end endendaddCommandHandler ( Comando_Revistar, Revistar )function getPlayerFromPartialName ( name ) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end endend Se funcionar você parte para a outra etapa, do trigger. tentei aqui e deu erro dai tentei arrumar e deu mais erro bom no caso deu erro quando dei /comprar http://prntscr.com/oepeej
DNL291 Posted July 14, 2019 Posted July 14, 2019 O código tá certo, testei aqui e funcionou. Pode ser que você colocou no lado cliente ou esse erro é com outro código. Aqui está meu código testado: -------------------------------------------------------------------------------------------- Comando_Revistar = "vendar" Comando_Revistar2 = "comprar" local venda = {} function quitPlayer( ) if venda[source] then venda[source] = nil end end addEventHandler ( "onPlayerQuit", root, quitPlayer ) function comprarv (source, cmd) if venda[source] then outputChatBox ( "* Erro: So Pode Comprar Uma Venda!", source, 230, 30, 30 ) else if getPlayerMoney(source) >= 1000 then -- verifique o dinheiro já que se trata de uma compra outputChatBox ( "* Venda Comprada /vendar [Jogador]", source, 0, 230, 0 ) venda[source] = true takePlayerMoney( source, 1000 ) else outputChatBox( "["..cmd.."] Dinheiro insuficiente!", source, 230, 30, 30 ) end end end addCommandHandler ( Comando_Revistar2, comprarv ) function cmdvendar ( source, cmd, player ) if venda[source] then if not player then return outputChatBox( "Sintaxe: /"..cmd.." <jogador>", source,230, 30, 30 ) end local Jogador = getPlayerFromPartialName ( player ) if isElement(Jogador) then local cx,cy,cz = getElementPosition(Jogador) local x,y,z = getElementPosition(source) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if dist <= 5 then outputChatBox ( "Você Vendou Um Jogador [-1 Venda]", source, 0, 230, 0 ) outputChatBox ( "Você Foi Vendado", Jogador, 230, 230, 230 ) fadeCamera( Jogador, false, 1 ) venda[source] = nil else outputChatBox("#bebebeChegue mais perto do jogador!", source, 255, 255, 255, true) end else outputChatBox( "["..cmd.."] Jogador não encontrado!", source, 230, 30, 30 ) end else outputChatBox( "["..cmd.."] Você não possui venda!", source, 230, 30, 30 ) end end addCommandHandler ( Comando_Revistar, cmdvendar ) function getPlayerFromPartialName ( name ) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end
zThyPvpTK Posted July 14, 2019 Author Posted July 14, 2019 13 hours ago, DNL291 said: O código tá certo, testei aqui e funcionou. Pode ser que você colocou no lado cliente ou esse erro é com outro código. Aqui está meu código testado: --------------------------------------------------------------------------------------------Comando_Revistar = "vendar"Comando_Revistar2 = "comprar"local venda = {}function quitPlayer( ) if venda[source] then venda[source] = nil endendaddEventHandler ( "onPlayerQuit", root, quitPlayer )function comprarv (source, cmd) if venda[source] then outputChatBox ( "* Erro: So Pode Comprar Uma Venda!", source, 230, 30, 30 ) else if getPlayerMoney(source) >= 1000 then -- verifique o dinheiro já que se trata de uma compra outputChatBox ( "* Venda Comprada /vendar [Jogador]", source, 0, 230, 0 ) venda[source] = true takePlayerMoney( source, 1000 ) else outputChatBox( "["..cmd.."] Dinheiro insuficiente!", source, 230, 30, 30 ) end endendaddCommandHandler ( Comando_Revistar2, comprarv )function cmdvendar ( source, cmd, player ) if venda[source] then if not player then return outputChatBox( "Sintaxe: /"..cmd.." <jogador>", source,230, 30, 30 ) end local Jogador = getPlayerFromPartialName ( player ) if isElement(Jogador) then local cx,cy,cz = getElementPosition(Jogador) local x,y,z = getElementPosition(source) local dist = getDistanceBetweenPoints3D(x,y,z,cx,cy,cz) if dist <= 5 then outputChatBox ( "Você Vendou Um Jogador [-1 Venda]", source, 0, 230, 0 ) outputChatBox ( "Você Foi Vendado", Jogador, 230, 230, 230 ) fadeCamera( Jogador, false, 1 ) venda[source] = nil else outputChatBox("#bebebeChegue mais perto do jogador!", source, 255, 255, 255, true) end else outputChatBox( "["..cmd.."] Jogador não encontrado!", source, 230, 30, 30 ) end else outputChatBox( "["..cmd.."] Você não possui venda!", source, 230, 30, 30 ) endendaddCommandHandler ( Comando_Revistar, cmdvendar )function getPlayerFromPartialName ( name ) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end endend no meu client n tem nd vo testar
zThyPvpTK Posted July 14, 2019 Author Posted July 14, 2019 (edited) comprei e funcionou tava colocando uma coisa erada mais obrigado a todos que me ajudarao muito muito obrigado Edited July 14, 2019 by zThyPvpTK
DNL291 Posted July 14, 2019 Posted July 14, 2019 De nada. Se precisar de ajuda com o dx-text só postar aqui. 1
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