mody134 Posted November 25, 2016 Share Posted November 25, 2016 (edited) لما اضغظ على اسم الاعب يجيب اسمى انا _________________ --[[----------------------------- --| Private Chat -| Author : PaiN^ -| ver. : 1.1.0 -| file : pc_client.lua --| --]]----------------------------- --// variables : local me = getLocalPlayer( ) local chatwindows = { } local chatLog = { } local screen = { guiGetScreenSize( ) } --// functions : function addPlayers( ) guiGridListClear( players ) for k, v in ipairs( getElementsByType( "player" ) ) do local name = getPlayerName( v ):gsub( "#%x%x%x%x%x%x", "" ) local row = guiGridListAddRow( players ) guiGridListSetItemText( players, row, 1, k, false, true ) guiGridListSetItemText( players, row, 2, name, false, false ) guiGridListSetItemData( players, row, 2, getPlayerSerial( v ) ) end return true end function guiSetSpot( wnd, spot ) local wX, wY = guiGetSize( wnd, false ) if spot == "c" then return guiSetPosition( wnd, ( screen[1] - wX ) / 2, ( screen[2] - wY ) / 2, false ) elseif spot == "r" then return guiSetPosition( wnd, ( screen[1] - wX ), ( screen[2] - wY ) / 2, false ) end end function sendNewMessage( player ) if chatwindows[player] and chatwindows[player].wnd then local msg = guiGetText( chatwindows[player].msgBox ) if msg:len( ) >= 2 then local msgLog = guiGetText( chatwindows[player].msgLog ) if not msgLog then msgLog = "" end msgLog = msgLog .. getPlayerName( me ):gsub( "#%x%x%x%x%x%x", "" ) .. " : " .. msg .. "\n" guiSetText( chatwindows[player].msgLog, msgLog ) guiSetText( chatwindows[player].msgBox, "" ) return triggerServerEvent( "onMessageSend", me, msg, player ) end end end function getSendMessage( msg ) if not chatwindows[source] then buildChatWindow( source ) end outputChatBox( "--------", 100, 100, 100, true ) outputChatBox( "لـديـك رســآلة خـآصة جديـدة", 255, 0, 0, true ) outputChatBox( "--------", 100, 100, 100, true ) playSound( "newMessage.mp3", false ) local msgLog = guiGetText( chatwindows[source].msgLog ) if not msgLog then msgLog = "" end msgLog = msgLog .. getPlayerName( source ):gsub( "#%x%x%x%x%x%x", "" ) .." : " .. msg .. "\n" guiSetText( chatwindows[source].msgLog, msgLog ) end function buildChatWindow( player ) chatwindows[player] = { } chatwindows[player].wnd = guiCreateWindow( 145, 218, 414, 315, getPlayerName( player ):gsub( "#%x%x%x%x%x%x", "" ), false, false ) chatwindows[player].msgLog = guiCreateMemo( 19, 29, 376, 198, "", false, chatwindows[player].wnd ) chatwindows[player].send = guiCreateButton( 19, 233, 71, 28, "إرسال", false, chatwindows[player].wnd ) chatwindows[player].closeC = guiCreateButton( 324, 271, 71, 28, "إغلاق", false, chatwindows[player].wnd ) chatwindows[player].msgBox = guiCreateEdit( 19, 264, 299, 35, "", false, chatwindows[player].wnd ) chatwindows[player].warning = guiCreateLabel( 114, 237, 281, 20, "قال تعالى : { ما يلفظ من قول إلا لديه رقيب عتيد } .", false, chatwindows[player].wnd ) guiWindowSetSizable( chatwindows[player].wnd, false ) guiSetSpot( chatwindows[player].wnd, "c" ) guiSetAlpha( chatwindows[player].wnd, 1 ) guiBringToFront( chatwindows[player].wnd ) guiMemoSetReadOnly( chatwindows[player].msgLog, true ) addEventHandler( "onClientGUIAccepted", chatwindows[player].msgBox, function( ) sendNewMessage( player ) end, false ) addEventHandler( "onClientGUIClick", chatwindows[player].send, function( ) sendNewMessage( player ) end, false ) addEventHandler( "onClientGUIClick", chatwindows[player].closeC, function( ) setElementData( me, "c_state", false ) destroyElement( chatwindows[player].wnd ) chatwindows[player] = nil chatLog[me] = nil chatLog[player] = nil end, false ) end function getPlayerFromSerial( serial ) for k, v in ipairs( getElementsByType( "player" ) ) do if getPlayerSerial( v ) == serial then return v end end return false end --// events & commands : addEvent( "onMessageReceive", true ) addEventHandler( "onClientPlayerJoin", root, addPlayers ) addEventHandler( "onClientPlayerQuit", root, addPlayers ) addEventHandler( "onMessageReceive", root, getSendMessage ) addEventHandler( "onClientPlayerNickChange", root, addPlayers ) addEventHandler( "onClientResourceStart", resourceRoot, function( ) wndMain = guiCreateWindow( 686, 194, 338, 431, "# الرسائل الخاصة .,", false, true ) guiSetVisible( wndMain, false ) guiSetSpot( wndMain, "r" ) --- players = guiCreateGridList( 14, 41, 309, 314, false, wndMain ) guiGridListAddColumn( players, "#", 0.1 ) guiGridListAddColumn( players, "Players", 0.8 ) addPlayers( ) --- close = guiCreateButton( 208, 387, 104, 28, "إغلاق", false, wndMain ) start = guiCreateButton( 28, 387, 104, 28, "بدء محادثة", false, wndMain ) for k, v in ipairs( getElementsByType( "gui-button", resourceRoot ) ) do guiSetFont( v, "default-bold-small" ) guiSetProperty( v, "NormalTextColour", "FFAAAAAA" ) end --- allow = guiCreateRadioButton( 14, 359, 148, 22, "السماح بالرسائل الخاصة", false, wndMain ) guiRadioButtonSetSelected( allow, true ) disallow = guiCreateRadioButton( 192, 359, 130, 22, " منع الرسائل الخاصة", false, wndMain ) for k, v in ipairs( getElementsByType( "gui-radiobutton", resourceRoot ) ) do guiSetFont( v, "default-bold-small" ) guiSetProperty( v, "NormalTextColour", "FF000000" ) end --- bindKey( "F4", "down", function( ) local isInChat = getElementData( me, "c_state" ) if isInChat then if guiGetVisible( wndMain ) then guiSetVisible( wndMain, false ) showCursor( false ) for k, v in pairs( chatwindows ) do guiSetVisible( chatwindows[k].wnd, false ) end else guiSetVisible( wndMain, true ) showCursor( true ) for k, v in pairs( chatwindows ) do guiSetVisible( chatwindows[k].wnd, true ) end end else guiSetVisible( wndMain, not guiGetVisible( wndMain ) ) showCursor( guiGetVisible( wndMain ) ) end end ) setElementData( me, "allowing", true ) setElementData( me, "c_state", false ) end ) addEventHandler( "onClientGUIClick", resourceRoot, function( ) if source == close then guiSetVisible( wndMain, false ) showCursor( false ) for k, v in pairs( chatwindows ) do guiSetVisible( chatwindows[k].wnd, false ) end elseif source == start then local row = guiGridListGetSelectedItem( players ) if row and row ~= -1 then local playerName = guiGridListGetItemText( players, row, 2 ) local player = getPlayerFromSerial( guiGridListGetItemData( players, row, 2 ) ) if player then if getElementData( player, "allowing" ) then if chatLog[me] and chatLog[me] == player or chatLog[player] and chatLog[player] == me then return end buildChatWindow( player ) setElementData( me, "c_state", true ) chatLog[me] = player chatLog[player] = me else outputChatBox( "! هذا اللاعب قام بإغلاق الرسائل الخاصة", 200, 0, 0, true ) end else outputChatBox( "! حصل خطأ في النظام, تواصل مع أي ادمن للمساعدة", 200, 0, 0, true ) end else outputChatBox( "! يجب أن تختار لاعبا لبدء المحادثة معه", 200, 0, 0, true ) end elseif source == allow or source == disallow then setElementData( me, "allowing", guiRadioButtonGetSelected( allow ) ) end end ) addEventHandler( "onClientGUIDoubleClick", resourceRoot, function( button, state ) if source == players then if button == "left" and state == "up" then local row = guiGridListGetSelectedItem( players ) if row and row ~= -1 then local playerName = guiGridListGetItemText( players, row, 2 ) local player = getPlayerFromSerial( guiGridListGetItemData( players, row, 2 ) ) if player then if getElementData( player, "allowing" ) then if chatLog[me] and chatLog[me] == player or chatLog[player] and chatLog[player] == me then return end buildChatWindow( player ) setElementData( me, "c_state", true ) chatLog[me] = player chatLog[player] = me else outputChatBox( "! هذا اللاعب قام بإغلاق الرسائل الخاصة", 200, 0, 0, true ) end else outputChatBox( "! حصل خطأ في النظام, تواصل مع أي ادمن للمساعدة", 200, 0, 0, true ) end else outputChatBox( "! يجب أن تختار لاعبا لبدء المحادثة معه", 200, 0, 0, true ) end end end end ) Edited November 25, 2016 by mody134 Link to comment
Kara Posted November 25, 2016 Share Posted November 25, 2016 function sendNewMessage () local text = guiGetText (chatwindows[player].msgBox) if tostring(text) ~= "" then local row,col = guiGridListGetSelectedItem(players) if (row and col and row ~= -1 and col ~= -1) then local player = guiGridListGetItemText(players, row, 1) if player then guiSetText ( chatwindows[player].msgBox, "" ) guiSetText ( chatwindows[player].msgLog, ""..(guiGetText (chatwindows[player].msgLog)).."@ "..(playerName)..": "..(tostring(text)).."\n" ) triggerServerEvent ("onMessageSend", getLocalPlayer(), localPlayer, tostring(text), player ) end end end end جرب استبدل هذا الفنكشن بي يلي عندك Link to comment
Master_MTA Posted November 27, 2016 Share Posted November 27, 2016 On ٢٥/١١/٢٠١٦ at 2:47 PM, mody134 said: لما اضغظ على اسم الاعب يجيب اسمى انا _________________ --[[----------------------------- --| Private Chat -| Author : PaiN^ -| ver. : 1.1.0 -| file : pc_client.lua --| --]]----------------------------- --// variables : local me = getLocalPlayer( ) local chatwindows = { } local chatLog = { } local screen = { guiGetScreenSize( ) } --// functions : function addPlayers( ) guiGridListClear( players ) for k, v in ipairs( getElementsByType( "player" ) ) do local name = getPlayerName( v ):gsub( "#%x%x%x%x%x%x", "" ) local row = guiGridListAddRow( players ) guiGridListSetItemText( players, row, 1, k, false, true ) guiGridListSetItemText( players, row, 2, name, false, false ) guiGridListSetItemData( players, row, 2, getPlayerSerial( v ) ) end return true end function guiSetSpot( wnd, spot ) local wX, wY = guiGetSize( wnd, false ) if spot == "c" then return guiSetPosition( wnd, ( screen[1] - wX ) / 2, ( screen[2] - wY ) / 2, false ) elseif spot == "r" then return guiSetPosition( wnd, ( screen[1] - wX ), ( screen[2] - wY ) / 2, false ) end end function sendNewMessage( player ) if chatwindows[player] and chatwindows[player].wnd then local msg = guiGetText( chatwindows[player].msgBox ) if msg:len( ) >= 2 then local msgLog = guiGetText( chatwindows[player].msgLog ) if not msgLog then msgLog = "" end msgLog = msgLog .. getPlayerName( me ):gsub( "#%x%x%x%x%x%x", "" ) .. " : " .. msg .. "\n" guiSetText( chatwindows[player].msgLog, msgLog ) guiSetText( chatwindows[player].msgBox, "" ) return triggerServerEvent( "onMessageSend", me, msg, player ) end end end function getSendMessage( msg ) if not chatwindows[source] then buildChatWindow( source ) end outputChatBox( "--------", 100, 100, 100, true ) outputChatBox( "لـديـك رســآلة خـآصة جديـدة", 255, 0, 0, true ) outputChatBox( "--------", 100, 100, 100, true ) playSound( "newMessage.mp3", false ) local msgLog = guiGetText( chatwindows[source].msgLog ) if not msgLog then msgLog = "" end msgLog = msgLog .. getPlayerName( source ):gsub( "#%x%x%x%x%x%x", "" ) .." : " .. msg .. "\n" guiSetText( chatwindows[source].msgLog, msgLog ) end function buildChatWindow( player ) chatwindows[player] = { } chatwindows[player].wnd = guiCreateWindow( 145, 218, 414, 315, getPlayerName( player ):gsub( "#%x%x%x%x%x%x", "" ), false, false ) chatwindows[player].msgLog = guiCreateMemo( 19, 29, 376, 198, "", false, chatwindows[player].wnd ) chatwindows[player].send = guiCreateButton( 19, 233, 71, 28, "إرسال", false, chatwindows[player].wnd ) chatwindows[player].closeC = guiCreateButton( 324, 271, 71, 28, "إغلاق", false, chatwindows[player].wnd ) chatwindows[player].msgBox = guiCreateEdit( 19, 264, 299, 35, "", false, chatwindows[player].wnd ) chatwindows[player].warning = guiCreateLabel( 114, 237, 281, 20, "قال تعالى : { ما يلفظ من قول إلا لديه رقيب عتيد } .", false, chatwindows[player].wnd ) guiWindowSetSizable( chatwindows[player].wnd, false ) guiSetSpot( chatwindows[player].wnd, "c" ) guiSetAlpha( chatwindows[player].wnd, 1 ) guiBringToFront( chatwindows[player].wnd ) guiMemoSetReadOnly( chatwindows[player].msgLog, true ) addEventHandler( "onClientGUIAccepted", chatwindows[player].msgBox, function( ) sendNewMessage( player ) end, false ) addEventHandler( "onClientGUIClick", chatwindows[player].send, function( ) sendNewMessage( player ) end, false ) addEventHandler( "onClientGUIClick", chatwindows[player].closeC, function( ) setElementData( me, "c_state", false ) destroyElement( chatwindows[player].wnd ) chatwindows[player] = nil chatLog[me] = nil chatLog[player] = nil end, false ) end function getPlayerFromSerial( serial ) for k, v in ipairs( getElementsByType( "player" ) ) do if getPlayerSerial( v ) == serial then return v end end return false end --// events & commands : addEvent( "onMessageReceive", true ) addEventHandler( "onClientPlayerJoin", root, addPlayers ) addEventHandler( "onClientPlayerQuit", root, addPlayers ) addEventHandler( "onMessageReceive", root, getSendMessage ) addEventHandler( "onClientPlayerNickChange", root, addPlayers ) addEventHandler( "onClientResourceStart", resourceRoot, function( ) wndMain = guiCreateWindow( 686, 194, 338, 431, "# الرسائل الخاصة .,", false, true ) guiSetVisible( wndMain, false ) guiSetSpot( wndMain, "r" ) --- players = guiCreateGridList( 14, 41, 309, 314, false, wndMain ) guiGridListAddColumn( players, "#", 0.1 ) guiGridListAddColumn( players, "Players", 0.8 ) addPlayers( ) --- close = guiCreateButton( 208, 387, 104, 28, "إغلاق", false, wndMain ) start = guiCreateButton( 28, 387, 104, 28, "بدء محادثة", false, wndMain ) for k, v in ipairs( getElementsByType( "gui-button", resourceRoot ) ) do guiSetFont( v, "default-bold-small" ) guiSetProperty( v, "NormalTextColour", "FFAAAAAA" ) end --- allow = guiCreateRadioButton( 14, 359, 148, 22, "السماح بالرسائل الخاصة", false, wndMain ) guiRadioButtonSetSelected( allow, true ) disallow = guiCreateRadioButton( 192, 359, 130, 22, " منع الرسائل الخاصة", false, wndMain ) for k, v in ipairs( getElementsByType( "gui-radiobutton", resourceRoot ) ) do guiSetFont( v, "default-bold-small" ) guiSetProperty( v, "NormalTextColour", "FF000000" ) end --- bindKey( "F4", "down", function( ) local isInChat = getElementData( me, "c_state" ) if isInChat then if guiGetVisible( wndMain ) then guiSetVisible( wndMain, false ) showCursor( false ) for k, v in pairs( chatwindows ) do guiSetVisible( chatwindows[k].wnd, false ) end else guiSetVisible( wndMain, true ) showCursor( true ) for k, v in pairs( chatwindows ) do guiSetVisible( chatwindows[k].wnd, true ) end end else guiSetVisible( wndMain, not guiGetVisible( wndMain ) ) showCursor( guiGetVisible( wndMain ) ) end end ) setElementData( me, "allowing", true ) setElementData( me, "c_state", false ) end ) addEventHandler( "onClientGUIClick", resourceRoot, function( ) if source == close then guiSetVisible( wndMain, false ) showCursor( false ) for k, v in pairs( chatwindows ) do guiSetVisible( chatwindows[k].wnd, false ) end elseif source == start then local row = guiGridListGetSelectedItem( players ) if row and row ~= -1 then local playerName = guiGridListGetItemText( players, row, 2 ) local player = getPlayerFromSerial( guiGridListGetItemData( players, row, 2 ) ) if player then if getElementData( player, "allowing" ) then if chatLog[me] and chatLog[me] == player or chatLog[player] and chatLog[player] == me then return end buildChatWindow( player ) setElementData( me, "c_state", true ) chatLog[me] = player chatLog[player] = me else outputChatBox( "! هذا اللاعب قام بإغلاق الرسائل الخاصة", 200, 0, 0, true ) end else outputChatBox( "! حصل خطأ في النظام, تواصل مع أي ادمن للمساعدة", 200, 0, 0, true ) end else outputChatBox( "! يجب أن تختار لاعبا لبدء المحادثة معه", 200, 0, 0, true ) end elseif source == allow or source == disallow then setElementData( me, "allowing", guiRadioButtonGetSelected( allow ) ) end end ) addEventHandler( "onClientGUIDoubleClick", resourceRoot, function( button, state ) if source == players then if button == "left" and state == "up" then local row = guiGridListGetSelectedItem( players ) if row and row ~= -1 then local playerName = guiGridListGetItemText( players, row, 2 ) local player = getPlayerFromSerial( guiGridListGetItemData( players, row, 2 ) ) if player then if getElementData( player, "allowing" ) then if chatLog[me] and chatLog[me] == player or chatLog[player] and chatLog[player] == me then return end buildChatWindow( player ) setElementData( me, "c_state", true ) chatLog[me] = player chatLog[player] = me else outputChatBox( "! هذا اللاعب قام بإغلاق الرسائل الخاصة", 200, 0, 0, true ) end else outputChatBox( "! حصل خطأ في النظام, تواصل مع أي ادمن للمساعدة", 200, 0, 0, true ) end else outputChatBox( "! يجب أن تختار لاعبا لبدء المحادثة معه", 200, 0, 0, true ) end end end end ) يا غالي لانك تجيب اسم اللاعب بعد ما عدلت عليه وبكذا فهو ما يعثر على اللاعب فاكيد ما بيزبط المقصود بعد ما عدلت عليه انك حذفت اكواد الالوان منه Link to comment
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