Serginix Posted April 17, 2011 Share Posted April 17, 2011 Hola nuevamente , me eh bajado el resource de Hunger del MTA Resources, (creador JasperNL=D) y me parecio genial la cosa esque quiero añadir mas posisciones de Hamburgesas, para quye le sea mas facil a los jugadores buscar algo de comer, el problema esque no puedo colocarlos e, X Dimension, solo aparecen en la Dimension 0, y nesecitaria modificar la Dimension para asi poder poner diferentes entratadas a las tiendas en diferentes partes de la ciudad, la parte de modificacion de las posiones se ve asi : hamburgerPositions = { {377,-68,1001.51,10}, {380.44,-8.65,1001.85,9}, {379.42,-119.65,1001.49,5} } -- The positions for the hamburger, in the style: x,y,z,interior --[[ This is the hunger script. You can add hamburgers by adding it in hamburgerPositions. It works easy, just a after it, and filling in! {x,y,z,interiorID} When it isn't the last position, it needs a "," after it yo se modificar la coordenada, pero no me da la Dimension, estaba tratando de añadir la funcion de setElementDimension pero no se si lo ubico mal o que pero el resource no me carga si se lo agrego, estube leyendo la wiki haber si de ahi puedo sacar algo... este es el resource : https://community.multitheftauto.com/index.php?p=resources&s=details&id=906 en esta semana me voy y dejo de joder un tiempo , perdonen todos las molestias y gracias por su atencion Link to comment
Castillo Posted April 17, 2011 Share Posted April 17, 2011 Es muy facil, postea todo el codigo. Link to comment
Serginix Posted April 17, 2011 Author Share Posted April 17, 2011 Ok, ya lo pude arreglar, pude colocar el objeto en otr dimension, el problema, esque ahora aparece invisible.... pero alli esta... y lo cojo y si me sube la barra de hambre, le hize unas modificaciones encuanto al original, pero quiero que la el icono (es una hamburgesa que flota en circulos como si fuera un arma) sea visible, en cualquier dimension Codigo Modificado por Mi y Traducido Para mi server que estoy tratando que sea lo mas Español Posible PD: Estroy tratando de hacer que al cojer la Hamburgesa, y se llene la barra de hambre te cobren 50, creo que esta seria la funcion takePlayerMoney ( thePlayer, 50 ) pero no sabria bien donde ubicarla....... hamburgerPositions = { {377,-68,1001.51,10,8} , {380.44,-8.65,1001.85,9}, {379.42,-119.65,1001.49,5} } -- The positions for the hamburger, in the style: x,y,z,interior --[[ This is the hunger script. You can add hamburgers by adding it in hamburgerPositions. It works easy, just a after it, and filling in! {x,y,z,interiorID,dimension} When it isn't the last position, it needs a "," after it ]]-- -- DONT CHANGE ANYTHING AFTER THIS WITHOUT KNOWLEDGE! addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), function () hungerProcess = guiCreateProgressBar(0.7763,0.28,0.1775,0.04,true) guiMoveToBack (hungerProcess) guiProgressBarSetProgress(hungerProcess,100) hungerLabel = guiCreateLabel(0.7775,0.2817,0.1737,0.0367,"Estado de Hambre",true) guiLabelSetColor(hungerLabel,255,255,255) guiLabelSetVerticalAlign(hungerLabel,"center") guiLabelSetHorizontalAlign(hungerLabel,"center",false) guiSetFont(hungerLabel,"default-small") for i,v in ipairs (hamburgerPositions) do local hamburger = createPickup (v[1],v[2],v[3],3,2768,100) local hamburgerMarker = createMarker (v[1],v[2],v[3],"corona",1,255,255,0,80) setElementData (hamburgerMarker,"HAMBURGER!",true) setElementInterior (hamburgerMarker,v[4]) setElementInterior (hamburger,v[4]) end setTimer (dropDownHungerState,45000,0,getLocalPlayer()) end) function setHungerState (player,hungerState) if (player == getLocalPlayer()) then guiProgressBarSetProgress(hungerProcess,hungerState) end end function getHungerState (player) if (player == getLocalPlayer()) then return guiProgressBarGetProgress(hungerProcess) end end function dropDownHungerState (player) if (player == getLocalPlayer()) then guiProgressBarSetProgress(hungerProcess,guiProgressBarGetProgress(hungerProcess) -1) if (guiProgressBarGetProgress(hungerProcess) == 0) then setElementHealth (player,getElementHealth (player) -25) outputChatBox ("Rapido! tienes que comer algo!",255,0,0,false) elseif (guiProgressBarGetProgress(hungerProcess) == 10) then outputChatBox ("Peligro! Tienes Mucha Hambre!",255,0,0,false) end end end addEventHandler ("onClientPlayerSpawn",getRootElement(), function (team) setHungerState (source,100) end) addEventHandler ("onClientMarkerHit",getRootElement(), function(hitEle,dim) if (getLocalPlayer() == hitEle) and (getElementData (source,"HAMBURGER!") == true) then if (getHungerState (hitEle) < 50) then setHungerState (hitEle,100) ------------->Estaba pensando que aqui iria el takePlayerMoney ( thePlayer, 50 ) <------------ outputChatBox ("HAMBURGER POWER!",255,0,255,false) outputChatBox ("No Tienes Mas Hambre :D",255,0,255,false) else outputChatBox ("Tu no Nesecitas Comer!",255,0,255,false) end end end) a diferencia del original, solo esta esta linea y lo que esta en español, claro y los colores de los avisos y mi inteto de que te cobren......: hamburgerPositions = { {377,-68,1001.51,10} , {380.44,-8.65,1001.85,9}, {379.42,-119.65,1001.49,5} } -- The positions for the hamburger, in the style: x,y,z,interior --[[ This is the hunger script. You can add hamburgers by adding it in hamburgerPositions. It works easy, just a after it, and filling in! {x,y,z,interiorID} When it isn't the last position, it needs a "," after it Creo que eso Seria Todo.... PD: ¿que habra pasado con las demas personas del foro ? la malloria son muy inactivos........ Link to comment
Castillo Posted April 17, 2011 Share Posted April 17, 2011 --client side hamburgerPositions = { {377,-68,1001.51,10,8,0} , {380.44,-8.65,1001.85,9,0}, {379.42,-119.65,1001.49,5,0} } -- The positions for the hamburger, in the style: x,y,z,interior,dimension --[[ This is the hunger script. You can add hamburgers by adding it in hamburgerPositions. It works easy, just a after it, and filling in! {x,y,z,interiorID,dimension} When it isn't the last position, it needs a "," after it ]]-- -- DONT CHANGE ANYTHING AFTER THIS WITHOUT KNOWLEDGE! addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), function () hungerProcess = guiCreateProgressBar(0.7763,0.28,0.1775,0.04,true) guiMoveToBack (hungerProcess) guiProgressBarSetProgress(hungerProcess,100) hungerLabel = guiCreateLabel(0.7775,0.2817,0.1737,0.0367,"Estado de Hambre",true) guiLabelSetColor(hungerLabel,255,255,255) guiLabelSetVerticalAlign(hungerLabel,"center") guiLabelSetHorizontalAlign(hungerLabel,"center",false) guiSetFont(hungerLabel,"default-small") for i,v in ipairs (hamburgerPositions) do local hamburger = createPickup (v[1],v[2],v[3],3,2768,100) local hamburgerMarker = createMarker (v[1],v[2],v[3],"corona",1,255,255,0,80) setElementData (hamburgerMarker,"HAMBURGER!",true) setElementInterior (hamburgerMarker,v[4]) setElementInterior (hamburger,v[4]) setElementDimension(hamburger,tonumber(v[5])) setElementDimension(hamburgerMarker,tonumber(v[5])) end setTimer (dropDownHungerState,45000,0,getLocalPlayer()) end) function setHungerState (player,hungerState) if (player == getLocalPlayer()) then guiProgressBarSetProgress(hungerProcess,hungerState) end end function getHungerState (player) if (player == getLocalPlayer()) then return guiProgressBarGetProgress(hungerProcess) end end function dropDownHungerState (player) if (player == getLocalPlayer()) then guiProgressBarSetProgress(hungerProcess,guiProgressBarGetProgress(hungerProcess) -1) if (guiProgressBarGetProgress(hungerProcess) == 0) then setElementHealth (player,getElementHealth (player) -25) outputChatBox ("Rapido! tienes que comer algo!",255,0,0,false) elseif (guiProgressBarGetProgress(hungerProcess) == 10) then outputChatBox ("Peligro! Tienes Mucha Hambre!",255,0,0,false) end end end addEventHandler ("onClientPlayerSpawn",getRootElement(), function (team) setHungerState (source,100) end) addEventHandler ("onClientMarkerHit",getRootElement(), function(hitEle,dim) if (getLocalPlayer() == hitEle) and (getElementData (source,"HAMBURGER!") == true) then if (getHungerState (hitEle) < 50) then setHungerState (hitEle,100) triggerServerEvent("takeTheMoney",getLocalPlayer(),getLocalPlayer(),50) outputChatBox ("HAMBURGER POWER!",255,0,255,false) outputChatBox ("No Tienes Mas Hambre \"{SMILIES_PATH}/icon_biggrin.gif\" alt=\"\" title=\"Very Happy\" />",255,0,255,false) else outputChatBox ("Tu no Nesecitas Comer!",255,0,255,false) end end end) --server side addEvent("takeTheMoney",true) addEventHandler("takeTheMoney",getRootElement(), function (cliente,monto) if getPlayerMoney(cliente) >= tonumber(monto) then takePlayerMoney(cliente,tonumber(monto)) end end) Como puedes ver, e creado otro script mas, ese es para quitarle el dinero al jugador (es preferible usarlo en el lado server-side, que yo sepa takePlayerMoney tiene errores en el cliente ) Bueno, ahora deberia enviar a las hamburgesas a las dimensiones, como veras agregue otro valor a la tabla, "0" (es el ultimo valor) eso define la dimension de la hamburgesa. debes crear otro script que puede ser: server.lua y luego agregarlo al meta.xml y poner type="server". Saludos. Link to comment
Serginix Posted April 17, 2011 Author Share Posted April 17, 2011 Solidsnake14, me impresionas de nuevo, el escript me funciono a la perfeccion, eres el mejor, espero algun dia scriptear como tu, la unica cosa, esque cuando pasas encima de el icono de la Hamburgesa, te sale en el Chat como 20 veces "Aun No Nesecitas Comer" y esto se da Creo, por que ay 10 hamburgesas, en el mismo sitio pero en distinta dimension, aun asi gracias esta buenisimo Link to comment
Castillo Posted April 18, 2011 Share Posted April 18, 2011 jajajjaajaja, me olvide de esa parte creo que se como se arregla hamburgerPositions = { {377,-68,1001.51,10,8,0} , {380.44,-8.65,1001.85,9,0}, {379.42,-119.65,1001.49,5,0} } -- The positions for the hamburger, in the style: x,y,z,interior,dimension --[[ This is the hunger script. You can add hamburgers by adding it in hamburgerPositions. It works easy, just a after it, and filling in! {x,y,z,interiorID,dimension} When it isn't the last position, it needs a "," after it ]]-- -- DONT CHANGE ANYTHING AFTER THIS WITHOUT KNOWLEDGE! addEventHandler ("onClientResourceStart",getResourceRootElement(getThisResource()), function () hungerProcess = guiCreateProgressBar(0.7763,0.28,0.1775,0.04,true) guiMoveToBack (hungerProcess) guiProgressBarSetProgress(hungerProcess,100) hungerLabel = guiCreateLabel(0.7775,0.2817,0.1737,0.0367,"Estado de Hambre",true) guiLabelSetColor(hungerLabel,255,255,255) guiLabelSetVerticalAlign(hungerLabel,"center") guiLabelSetHorizontalAlign(hungerLabel,"center",false) guiSetFont(hungerLabel,"default-small") for i,v in ipairs (hamburgerPositions) do local hamburger = createPickup (v[1],v[2],v[3],3,2768,100) local hamburgerMarker = createMarker (v[1],v[2],v[3],"corona",1,255,255,0,80) setElementData (hamburgerMarker,"HAMBURGER!",true) setElementInterior (hamburgerMarker,v[4]) setElementInterior (hamburger,v[4]) setElementDimension(hamburger,tonumber(v[5])) setElementDimension(hamburgerMarker,tonumber(v[5])) end setTimer (dropDownHungerState,45000,0,getLocalPlayer()) end) function setHungerState (player,hungerState) if (player == getLocalPlayer()) then guiProgressBarSetProgress(hungerProcess,hungerState) end end function getHungerState (player) if (player == getLocalPlayer()) then return guiProgressBarGetProgress(hungerProcess) end end function dropDownHungerState (player) if (player == getLocalPlayer()) then guiProgressBarSetProgress(hungerProcess,guiProgressBarGetProgress(hungerProcess) -1) if (guiProgressBarGetProgress(hungerProcess) == 0) then setElementHealth (player,getElementHealth (player) -25) outputChatBox ("Rapido! tienes que comer algo!",255,0,0,false) elseif (guiProgressBarGetProgress(hungerProcess) == 10) then outputChatBox ("Peligro! Tienes Mucha Hambre!",255,0,0,false) end end end addEventHandler ("onClientPlayerSpawn",getRootElement(), function (team) setHungerState (source,100) end) addEventHandler ("onClientMarkerHit",getRootElement(), function(hitEle,dim) if (getLocalPlayer() == hitEle) and (getElementData (source,"HAMBURGER!") == true) and (dim) then if (getHungerState (hitEle) < 50) then setHungerState (hitEle,100) triggerServerEvent("takeTheMoney",getLocalPlayer(),getLocalPlayer(),50) outputChatBox ("HAMBURGER POWER!",255,0,255,false) outputChatBox ("No Tienes Mas Hambre.",255,0,255,false) else outputChatBox ("Tu no Nesecitas Comer!",255,0,255,false) end end end) Dime si te funciona Link to comment
Serginix Posted April 18, 2011 Author Share Posted April 18, 2011 Yeah, funciono a la perfeccion , gracias man, ahora si me voy a Parranda, digo Semana Santa ! Link to comment
juniorblinxs Posted April 20, 2011 Share Posted April 20, 2011 ^^ Solidsnake14 siempre ayuda ( yo no se mucho de script no le entiendo ) ....... viva Solidsnake14!! Link to comment
Castillo Posted April 20, 2011 Share Posted April 20, 2011 jajaja, no jodas Yo ayudo cuando puedo Link to comment
Recommended Posts