Jump to content

I can't fix this


Deep thinker

Recommended Posts

Posted
addEvent('showAssistanceMsg', true)
addEventHandler('showAssistanceMsg', root,
    function(name, location)
        theAlpha = 255
        rand = math.random(-50, 50)
        function showMSG() 
            if theAlpha > 0 then
            theAlpha = theAlpha - 0.3
                dxDrawText("(..name..)"  Requesting Medical Assistance in '(..location..)',x(914.0),y(453.0+rand),x(1322.0),y(504.0),tocolor(0,205,0,theAlpha),x(1.3),"default-bold","center","center",false,false,false)
            else
            removeEventHandler('onClientRender', root, showMSG)
            end
            end
            addEventHandler('onClientRender', root, showMSG)
            end
        end
    end
end
)


function x(f)
    local sx, sy = guiGetScreenSize()
    return (sx/1440) * f
end

function y(f)
    local sx, sy = guiGetScreenSize()
    return (sy/900) * f
end

It's a simple notification script for a job with a command but there is a bug i can't fix which is  ')' expected near 'Requesting'  ,,please answer asap 

Posted

check line 9:

the string is not correct and highlighted syntax makes it obvious

also i'm not sure if things like x(914.0) can be "accepted" from lua

Posted

i did but i couldn't fix it in any kind of ways .:|

1 minute ago, LoPollo said:

check line 9:

the string is not correct and highlighted syntax makes it obvious

also i'm not sure if things like x(914.0) can be "accepted" from lua

 

Posted (edited)
dxDrawText(name.." is requesting Medical Assistance in "..location,x(914.0),y(453.0+rand),x(1322.0),y(504.0),tocolor(0,205,0,theAlpha),x(1.3),"default-bold","center","center",false,false,false)

i don't understand the other arguments so i'm omitting them

Edit: OMG i'm blind sry did not see the functions below the handler function, edited the above code

Edited by LoPollo
  • Like 1
Posted
25 minutes ago, LoPollo said:

dxDrawText(name.." is requesting Medical Assistance in "..location,x(914.0),y(453.0+rand),x(1322.0),y(504.0),tocolor(0,205,0,theAlpha),x(1.3),"default-bold","center","center",false,false,false)

i don't understand the other arguments so i'm omitting them

Edit: OMG i'm blind sry did not see the functions below the handler function, edited the above code

thank you it worked perfectly but i need to fix anther thing in my server ,i have started a new chat resource but when i type something it repeat it self 3 or 2 times.

can you tell me a solution ?

Posted

With "new chat resource" do you mean a resource that replace the default chatbox? if it's handling onPlayerChat then post here or a new topic the handler function

Posted

 

check the script for a second.--Client

local languages = {
	["English"] = "en",
	["Spanish"] = "es",
	["Afrikaans"] = "af",
	["Albanian"] = "sq",
	["Arabic"] = "ar",
	["Belarusian"] = "be",
	["Bulgarian"] = "bg",
	["Catalan"] = "ca",
	["Chinese"] = "zh",
	["Chinese Simplified"] = "zh-CN",
	["Chinese Traditional"] = "zh-TW",
	["Croatian"] = "hr",
	["Czech"] = "cs",
	["Danish"] = "da",
	["Dutch"] = "nl",
	["Estonian"] = "et",
	["Filipino"] = "tl",
	["Finnish"] = "fi",
	["French"] = "fr",
	["Galician"] = "gl",
	["German"] = "de",
	["Greek"] = "el",
	["Haitian Creole"] = "ht",
	["Hebrew"] = "iw",
	["Hindi"] = "hi",
	["Hungarian"] = "hu",
	["Icelandic"] = "is",
	["Indonesian"] = "id",
	["Irish"] = "ga",
	["Italian"] = "it",
	["Japanese"] = "ja",
	["Korean"] = "ko",
	["Latvian"] = "lv",
	["Lithuanian"] = "lt",
	["Macedonian"] = "mk",
	["Malay"] = "ms",
	["Maltese"] = "mt",
	["Norwegian"] = "no",
	["Persian"] = "fa",
	["Polish"] = "pl",
	["Portuguese"] = "pt",
	["Portuguese Portugal"] = "pt-PT",
	["Romanian"] = "ro",
	["Russian"] = "ru",
	["Serbian"] = "sr",
	["Slovak"] = "sk",
	["Slovenian"] = "sl",
	["Swahili"] = "sw",
	["Swedish"] = "sv",
	["Tagalog"] = "tl",
	["Thai"] = "th",
	["Turkish"] = "tr",
	["Ukrainian"] = "uk",
	["Vietnamese"] = "vi",
	["Welsh"] = "cy",
	["Yiddish"] = "yi",
}

window = guiCreateWindow(0.4229,0.2839,0.1416,0.3411,"Select languages for the translated channel",true)
guiWindowSetSizable(window,false)
guiSetVisible(window,false)
comboBox_to = guiCreateComboBox(0.0621,0.1031,0.8207,0.7069,"Spanish",true,window)
doneButton = guiCreateButton(0.1655,0.8702,0.6621,0.0916,"Done",true,window)

for languageName, language in pairs(languages) do
	guiComboBoxAddItem(comboBox_to, languageName)
end

addEvent("showLangSelector",true)
addEventHandler("showLangSelector",root,
function ()
	guiSetVisible(window,true)
	showCursor(true)
end)

addEventHandler("onClientGUIClick",doneButton,
function ()
	local selectedTo = guiComboBoxGetSelected(comboBox_to)
	if selectedTo then
		local langNameTo = guiComboBoxGetItemText(comboBox_to, selectedTo)
		setElementData(localPlayer,"lang_to",languages[langNameTo])
		guiSetVisible(window,false)
		showCursor(false)
	end
end, false)

--Server Side

local languages = {
	["en"] = "English",
	["es"] = "Spanish",
	["af"] = "Afrikaans",
	["sq"] = "Albanian",
	["ar"] = "Arabic",
	["be"] = "Belarusian",
	["bg"] = "Bulgarian",
	["ca"] = "Catalan",
	["zh"] = "Chinese",
	["zh-CN"] = "Chinese Simplified",
	["zh-TW"] = "Chinese Traditional",
	["hr"] = "Croatian",
	["cs"] = "Czech",
	["da"] = "Danish",
	["nl"] = "Dutch",
	["et"] = "Estonian",
	["tl"] = "Filipino",
	["fi"] = "Finnish",
	["fr"] = "French",
	["gl"] = "Galician",
	["de"] = "German",
	["el"] = "Greek",
	["ht"] = "Haitian Creole",
	["iw"] = "Hebrew",
	["hi"] = "Hindi",
	["hu"] = "Hungarian",
	["is"] = "Icelandic",
	["id"] = "Indonesian",
	["ga"] = "Irish",
	["it"] = "Italian",
	["ja"] = "Japanese",
	["ko"] = "Korean",
	["lv"] = "Latvian",
	["lt"] = "Lithuanian",
	["mk"] = "Macedonian",
	["ms"] = "Malay",
	["mt"] = "Maltese",
	["no"] = "Norwegian",
	["fa"] = "Persian",
	["pl"] = "Polish",
	["pt"] = "Portuguese",
	["pt-PT"] = "Portuguese Portugal",
	["ro"] = "Romanian",
	["ru"] = "Russian",
	["sr"] = "Serbian",
	["sk"] = "Slovak",
	["sl"] = "Slovenian",
	["sw"] = "Swahili",
	["sv"] = "Swedish",
	["tl"] = "Tagalog",
	["th"] = "Thai",
	["tr"] = "Turkish",
	["uk"] = "Ukrainian",
	["vi"] = "Vietnamese",
	["cy"] = "Welsh",
	["yi"] = "Yiddish",
}

addEventHandler("onPlayerJoin",root,
function ()
	bindKey(source,"F4","down",switchChannel)
	setElementData(source,"lang_to","en")
end)

addEventHandler("onResourceStart",resourceRoot,
function ()
	for index, player in pairs(getElementsByType("player")) do
		setElementData(player,"translator",false)
		bindKey(player,"F4","down",switchChannel)
		if not getElementData(player,"lang_to") then
			setElementData(player,"lang_to","en")
		end
	end
end)

function switchChannel(player)
	if getElementData(player,"translator") then
		setElementData(player,"translator",false)
		exports["(T-RPG)Info"]:sendMessage(player,"*CHAT* Translator disabled.",0,255,0)
	else
		setElementData(player,"translator",true)
		triggerClientEvent(player,"showLangSelector",player)
		exports["(T-RPG)Info"]:sendMessage(player,"*CHAT* Translator enabled.",0,255,0)
	end
end

function onChat(message, messageType)
	if (messageType == 0) then
		local r, g, b = getPlayerNametagColor(source)
		outputChatBox(getPlayerName(source)..": #ffffff"..message,getRootElement(),r,g,b,true)
		cancelEvent()
	end
end
addEventHandler("onPlayerChat",root,onChat)

addEvent("onRecieveTranslatedText",true)
addEventHandler("onRecieveTranslatedText",root,
function (player, translatedText, bool, languageCode, message)
if not bool and not message.player then
	local r, g, b = getPlayerNametagColor(player)
		for index, players in pairs(getElementsByType("player")) do
			if getElementData(players,"translator") then
			end
		end
	end
end)

addEventHandler("onRecieveTranslatedText",root,
function (player, translatedText, bool, languageCode, message)
	if message and type(message) == "table" and message.player and type(message.player) == "string" and message.r and message.g and message.b then
		outputChatBox("Translator ("..tostring(languages[languageCode]).."): ".. message.player ..": #ffffff".. translatedText,player,message.r,message.g,message.b,true)
	end
end)

I have checked the /debugscript 3 ,it didn't notice anything at all

25 minutes ago, LoPollo said:

ok so post the handler function of onPlayerChat. 

also check if there are warnings or errors both serverside and clientside

 

Please answer as soon as possible.

Posted (edited)

server line 92: cancelEvent seems to not work therefore every chat message will be outputted twice. BUT that's not a script fault.

I decided to test starting from zero: tried the wiki example #2 and it does not work, calling wasEventCancelled returns false ( so the event was not cancelled)... i never used this kind of functions with the chat but i'm sure that's not the way they should work... so probably i'm missing something BIG or we found a BUG

Let's see if other people can say something about it... i honestly don't know how to handle it, and i can't find anything about this on mantis

Also i'm tired now, and lots of times i can't see what's below my nose (it sounds so bad in english, does this exists in this language? it means i can't see something obvious), maybe that's the case...

Edited by LoPollo

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