Flipi Posted October 19, 2013 Share Posted October 19, 2013 Hola, tengo un problema con la parte de la funcion cuests con message (linea 17), ya que no me funciona al escribir...ejemplo "!ayuda" ........(lo puse en server-side)... server: local msgs = { 'necesita ayuda', 'es noob', 'es malo' } local msgss = { 'Carabinero', 'Bachelet', 'Holy Fuuu' } local msgsss = { 'No tengo idea', 'Que te ayude tu vieja', 'Mala cuea' } function cuest( player,text ) local texts = msgs [ math.random ( 1, #msgs )] local texts2 = msgss [ math.random ( 1, #msgss )] local texts3 = msgsss [ math.random ( 1, #msgsss )] if text then outputChatBox ("* #FF8000[Ayuda] #FFFFFF"..getPlayerName(player).." #0080FFpide ayuda porque: #FFFFFF" ..texts.. "#0080FF!", getRootElement(), 255, 255, 255, true ) outputChatBox ("* #FF8000"..texts2.." #0080FFle da la solucion: #FFFFFF" ..texts3.. "#0080FF!", getRootElement(), 255, 255, 255, true ) end end addCommandHandler ( "ayuda", cuest) addCommandHandler ( "jelp", cuest) function cuests(player,message,messageType,text) if message == "!ayuda" or message =="!jelp" then local texts = msgs [ math.random ( 1, #msgs )] local texts2 = msgss [ math.random ( 1, #msgss )] local texts3 = msgsss [ math.random ( 1, #msgsss )] if text then outputChatBox ("* #FF8000[Ayuda] #FFFFFF"..getPlayerName(player).." #0080FFpide ayuda porque: #FFFFFF" ..texts.. "#0080FF!", getRootElement(), 255, 255, 255, true ) outputChatBox ("* #FF8000"..texts2.." #0080FFle da la solucion: #FFFFFF" ..texts3.. "#0080FF!", getRootElement(), 255, 255, 255, true ) end end end addEventHandler("onPlayerChat",getRootElement(),cuests) Link to comment
Castillo Posted October 19, 2013 Share Posted October 19, 2013 El comando "/ayuda" funciona? P.D: Es "help" no "jelp". Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 El comando "/ayuda" funciona?P.D: Es "help" no "jelp". si, si funciona, pero el que no funciona es la parte de abajo "!jelp o !ayuda" P.D: yo le puse "jelp" Link to comment
Castillo Posted October 19, 2013 Share Posted October 19, 2013 function cuests(player,message,messageType,text) Ese es el problema, onPlayerChat solo tiene 2 argumentos: mensaje, tipoDeMensaje. Borra 'player' de ahi y tambien 'text'. Luego cambia 'player' por 'source' en las otras funciones ( getPlayerName, etc ). Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 function cuests(player,message,messageType,text) Ese es el problema, onPlayerChat solo tiene 2 argumentos: mensaje, tipoDeMensaje. Borra 'player' de ahi y tambien 'text'. Luego cambia 'player' por 'source' en las otras funciones ( getPlayerName, etc ). asi? function cuests(message,messageType) if message == "!ayuda" or message =="!jelp" then local texts = msgs [ math.random ( 1, #msgs )] local texts2 = msgss [ math.random ( 1, #msgss )] local texts3 = msgsss [ math.random ( 1, #msgsss )] if text then outputChatBox ("* #FF8000[Ayuda] #FFFFFF"..getPlayerName(source).." #0080FFpide ayuda porque: #FFFFFF" ..texts.. "#0080FF!", getRootElement(), 255, 255, 255, true ) outputChatBox ("* #FF8000"..texts2.." #0080FFle da la solucion: #FFFFFF" ..texts3.. "#0080FF!", getRootElement(), 255, 255, 255, true ) end end end addEventHandler("onPlayerChat",getRootElement(),cuests) Link to comment
Castillo Posted October 19, 2013 Share Posted October 19, 2013 Si, pero, donde esta definido 'text'? Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 Si, pero, donde esta definido 'text'? lo puse asi, pero tampoco funciona... o como tendria que ser? function cuests(message,messageType,text) if message == "!ayuda" or message =="!jelp" then local texts = msgs [ math.random ( 1, #msgs )] local texts2 = msgss [ math.random ( 1, #msgss )] local texts3 = msgsss [ math.random ( 1, #msgsss )] if text then outputChatBox ("* #FF8000[Ayuda] #FFFFFF"..getPlayerName(source).." #0080FFpide ayuda porque: #FFFFFF" ..texts.. "#0080FF!", getRootElement(), 255, 255, 255, true ) outputChatBox ("* #FF8000"..texts2.." #0080FFle da la solucion: #FFFFFF" ..texts3.. "#0080FF!", getRootElement(), 255, 255, 255, true ) end end end addEventHandler("onPlayerChat",getRootElement(),cuests) Link to comment
Castillo Posted October 19, 2013 Share Posted October 19, 2013 Eso es porque 'text' es siempre nil, no deberias usar 'texts'? Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 Eso es porque 'text' es siempre nil, no deberias usar 'texts'? no entiendo Link to comment
Alexs Posted October 19, 2013 Share Posted October 19, 2013 Eso es porque 'text' es siempre nil, no deberias usar 'texts'? no entiendo function cuests(message,messageType) if message == "!ayuda" or message =="!jelp" then local texts = msgs [ math.random ( 1, #msgs )] local texts2 = msgss [ math.random ( 1, #msgss )] local texts3 = msgsss [ math.random ( 1, #msgsss )] outputChatBox ("* #FF8000[Ayuda] #FFFFFF"..getPlayerName(source).." #0080FFpide ayuda porque: #FFFFFF" ..texts.. "#0080FF!", getRootElement(), 255, 255, 255, true ) outputChatBox ("* #FF8000"..texts2.." #0080FFle da la solucion: #FFFFFF" ..texts3.. "#0080FF!", getRootElement(), 255, 255, 255, true ) end end addEventHandler("onPlayerChat",getRootElement(),cuests) Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 function cuests(message,messageType) if message == "!ayuda" or message =="!jelp" then local texts = msgs [ math.random ( 1, #msgs )] local texts2 = msgss [ math.random ( 1, #msgss )] local texts3 = msgsss [ math.random ( 1, #msgsss )] outputChatBox ("* #FF8000[Ayuda] #FFFFFF"..getPlayerName(source).." #0080FFpide ayuda porque: #FFFFFF" ..texts.. "#0080FF!", getRootElement(), 255, 255, 255, true ) outputChatBox ("* #FF8000"..texts2.." #0080FFle da la solucion: #FFFFFF" ..texts3.. "#0080FF!", getRootElement(), 255, 255, 255, true ) end end addEventHandler("onPlayerChat",getRootElement(),cuests) era solo quitar el text?, gracias !! Link to comment
Castillo Posted October 19, 2013 Share Posted October 19, 2013 O cambiar 'text en el 'if' por 'texts'. Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 O cambiar 'text en el 'if' por 'texts'. es que si lo cambio por texts, tendria que poner para texts2 y texts3 o no? Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 No se, es tu script. ya se a lo que te refieres, era un problema mio, igual gracias por todo, ya funciona Link to comment
Alexs Posted October 19, 2013 Share Posted October 19, 2013 ya se a lo que te refieres, era un problema mio, igual gracias por todo, ya funciona No veo por que habría que comprobar si 'texts', 'texts2' y 'texts3' existen, siempre están definidos. Link to comment
Flipi Posted October 19, 2013 Author Share Posted October 19, 2013 ya se a lo que te refieres, era un problema mio, igual gracias por todo, ya funciona No veo por que habría que comprobar si 'texts', 'texts2' y 'texts3' existen, siempre están definidos. aah oks gracias por todo! Link to comment
Recommended Posts