manawydan Posted April 1, 2013 Posted April 1, 2013 ola, bem, eu estou tentando cria uma barra de exp usando o recurso "exp_system(criado por solidsnake14)". meu problema é que não consigo passar os pontos de exp do server para o cliente. como poderei fazer isso? obrigado
DNL291 Posted April 2, 2013 Posted April 2, 2013 Você pode enviar esses pontos usando a função triggerClientEvent/triggerServerEvent ou setElementData dependendo do caso. Se estiver com algum problema para enviar esse valor, mostre o código que você está tentando.
manawydan Posted April 2, 2013 Author Posted April 2, 2013 bom, eu estou exportando função do recurso "exp_system" a exp eu consuigo pegar usando getElementData.o que eu não consigo é local level = exports.exp_system:getPlayerLevel ( thePlayer ) local name, expreq = exports.exp_system:getLevelData ( level ) neste exemplo eu queria poder pegar o expreq( que é a exp requerida pra subir de level) obrigado.
manawydan Posted April 2, 2013 Author Posted April 2, 2013 vou tentar explicar melhor. a unica coisa que eu não consigo descobrir é a exp necessaria para aumentar de level. como o script do exp_system é compilado to tendo dificuldade
DNL291 Posted April 3, 2013 Posted April 3, 2013 Você pode tentar dessa forma. Server: local level = exports.exp_system:getPlayerLevel ( thePlayer ) local name, expreq = exports.exp_system:getLevelData ( level ) triggerClientEvent(thePlayer, "onGetLevelData", thePlayer, name, expreq) Client: addEvent("onGetLevelData", true) addEventHandler("onGetLevelData", root, function(name, expreq) outputChatBox( name ..": ".. expreq ) end ) Ou assim. Server: local level = exports.exp_system:getPlayerLevel ( thePlayer ) local name, expreq = exports.exp_system:getLevelData ( level ) setElementData(thePlayer, "levelName", name) setElementData(thePlayer, "expRequired", expreq) Client: local name = getElementData(thePlayer, "levelName") local expreq = getElementData(thePlayer, "expRequired") outputChatBox( name ..": ".. expreq )
manawydan Posted April 3, 2013 Author Posted April 3, 2013 obrigado pela ajuda. mais ainda estou confuso. qual o problema aq? client local sx, sy = guiGetScreenSize() function puxaExperience() dxDrawRectangle((310/1024)*sx,(698/768)*sy,(481/1024)*sx,(36/768)*sy,tocolor(255,50,25,35),false) dxDrawRectangle((315/1024)*sx,(703/768)*sy,(472/1024)*sx,(26/768)*sy,tocolor(0,0,0,255),false) local experience = getElementData(localPlayer,"exp") or 0 local experience_n = getElementData(localPlayer, "expRequired")or 0 local level = getElementData(localPlayer,"level") or 1 local percent = (experience / experience_n * 100) if (percent >= 100) then percent = 100 elseif (experience_n < 1) then percent = 0 end dxDrawRectangle((320/1024)*sx,(706/768)*sy,(tonumber(percent)*4.64/1024)*sx,(20/768)*sy,tocolor(2,255,255,75),false) dxDrawBorderedText("Level: ".. tostring(level) .." | Pontos experiencia: ".. tostring(experience) .." > ".. tostring(experience_n),(430/1024)*sx,(707/768)*sy,(667/1024)*sx,(724/768)*sy,tocolor(0,0,0,255),(sx/1024)*0.6,"bankgothic","center","center",false,false,false) end addEventHandler("onClientRender",root,puxarExperience) server addEvent ( "onZombieWasted", true ) addEventHandler ( "onZombieWasted", root, function ( theKiller ) if (getElementType ( theKiller ) == "player") then exports.exp_system:addPlayerEXP ( theKiller, 5 ) end end ) function NivelR(dataName,oldValue) if getElementType(source) == "player" then local experience = getElementData(source,"exp") local level = exports.exp_system:getPlayerLevel ( thePlayer ) local name, expreq = exports.exp_system:getLevelData ( level ) setElementData(source, "levelName", name) setElementData(source, "expRequired", expreq) end end addEventHandler("onElementDataChange",getRootElement(),NivelR) o unico que não aparece e a exp necessaria pra aumentar de nivel
DNL291 Posted April 4, 2013 Posted April 4, 2013 O lado server tem alguns problemas, a source do evento onElementDataChange não é o jogador. O jogador não foi definido na função exportada getPlayerLevel. Foi definida a key levelName na função setElementData do lado server, E você está usando outra key (chave) no lado client.
manawydan Posted April 4, 2013 Author Posted April 4, 2013 o erro do theplayer eu coloquei como source. ja o outro erro não entendi.
DNL291 Posted April 5, 2013 Posted April 5, 2013 No código que você mostrou, você colocou: setElementData(source, "levelName", name), e usou: getElementData(localPlayer,"level") no lado client. Nem preciso dizer que o erro é a key que está diferente. Se você está usando o evento onElementDataChange na função NivelR (como no código mostrado), então o argumento thePlayer está errado porque não é a source.
manawydan Posted April 5, 2013 Author Posted April 5, 2013 obrigado mudei umas coisas e agora ta funcionando. desculpe fazer muitas perguntas( as vezes eu empaco com coisa boba).
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