Flipi Posted September 19, 2013 Share Posted September 19, 2013 Hola, me gustaria saber como hacer para agregar diversos tipos de mensajes al morir, que no solo diga "murio", sino que otros mensajes mas con math.random, pero no logro hacerlo. function playerDied(totalAmmo, killer, killerWeapon, bodypart) outputChatBox('* #FFFFFF'..getPlayerName(source)..' #0080FFMurio!',getRootElement(),255,255,255,true) end addEventHandler("onPlayerWasted",getRootElement(),playerDied) Intente hacer esto pero no logro armarlo: local msgs = { 'noob', 'murio', 'diee!' } setTimer(function playerDied(totalAmmo, killer, killerWeapon, bodypart) local text = msgs[math.random(1, #msgs)] outputChatBox (getPlayerName(source).. text, root, 255, 255, 255, true) else outputChatBox(text, root, 255, 255, 255, true) end addEventHandler("onPlayerWasted",getRootElement(),playerDied) end, 25000, 0) Link to comment
Castillo Posted September 19, 2013 Share Posted September 19, 2013 local msgs = { 'noob', 'murio', 'diee!' } function playerDied ( totalAmmo, killer, killerWeapon, bodypart ) local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ( getPlayerName ( source ) .. text, root, 255, 255, 255, true ) end addEventHandler ( "onPlayerWasted", getRootElement(), playerDied ) Link to comment
Flipi Posted September 19, 2013 Author Share Posted September 19, 2013 Gracias, y como puedo agregarle la razón de la muerte (suicide, kill...)? Link to comment
AlvareZ_ Posted September 19, 2013 Share Posted September 19, 2013 local msgs = { 'noob', 'murio', 'diee!' } function playerDied ( totalAmmo, killer, killerWeapon, bodypart ) local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ( getPlayerName ( source ) .. text .. getBodyPartName ( bodypart ) .. !, root, 255, 255, 255, true ) end addEventHandler ( "onPlayerWasted", getRootElement(), playerDied ) Link to comment
Flipi Posted September 19, 2013 Author Share Posted September 19, 2013 gracias, puedo hacerte una pregunta, esto está bien?, es algo parecido, pero cuando el jugador se va del server.. local msgs = { ' fue la baño!', ' lo reto su mamá!', ' no pagó el internet!', ' se le fundio el pc!' } addEventHandler ( "onClientPlayerQuit", g_Root, function(reason) local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ('* #FFFFFF'..getPlayerName ( source ).. text "#0080FF[#FFFFFF"..reason.."#0080FF]", root, 255, 255, 255, true ) end ) Link to comment
Flipi Posted September 19, 2013 Author Share Posted September 19, 2013 local msgs = { 'noob', 'murio', 'diee!' } function playerDied ( totalAmmo, killer, killerWeapon, bodypart ) local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ( getPlayerName ( source ) .. text .. getBodyPartName ( bodypart ) .. !, root, 255, 255, 255, true ) end addEventHandler ( "onPlayerWasted", getRootElement(), playerDied ) me arroja un error, lua: 5: Bad argument @ 'getBodyPartName' lua: 5 : attempt to concatenate a boolean value Link to comment
Sasu Posted September 19, 2013 Share Posted September 19, 2013 local msgs = { 'noob', 'murio', 'diee!' } function playerDied ( totalAmmo, killer, killerWeapon, bodypart ) local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ( getPlayerName ( source ) .." ".. text .." ".. getBodyPartName ( bodypart ) or "N/A" .." !", root, 255, 255, 255, true ) end addEventHandler ( "onPlayerWasted", getRootElement(), playerDied ) Link to comment
Flipi Posted September 19, 2013 Author Share Posted September 19, 2013 local msgs = { 'noob', 'murio', 'diee!' } function playerDied ( totalAmmo, killer, killerWeapon, bodypart ) local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ( getPlayerName ( source ) .." ".. text .." ".. getBodyPartName ( bodypart ) or "N/A" .." !", root, 255, 255, 255, true ) end addEventHandler ( "onPlayerWasted", getRootElement(), playerDied ) dice lo mismo: lua: 5: Bad argument @ 'getBodyPartName' lua: 5 : attempt to concatenate a boolean value Link to comment
Sasu Posted September 19, 2013 Share Posted September 19, 2013 local msgs = { 'noob', 'murio', 'diee!' } function playerDied ( totalAmmo, killer, killerWeapon, bodypart ) if bodypart then local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ( getPlayerName ( source ) .." ".. text .." ".. getBodyPartName ( bodypart ).." !", root, 255, 255, 255, true ) end end addEventHandler ( "onPlayerWasted", getRootElement(), playerDied ) Link to comment
Flipi Posted September 20, 2013 Author Share Posted September 20, 2013 gracias !, una pregunta, esta bien asi este script? (nose como probarlo, ya que es con el evento quit). g_Root = getRootElement() local msgs = { ' Fue la baño!', ' Lo reto su mamá!', ' No pagó el internet!', ' Se le fundio el pc!', ' Se canso de ser malo!' } addEventHandler ( "onClientPlayerQuit", g_Root, function(reason) local text = msgs [ math.random ( 1, #msgs ) ] outputChatBox ('* #FFFFFF'..getPlayerName ( source ).. text .."["..reason.."]", root, 255, 255, 255, true ) end ) Link to comment
FraN-724 Posted September 20, 2013 Share Posted September 20, 2013 local messageQuit = "" mensajesQuit = { ' Fue la baño!', ' Lo reto su mamá!', ' No pagó el internet!', ' Se le fundio el pc!', ' Se canso de ser malo!' } addEventHandler ( "onClientPlayerQuit", root, function(reason) messageQuit = outputChatBox ('* #FFFFFF'.. getPlayerName( source ) .. ' #ffffff'..mensajesQuit[math.random(1,#mensajesQuit)]..'.', "["..reason.."]", root, 255, 255, 255, true ) end ) Link to comment
Flipi Posted September 20, 2013 Author Share Posted September 20, 2013 local messageQuit = "" mensajesQuit = { ' Fue la baño!', ' Lo reto su mamá!', ' No pagó el internet!', ' Se le fundio el pc!', ' Se canso de ser malo!' } addEventHandler ( "onClientPlayerQuit", root, function(reason) messageQuit = outputChatBox ('* #FFFFFF'.. getPlayerName( source ) .. ' #ffffff'..mensajesQuit[math.random(1,#mensajesQuit)]..'.', "["..reason.."]", root, 255, 255, 255, true ) end ) Gracias !! Link to comment
Recommended Posts