Jump to content

[HELP] How to fix this bug in my pm system?


Tokio

Recommended Posts

 

here's a video about the bug..: 

How to fix this bug? I tried many things, but unsuccessfully.. :s 

Here the code: 

Client.lua:

local sX, sY = guiGetScreenSize()
setElementData(localPlayer,"name",nil)

GUIEditor = {
    button = {},
    edit = {}
}

        GUIEditor.button[1] = guiCreateButton(0.72, 0.74, 0.03, 0.04, ">", true)

kuldottpmek = {}
 fogadottpmek = {}
        GUIEditor.edit[1] = guiCreateEdit(0.38, 0.74, 0.34, 0.04, ".", true)
        guiEditSetMaxLength(GUIEditor.edit[1], 150)    


local dxfont0_gothic = dxCreateFont(":mta_wintertime/gothic.ttf", 14)
local screenW, screenH = guiGetScreenSize()


	local players = getElementsByType ( "player" )

addEventHandler("onClientRender", root,
    function()
	local players = getElementsByType ( "player" )
local elem = 0
local fpm = 0
local kpm = 0
local uzenet = guiGetText(GUIEditor.edit[1])

        dxDrawRectangle(screenW * 0.3722, screenH * 0.2722, screenW * 0.3833, screenH * 0.5100, tocolor(0, 0, 0, 162), false)
        dxDrawRectangle(screenW * 0.1757, screenH * 0.2722, screenW * 0.1896, screenH * 0.5100, tocolor(0, 0, 0, 162), false)
        dxDrawText("Játékoslista", screenW * 0.1764, screenH * 0.2722, screenW * 0.3653, screenH * 0.3167, tocolor(255, 255, 255, 255), 1.00, dxfont0_gothic, "center", "center", false, false, false, false, false)
        for id,player in ipairs(players) do
			local plname = getPlayerName(player)
elem = elem + 1

        dxDrawText(plname, screenW * 0.1764, screenH * 0.2500+(elem*70), screenW * 0.3653, screenH * 0.3578, tocolor(255, 255, 255, 255), 0.65, dxfont0_gothic, "left", "center", false, false, true, true, false)
		dxDrawRectangle(screenW * 0.1764, screenH * 0.2850+(elem*35), screenW * 0.1889, screenH * 0.0367, tocolor(0, 0, 0, 162), false)
		end
        
		dxDrawText(getElementData(localPlayer,"name") or "Válassz játékost", screenW * 0.3722, screenH * 0.2722, screenW * 0.7556, screenH * 0.3167, tocolor(255, 255, 255, 255), 1.00, dxfont0_gothic, "center", "center", false, false, false, true, false)
        dxDrawText(getElementData(localPlayer,"name") and "Elérhető most" or "", screenW * 0.5278, screenH * 0.3056, screenW * 0.6014, screenH * 0.3411, tocolor(255, 255, 255, 255), 0.65, dxfont0_gothic, "center", "center", false, false, false, true, false)
        dxDrawRectangle(screenW * 0.3722, screenH * 0.3467, screenW * 0.3833, screenH * 0.3844, tocolor(0, 0, 0, 162), false)
		for k,v in ipairs(kuldottpmek) do
		kpm = kpm + 1
		dxDrawRectangle(screenW * 0.3722, screenH * 0.2775+(kpm*62), screenW * 0.3833, screenH * 0.0633, tocolor(94, 192, 254, 162), false)
        dxDrawText("Te:", screenW * 0.3729, screenH * 0.1430+(kpm*124), screenW * 0.7556, screenH * 0.4367, tocolor(255, 255, 255, 255), 1.00, "default-bold", "left", "center", false, false, false, true, false)
        dxDrawText(v, screenW * 0.3729, screenH * 0.3050+(kpm*62), screenW * 0.7556, screenH * 0.4733, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, true, true, false, false)
		for k,v in ipairs(fogadottpmek) do
		kpm = kpm + 1
		dxDrawRectangle(screenW * 0.3722, screenH * 0.2775+(kpm*62), screenW * 0.3833, screenH * 0.0633, tocolor(255, 255, 254, 162), false)
        dxDrawText(getElementData(localPlayer,"name")..":", screenW * 0.3729, screenH * 0.1430+(kpm*124), screenW * 0.7556, screenH * 0.4367, tocolor(110, 110,111, 200), 1.00, "default-bold", "left", "center", false, false, false, true, false)
        dxDrawText(v, screenW * 0.3729, screenH * 0.3050+(kpm*62), screenW * 0.7556, screenH * 0.4733, tocolor(255, 255, 255, 255), 1.00, "default", "left", "top", false, true, true, false, false)
	end
    end
    end
)

function onClientClick(button, state)
		local elem = 0
			if button == "left" and state == "down" then

		for k, v in ipairs(players) do
			local plname = getPlayerName(v)

			elem = elem+1

			if isInBox(screenW * 0.1764, screenH * 0.2850+(elem*35), screenW * 0.1889, screenH * 0.0367) then
			if plname == getPlayerName(localPlayer) then return end
				setElementData(localPlayer,"name",plname)
				kuldottpmek = {}
				fogadottpmek = {}
			end
		end
		end
		end

addEventHandler("onClientClick", root, onClientClick)

function isInBox(xS,yS,wS,hS)
	if(isCursorShowing()) then
		local cursorX, cursorY = getCursorPosition()
		cursorX, cursorY = cursorX*sX, cursorY*sY
		if(cursorX >= xS and cursorX <= xS+wS and cursorY >= yS and cursorY <= yS+hS) then
			return true
		else
			return false
		end
	end	
end

function trig1()
			if getElementData(localPlayer,"name") == nil then return end

			local nev =getElementData(localPlayer,"name") or ""
			local targetPlayer = getPlayerFromName ( nev )
			
			
if targetPlayer then
local uzenet = guiGetText(GUIEditor.edit[1])

	table.insert(kuldottpmek,uzenet)
end
end
addEvent("uzenet",true)
addEventHandler("uzenet",root,trig1)

function trig2()
			if getElementData(localPlayer,"name") == nil then return end
			local nev =getElementData(localPlayer,"name") or ""
			local targetPlayer = getPlayerFromName ( nev )

if targetPlayer then
local uzenet = guiGetText(GUIEditor.edit[1])

	table.insert(fogadottpmek,uzenet)
end
end
addEvent("uzenet2",true)
addEventHandler("uzenet2",root,trig2)

function test()
			if getElementData(localPlayer,"name") == nil then return end
local uzenet = guiGetText(GUIEditor.edit[1])

triggerServerEvent("pmuzenet",localPlayer,getLocalPlayer(),uzenet)
end
addEventHandler("onClientGUIClick",GUIEditor.button[1],test,false)

Server.lua:

function privateMessage(thePlayer)
local sendToName = getElementData(thePlayer,"name")
			local toPlayer = getPlayerFromParticalName (sendToName)
					
				triggerClientEvent(thePlayer,"uzenet",toPlayer)
				triggerClientEvent(toPlayer,"uzenet2",thePlayer)
					setElementData(toPlayer,"fogadott",true)
					setElementData(thePlayer,"fogadott",false)
	end

addEvent("pmuzenet",true)

addEventHandler("pmuzenet",root,privateMessage)

function getPlayerFromParticalName(thePlayerName)
	local thePlayer = getPlayerFromName(thePlayerName)
	if thePlayer then
		return thePlayer
	end
	for _,thePlayer in ipairs(getElementsByType("player")) do
		if string.find(string.gsub(getPlayerName(thePlayer):lower(),"#%x%x%x%x%x%x", ""), thePlayerName:lower(), 1, true) then
			return thePlayer
		end
	end
return false
end

 

Link to post

Fix the table.insert ... As it seems, your'e saving the message in a table.insert so you've to fix when you take the message from the table.. ain't you getting warning or errors at /debugscript 3 ?

Edited by R.I.P Logic
Link to post
2 hours ago, R.I.P Logic said:

Fix the table.insert ... As it seems, your'e saving the message in a table.insert so you've to fix when you take the message from the table.. ain't you getting warning or errors at /debugscript 3 ?

I do not get anything in debugscript 3 :ss 

Link to post

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