Jump to content

[Help]DM script


Gat

Recommended Posts

Hi guys,im stuck here... I want when i press on GUIEditor.button[1] it sends that i typed in GUIEditor.edit[1] to selected player..

--client

GUIEditor = {
    edit = {},
    button = {},
    window = {},
    label = {},
    gridlist = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
local screenW, screenH = guiGetScreenSize()
        GUIEditor.window[1] = guiCreateWindow((screenW - 528) / 2, (screenH - 183) / 2, 528, 183, "dm panel - gat", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.gridlist[1] = guiCreateGridList(29, 32, 186, 142, false, GUIEditor.window[1])

      local column = guiGridListAddColumn(GUIEditor.gridlist[1], "players", 0.9)
        GUIEditor.button[1] = guiCreateButton(247, 107, 271, 60, "DM", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
        GUIEditor.edit[1] = guiCreateEdit(247, 32, 269, 65, "", false, GUIEditor.window[1])
        GUIEditor.label[1] = guiCreateLabel(216, 63, 31, 15, "close", false, GUIEditor.window[1])    
for id, player in pairs(getElementsByType("player")) do
			local row = guiGridListAddRow ( GUIEditor.gridlist[1])
			guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, getPlayerName ( player ), false, false )
guiSetVisible(GUIEditor.window[1], false ) 
		end
    end
)
function show ()
	if guiGetVisible(GUIEditor.window[1] ) then
		guiSetVisible(GUIEditor.window[1], false ) showCursor (false)
 else
			guiSetVisible(GUIEditor.window[1], true )
 showCursor (true)
	end
end
addCommandHandler("dm", show)
function clickin ()
	if source == GUIEditor.label[1] then
		guiSetVisible(GUIEditor.window[1], false )  showCursor (false) elseif source == GUIEditor.button[1] then
if guiGetText(GUIEditor.edit[1] ) == "" then return end
    --im stoped here,
 showCursor (false)
guiSetVisible(GUIEditor.window[1], false )  
	end
end
addEventHandler("onClientGUIClick", root, clickin)

 

Edited by Gat
Link to comment
13 minutes ago, Gat said:

Hi guys,im stuck here... I want when i press on GUIEditor.button[1] it sends that i typed in GUIEditor.edit[1] to selected player..


--client

GUIEditor = {
    edit = {},
    button = {},
    window = {},
    label = {},
    gridlist = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
local screenW, screenH = guiGetScreenSize()
        GUIEditor.window[1] = guiCreateWindow((screenW - 528) / 2, (screenH - 183) / 2, 528, 183, "dm panel - gat", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.gridlist[1] = guiCreateGridList(29, 32, 186, 142, false, GUIEditor.window[1])

      local column = guiGridListAddColumn(GUIEditor.gridlist[1], "players", 0.9)
        GUIEditor.button[1] = guiCreateButton(247, 107, 271, 60, "DM", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
        GUIEditor.edit[1] = guiCreateEdit(247, 32, 269, 65, "", false, GUIEditor.window[1])
        GUIEditor.label[1] = guiCreateLabel(216, 63, 31, 15, "close", false, GUIEditor.window[1])    
for id, player in pairs(getElementsByType("player")) do
			local row = guiGridListAddRow ( GUIEditor.gridlist[1])
			guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, getPlayerName ( player ), false, false )
guiSetVisible(GUIEditor.window[1], false ) 
		end
    end
)
function show ()
	if guiGetVisible(GUIEditor.window[1] ) then
		guiSetVisible(GUIEditor.window[1], false ) showCursor (false)
 else
			guiSetVisible(GUIEditor.window[1], true )
 showCursor (true)
	end
end
addCommandHandler("dm", show)
function clickin ()
	if source == GUIEditor.label[1] then
		guiSetVisible(GUIEditor.window[1], false )  showCursor (false) elseif source == GUIEditor.button[1] then
if guiGetText(GUIEditor.edit[1] ) == "" then return end
 showCursor (false)
guiSetVisible(GUIEditor.window[1], false )  
	end
end
addEventHandler("onClientGUIClick", root, clickin)

 

try that

 

--server
addEvent("sendMessage", true)
addEventHandler("sendMessage", root,
	function( nn, Medit )
	local player = getPlayerFromName( nn )
		outputChatBox( Medit, player, 255, 255, 0, true )
	end
)

--client

GUIEditor = {
    edit = {},
    button = {},
    window = {},
    label = {},
    gridlist = {}
}
addEventHandler("onClientResourceStart", resourceRoot,
    function()
		local screenW, screenH = guiGetScreenSize()
        GUIEditor.window[1] = guiCreateWindow((screenW - 528) / 2, (screenH - 183) / 2, 528, 183, "dm panel - gat", false)
        guiWindowSetSizable(GUIEditor.window[1], false)

        GUIEditor.gridlist[1] = guiCreateGridList(29, 32, 186, 142, false, GUIEditor.window[1])

      local column = guiGridListAddColumn(GUIEditor.gridlist[1], "players", 0.9)
        GUIEditor.button[1] = guiCreateButton(247, 107, 271, 60, "DM", false, GUIEditor.window[1])
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFAAAAAA")
        GUIEditor.edit[1] = guiCreateEdit(247, 32, 269, 65, "", false, GUIEditor.window[1])
        GUIEditor.label[1] = guiCreateLabel(216, 63, 31, 15, "close", false, GUIEditor.window[1])    
		for id, player in pairs(getElementsByType("player")) do
		local row = guiGridListAddRow ( GUIEditor.gridlist[1])
		guiGridListSetItemText ( GUIEditor.gridlist[1], row, column, getPlayerName ( player ), false, false )
		guiSetVisible(GUIEditor.window[1], false ) 
		end
    end
)
function show ()
	if guiGetVisible(GUIEditor.window[1] ) then
		guiSetVisible(GUIEditor.window[1], false ) showCursor (false)
 else
			guiSetVisible(GUIEditor.window[1], true )
 showCursor (true)
	end
end
addCommandHandler("dm", show)
function clickin ()
local Medit = guiGetText( GUIEditor.edit[1] )
local ss = guiGridListGetSelectedItem( GUIEditor.gridlist[1] )
local tt = guiGridListGetItemText( GUIEditor.gridlist[1], ss, 1 )
local nn = guiGridListGetItemText( GUIEditor.gridlist[1], guiGridListGetSelectedItem( GUIEditor.gridlist[1] ), 1 )
	if source == GUIEditor.label[1] then
	guiSetVisible(GUIEditor.window[1], false )  
	showCursor (false) 
	elseif source == GUIEditor.button[1] then
	if ( ss == -1 ) then 
	outputChatBox( "Please select a player", 255, 0, 0, true )
	return end
	if Medit == "" then return end
	showCursor (false)
	guiSetVisible(GUIEditor.window[1], false )  
	triggerServerEvent( "sendMessage", localPlayer, nn, Medit )
	end
end
addEventHandler("onClientGUIClick", root, clickin)

 

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...