zMpyster Posted January 30, 2019 Share Posted January 30, 2019 13 minutes ago, kevincouto6 said: OKay funcionou obrigado, porem o outro poblema e assim player 1 plantou 1 planta player 2 plantou 2 plantas e completou, as plantas dele foram destruidos tudo coretamente, player1 apos o player 2 completar , player1 plantou e quando chegou na contidade total de 2, foi completar nãa destruiu todos. espera que consiga me entender. No debug aparece esse erro GUImission/server.lua:176: Bad argument @ 'destroyElement' [Expected element at argument 1, got nill] local plants = {} local plants1 = {} local indexPl = {} function iniciarFarm8 ( client, x, y, z ) if not indexPl[client] then indexPl[client] = 1 else indexPl[client] = indexPl[client] + 1 end plants[client and indexPl[client]] = createObject ( 862, x , y , z - 1 , 0, 0, 0 ) setElementData( client, "Trabalho8", true, false ) animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false) end addEvent ("iniciaJob8", true) addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8) function plantDestroy ( thePlayer ) if plants[thePlayer and indexPl[thePlayer]] and isElement(plants[thePlayer and indexPl[thePlayer]] ) and getElementModel(plants[thePlayer and indexPl[thePlayer]] ) == 862 then local numero = tonumber(indexPl[thePlayer]) for i=1,numero do destroyElement ( plants[thePlayer and indexPl[thePlayer]] ) indexPl[thePlayer] = indexPl[thePlayer] -1 end end end addEvent ("onDestroyElement", true) addEventHandler ("onDestroyElement", getRootElement(), plantDestroy) Não testei, se tiver algum erro me fale Link to comment
kevincouto6 Posted January 31, 2019 Author Share Posted January 31, 2019 Continua o mesmo erro, esse erro so acontece quando tem dois fazendo ao mesmo tempo, plantei 1 planto o outro jogador vai la e planta 2 e completa quando eu plantar a segunda para completar não vai funcionar vai aparecer o erro GUImission/server.lua:181: Bad argument @ 'destroyElement' [Expected element at argument 1, got nill] aparace conforme a quantidade de plantas que não foi destuida Link to comment
zMpyster Posted January 31, 2019 Share Posted January 31, 2019 17 minutes ago, kevincouto6 said: Continua o mesmo erro, esse erro so acontece quando tem dois fazendo ao mesmo tempo, plantei 1 planto o outro jogador vai la e planta 2 e completa quando eu plantar a segunda para completar não vai funcionar vai aparecer o erro GUImission/server.lua:181: Bad argument @ 'destroyElement' [Expected element at argument 1, got nill] aparace conforme a quantidade de plantas que não foi destuida Aé, acabei me esquecendo, quando coloca "and" automaticamente o valor vira o ultimo, ou seja dessa forma não mudou nada o problema local plants = {} local plants1 = {} local indexPl = {} function iniciarFarm8 ( client, x, y, z ) if not indexPl[client] then indexPl[client] = 1 else indexPl[client] = indexPl[client] + 1 end newIndex = getPlayerName(client) .."".. indexPl[client] plants[newIndex] = createObject ( 862, x , y , z - 1 , 0, 0, 0 ) setElementData( client, "Trabalho8", true, false ) animation = setPedAnimation(source, "medic", "CPR", -1, false, false, false, false) end addEvent ("iniciaJob8", true) addEventHandler ("iniciaJob8", getRootElement(), iniciarFarm8) function plantDestroy ( thePlayer ) newIndex = getPlayerName(thePlayer) .."".. indexPl[thePlayer] if plants[newIndex] and isElement(plants[newIndex] ) and getElementModel(plants[newIndex] ) == 862 then local numero = tonumber(indexPl[thePlayer]) for i=1,numero do destroyElement ( plants[newIndex] ) indexPl[thePlayer] = indexPl[thePlayer] -1 newIndex = getPlayerName(thePlayer) .."".. indexPl[thePlayer] end end end addEvent ("onDestroyElement", true) addEventHandler ("onDestroyElement", getRootElement(), plantDestroy) Tente dessa forma, o ruim mesmo, é que eu não tenho como testar, ai tenho que ficar mandando sempre kk 1 Link to comment
kevincouto6 Posted January 31, 2019 Author Share Posted January 31, 2019 Agora funcionou muito obrigado Link to comment
kevincouto6 Posted February 1, 2019 Author Share Posted February 1, 2019 Desculpe voltar, mas não sei o que fazer estava fazendo os detalhes finais e me deparei com um problema " onClientPlayerQuit " " onPlayerQuit " como fazer com que as plantas sejam destruidas, não e possivel verificar se as tabelas e o player quando ele se desconnect então sabem como posso fazer ? Link to comment
zMpyster Posted February 1, 2019 Share Posted February 1, 2019 24 minutes ago, kevincouto6 said: Desculpe voltar, mas não sei o que fazer estava fazendo os detalhes finais e me deparei com um problema " onClientPlayerQuit " " onPlayerQuit " como fazer com que as plantas sejam destruidas, não e possivel verificar se as tabelas e o player quando ele se desconnect então sabem como posso fazer ? Você quer destruir as plantas quando ele sair, ou salvar na conta do player? Link to comment
kevincouto6 Posted February 1, 2019 Author Share Posted February 1, 2019 10 minutes ago, zMpyster said: Você quer destruir as plantas quando ele sair, ou salvar na conta do player? destruir é melhor assim ele tera que refazer tudo denovo, porem não tenho a minima idea de como destruir, quando o player se desconnectar Link to comment
zMpyster Posted February 1, 2019 Share Posted February 1, 2019 18 minutes ago, kevincouto6 said: destruir é melhor assim ele tera que refazer tudo denovo, porem não tenho a minima idea de como destruir, quando o player se desconnectar function plantDestroyIfPlayerQuit () newIndex = getPlayerName(source) .."".. indexPl[source] if plants[newIndex] and isElement(plants[newIndex] ) and getElementModel(plants[newIndex] ) == 862 then local numero = tonumber(indexPl[source]) for i=1,numero do destroyElement ( plants[newIndex] ) indexPl[source] = indexPl[source] -1 newIndex = getPlayerName(source) .."".. indexPl[source] end end end addEventHandler ("onPlayerQuit", getRootElement(), plantDestroyIfPlayerQuit) Se essa for sua ideia, tente assim. Link to comment
kevincouto6 Posted February 1, 2019 Author Share Posted February 1, 2019 (edited) 7 minutes ago, zMpyster said: Se essa for sua ideia, tente assim. funcionou, Vlw ae manin (espera para de incomodar agr ) vlw mesmo Edited February 1, 2019 by kevincouto6 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