yMassai Posted June 28, 2012 Posted June 28, 2012 ------ Janela ------ function MilitarArmy() janelaArmy = guiCreateWindow(260,180,300,250,"",false) guiWindowSetSizable(janelaArmy,false) guiSetVisible (janelaArmy, false ) --label armylabel = guiCreateLabel(15,30,300,300,"....",false,janelaArmy) ---botões botaok = guiCreateButton(10,210,135,20,"OK",false,janelaArmy) botaoc = guiCreateButton(158,210,135,20,"Cancelar",false,janelaArmy) end addEventHandler( "onClientResourceStart", root, MilitarArmy) ------ Ped e Marker------ armyped = createPed(287, 94.12652, 1916.45544, 18.04716, 90) armymarker = createMarker( 94.12652, 1916.45544, 17.04716, "cylinder", 1.5, 0, 255, 0, 170) setElementFrozen ( armyped, true ) addEventHandler ( "onClientPedDamage", armyped, cancelEvent ) ---- Funções ----- function armyjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(janelaArmy) then guiSetVisible(janelaArmy, true) showCursor(true) end end end addEventHandler("onClientMarkerHit", armymarker, armyjob) addEventHandler('onClientGUIClick', root, function () if (source == botaoc ) then guiSetVisible ( janelaArmy, false ) showCursor ( false ) if (source == botaok ) then guiSetVisible ( janelaArmy, false ) showCursor ( false ) end end end ) n sei qual é o erro, eu aperto no botão "ok" e não fecha a janela. Community Profile MTA:SA = Click Here
DNL291 Posted June 29, 2012 Posted June 29, 2012 ------ Janela ------ function MilitarArmy() janelaArmy = guiCreateWindow(260,180,300,250,"",false) guiWindowSetSizable(janelaArmy,false) guiSetVisible (janelaArmy, false ) --label armylabel = guiCreateLabel(15,30,300,300,"....",false,janelaArmy) ---botões botaok = guiCreateButton(10,210,135,20,"OK",false,janelaArmy) botaoc = guiCreateButton(158,210,135,20,"Cancelar",false,janelaArmy) end addEventHandler( "onClientResourceStart", resourceRoot, MilitarArmy) ------ Ped e Marker------ armyped = createPed(287, 94.12652, 1916.45544, 18.04716, 90) armymarker = createMarker( 94.12652, 1916.45544, 17.04716, "cylinder", 1.5, 0, 255, 0, 170) setElementFrozen ( armyped, true ) addEventHandler ( "onClientPedDamage", armyped, cancelEvent ) ---- Funções ----- function armyjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(janelaArmy) then showWindow(true) end end end addEventHandler("onClientMarkerHit", armymarker, armyjob) addEventHandler('onClientGUIClick', root, function () if (source == botaoc ) then showWindow(false) elseif (source == botaok ) then showWindow(false) end end ) function showWindow(show) guiSetVisible(janelaArmy, show) showCursor(show) end Você leu oque eu postei no tópico sobre o resource WantedLevel? você continua utilizando root no evento onClientResourceStart. O correto é resourceRoot, já que você não quer que o evento seja acionado sempre que algum resource for iniciado. Please do not PM me with scripting related question nor support, use the forums instead.
yMassai Posted June 29, 2012 Author Posted June 29, 2012 você poderia me explicar mais sobre root? Community Profile MTA:SA = Click Here
DNL291 Posted June 29, 2012 Posted June 29, 2012 Você usou root no evento onClientResourceStart. então, o evento será acionado sempre que algum resource client-side for iniciado, ou seja o certo seria resourceRoot (variavel pre-definida de getResourceRootElement(getThisResource())). ou você também pode fazer isso: addEventHandler("onClientResourceStart", root, function (startedResource) if (startedResource == getThisResource()) then ... end end ) Isso é apenas para assegurar-se que o evento será acionado apenas quando esse mesmo resource for iniciado. "onClientResourceStart": parametro, resource startedResource. Source do evento é o resource iniciado. Como você quer apenas acionar para quando o próprio resource for iniciado você deve usar resourceRoot Please do not PM me with scripting related question nor support, use the forums instead.
yMassai Posted June 30, 2012 Author Posted June 30, 2012 Utilizando o "setPlayerTeam" como posso dar um team já existente para um jogador? um exemplo: setPlayerTeam(source,Staff) o jogador n pega o team, como posso fazer pegar um team já criado em outro recurso? Community Profile MTA:SA = Click Here
DNL291 Posted June 30, 2012 Posted June 30, 2012 Alguma mensagem 'sai' no debugmode, alertando erro na função setPlayerTeam? Não sei se o elemento player (source) no argumento está correto, fora isso parece estar certo, na verdade eu nunca utilizei setPlayerTeam com o argumento de um team criado em outro script, então não posso dizer se funcionará. mas o argumento pedido é Team, então acho que funciona. verifique se pode ter algum erro no nome do team, maiúscula/minuscula. Edit: setPlayerTeam é server-side apenas, certifique-se que não esteja usando no client-side. Please do not PM me with scripting related question nor support, use the forums instead.
Anderl Posted June 30, 2012 Posted June 30, 2012 Staff é um ponteiro para um team? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
yMassai Posted June 30, 2012 Author Posted June 30, 2012 Staff é um team já criado em outro script, não é o nome do evento mas sim o nome do team. ------ Janela ------ function MilitarArmy() janelaArmy = guiCreateWindow(260,180,300,250,"",false) guiWindowSetSizable(janelaArmy,false) guiSetVisible (janelaArmy, false ) --label armylabel = guiCreateLabel(15,30,300,300,"....",false,janelaArmy) ---botões botaok = guiCreateButton(10,210,135,20,"OK",false,janelaArmy) botaoc = guiCreateButton(158,210,135,20,"Cancelar",false,janelaArmy) end addEventHandler( "onClientResourceStart", resourceRoot, MilitarArmy) ------ Ped e Marker------ armyped = createPed(287, 94.12652, 1916.45544, 18.04716, 90) armymarker = createMarker( 94.12652, 1916.45544, 17.04716, "cylinder", 1.5, 0, 255, 0, 170) setElementFrozen ( armyped, true ) addEventHandler ( "onClientPedDamage", armyped, cancelEvent ) ---- Funções ----- function armyjob(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) then if not guiGetVisible(janelaArmy) then showWindow(true) end end end addEventHandler("onClientMarkerHit", armymarker, armyjob) addEventHandler('onClientGUIClick', root, function () if (source == botaoc ) then showWindow(false) elseif (source == botaok ) then showWindow(false) triggerServerEvent("armyFA",localPlayer) end end ) function showWindow(show) guiSetVisible(janelaArmy, show) showCursor(show) end function joinArmy() setPlayerTeam(source,Staff) setElementModel(source, 287) giveWeapon ( source, 3 ) setElementData( source, "Ocupação", "Forças Armadas", true ) outputChatBox("Você se juntou ao grupo das Forças Armadas.",source,0,255,0) end addEvent("armyFA", true) addEventHandler("armyFA",root,joinArmy) Community Profile MTA:SA = Click Here
Anderl Posted June 30, 2012 Posted June 30, 2012 Se Staff é o nome do team então está errado. Você tem que usar ponteiros para o team. Use getTeamFromName: local team = getTeamFromName( 'Staff' ); "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
yMassai Posted June 30, 2012 Author Posted June 30, 2012 aqui eu utilizei o setElementData setElementData( source, "Ocupação", "Forças Armadas", true ) isso da uma ocupação no scoreboard como eu posso salvar a ocupação do jogador quando sair do jogo e entrar na mesma conta? Community Profile MTA:SA = Click Here
Anderl Posted June 30, 2012 Posted June 30, 2012 Salve na conta... setAccountData ...quando o jogador sair e... getAccountData setElementData ...quando o jogador entrar. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
yMassai Posted July 1, 2012 Author Posted July 1, 2012 function onPlayerQuit ( ) local jogadoracc = getPlayerAccount ( source ) if ( jogadoracc ) and not isGuestAccount ( jogadoracc ) then setAccountData ( jogadoracc, "army.job", armyFA ) end end function onPlayerLogin (_, jogadoracc ) if ( jogadoracc ) then local playermoney = getAccountData ( jogadoracc, "army.job" ) if ( armyFA ) then setElementData ( jogadoracc, "aemy.job", armyFA ) end end end addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) assim? Community Profile MTA:SA = Click Here
Anderl Posted July 1, 2012 Posted July 1, 2012 Não, lol. Tenho quase a certeza que você copiou esse código, certo? "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
yMassai Posted July 27, 2012 Author Posted July 27, 2012 pizzao = setElementData( source, "Occupation", "Entregador de Pizza", true ) function pQuit ( ) setAccountData(source,"job",pizzao) end addEventHandler ( "onPlayerQuit", root, pQuit ) function onPlayerLogin ( ) getAccountData ( pizzao, "job" ) setElementData (source, pizzao) end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) Qual o erro?? '-' Community Profile MTA:SA = Click Here
Cadu12 Posted July 27, 2012 Posted July 27, 2012 Todo. pizzao = createTeam( "Entregador de Pizza" ) function pQuit ( ) local team = getPlayerTeam ( source ) if ( team ) then setAccountData ( source, "job", getTeamName ( team ) ) end end addEventHandler ( "onPlayerQuit", root, pQuit ) function onPlayerLogin ( _, acc ) local teamName = getAccountData ( acc, "job" ) if ( teamName and #teamName ~= 0 ) then local team = getTeamFromName ( teamName ) if ( team ) then setPlayerTeam ( source, team ) end end end addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) Ingame nick: Cadu12
yMassai Posted July 27, 2012 Author Posted July 27, 2012 desculpe mas eu não quero salvar o team e sim a Occupation o team eu já salvo se poder me ajudar com relação a Ocuppation agradeço team eu tenho outro modo de salvar. Community Profile MTA:SA = Click Here
Hassam Posted August 17, 2012 Posted August 17, 2012 Tenta fazer isso: function pQuit ( ) local team = getElementData(localPlayer, "Ocupação") if ( team ) then setAccountData ( source, "Ocupação1", team ) end end addEventHandler ( "onPlayerQuit", root, pQuit ) function onPlayerLogin ( _, acc ) local teamName = getAccountData ( acc, "Ocupação1" ) if ( teamName and #teamName ~= 0) then local team = getElementData (source, "Ocupação") if ( team ) then setElementData ( source, team ) end end end addEventHandler ( "onPlayerLogin", root, onPlayerLogin ) Antes disso, faz assim, setElementData e setPlayerTeam, ou senão nao vai funcionar
DNL291 Posted August 17, 2012 Posted August 17, 2012 setAccountData na linha 5, o primeiro argumento está errado, a source do evento 'onPlayerQuit' é o jogador e não a conta. Na função onPlayerLogin, ' #teamName ~= 0 ' não é necessário usar o operador de comprimento '#', basta usar a condition false/nil. Não faz sentido definir novamente o mesmo valor obtido da função getElementData. Além disso, setElementData falta o 2° argumento (key). Please do not PM me with scripting related question nor support, use the forums instead.
Anderl Posted August 17, 2012 Posted August 17, 2012 Além disso, localPlayer é uma variavél predefinida de "getLocalPlayer" e é client-side, não server-side. "[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007
Recommended Posts