Jump to content

[SOLVED] Send Message (Server.lua)


3B00DG4MER

Recommended Posts

Hello,I made A Panel send Message

The Bug is,When i click Send will Send For me Only

The Message show for Client only

Help

Client:

function onClickSend(button, state) 
    if button == "left" then 
     if tostring( guiGetText( GUIEditor.edit[1] ) ) == "" then 
     else 
        local editmsg = tostring( guiGetText( GUIEditor.edit[1] ) ) 
        local playerName = getPlayerName( localPlayer ) 
        local row = guiGridListAddRow ( GUIEditor.gridlist[1] ) 
        guiGridListSetItemText ( GUIEditor.gridlist[1], row, 2, editmsg, false, false ) 
        guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, playerName , false, false ) 
        triggerServerEvent("onPlayerChatMessage",localPlayer,editText,Log) 
        guiSetText ( GUIEditor.edit[1] , "" ) 
    end 
    end 
    end 
addEvent( "Sendmsg", true ) 
addEventHandler( "Sendmsg", getRootElement(), onClickSend ) 

Server:

addEvent("onPlayerChatMessage",true) 
addEventHandler("onPlayerChatMessage",root,function ( Text , Log ) 
triggerClientEvent("Sendmsg",source,text) 
  
function logMessage(text,player) 
    if text and player then 
        local log = fileOpen("Logs/support.log")    or fileCreate("Logs/support.log") 
        -- 
        if log then 
            fileSetPos(log,fileGetSize(log)) 
            fileWrite(log,"\r\n",""..player.." | "..text.."") 
            fileFlush(log) 
            fileClose(log) 
        end 
        end 
        end 
end 
) 

Help plz

Edited by Guest
Link to comment
  
function onClickSend() 
        local editmsg = tostring( guiGetText( GUIEditor.edit[1] ) ) 
        local playerName = getPlayerName( localPlayer ) 
        local row = guiGridListAddRow ( GUIEditor.gridlist[1] ) 
        guiGridListSetItemText ( GUIEditor.gridlist[1], row, 2, editmsg, false, false ) 
        guiGridListSetItemText ( GUIEditor.gridlist[1], row, 1, playerName , false, false ) 
        triggerServerEvent("onPlayerChatMessage",localPlayer,editText,Log) 
        guiSetText ( GUIEditor.edit[1] , "" ) 
    end 
    end 
    end 
addEvent( "Sendmsg", true ) 
addEventHandler( "Sendmsg", getRootElement(), onClickSend ) 
  

Server

  
addEvent("onPlayerChatMessage",true) 
addEventHandler("onPlayerChatMessage",root,function ( Text , Log ,text,player) 
triggerClientEvent("Sendmsg",source,text) 
    if text and player then 
        local log = fileOpen("Logs/support.log")    or fileCreate("Logs/support.log") 
        -- 
        if log then 
            fileSetPos(log,fileGetSize(log)) 
            fileWrite(log,"\r\n",""..player.." | "..text.."") 
            fileFlush(log) 
            fileClose(log) 
        end 
        end 
        end 
) 
  

EDIT: I have corrected some mistakes. Not do the outputing.

Link to comment
  • Moderators
ERROR: Client (|PD|XGamer) triggered serverside event onPlayerChatMessage, but event is not added serverside

It means that the script that contains this:

addEvent("onPlayerChatMessage", true) 

wasn't added to the meta.xml or there is a syntax error somewhere in this script file.

There is no syntax error in the Anubhav's code so fix the rest of the code or put it in another script file.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...