Jump to content

[BUG] How to fix this interesting bug in this script?


Tokio

Recommended Posts

Posted
function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
				end
			end
        end
	end
	outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

Sometimes working the "asay xy" cmd, sometimes not working. :/ How to fix this bug? 

Posted
Just now, Gourmet. said:

Where is the table 'names' specified?

 

local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}

 

Posted
Just now, Gourmet. said:

Forgot to mention, are there any errors in /debugscript 3?

I do not see anything in debugscript 3

Posted
local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}



function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

@50cent

Not tested though.

Posted
4 minutes ago, Gourmet. said:

local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}



function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

@50cent

Not tested though.

Now when i type for example "/asay asd" output often instead of once

sorry for my bad english :c

Posted

 


local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}



function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Should work.

  • Like 1
Posted
4 minutes ago, Gourmet. said:

 


local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}



function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Should work.

Thank you! :D

Posted
Just now, koragg said:

@Gourmet. what did you edit in his first posted script? I didn't see any problems, share please :D

I'm pretty sure that I just changed the position of outputChatBox() and set it not to output to root but v - the player in that loop.

This is not the most effective solution, but it works.

  • Like 1
Posted
13 hours ago, Gourmet. said:

 


local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}



function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Should work.

Wait, lol! Yesterday was still good, but today it does not work at all the cmd. Wtf? O.o 

Posted
2 minutes ago, 50cent said:

Wait, lol! Yesterday was still good, but today it does not work at all the cmd. Wtf? O.o 

Man, are you sure that no one has access to your FTP and do you trust all admins?

It can't just stop working. Have you edited anything? Please post the current code, meta.xml and server log where the resource could been restarted or interfered with. Maybe you have changed ACL?

Posted
1 minute ago, Gourmet. said:

Man, are you sure that no one has access to your FTP and do you trust all admins?

It can't just stop working. Have you edited anything? Please post the current code, meta.xml and server log where the resource could been restarted or interfered with. Maybe you have changed ACL?

i sure that no one has access to my FTP! i just edited the output nothing else.

function getFixedName(player)
if isElement(player) then
local hisName = getPlayerName(player)
if hisName then
result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
if result then
return result
end
end
end
end

local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}

function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then
					message = table.concat({...}, " ")
					groupName = names[group]
					outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

this is the current code, 

<meta>
<script src="asay.lua" type="server"/>
</meta>

and this is meta

i does not change anything in ACL :/ 

Posted
21 minutes ago, Gourmet. said:

Is the resource running? Anything in /debugscript 3?

 

Make sure that you are LOGGED IN 

The resource running, and I do not see anything in debugscript 3 :/ Yeah, i logged in

Posted (edited)
function adminuzi(thePlayer, commandName, ...)
  	outputDebugString("function is working P1")
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
        		outputDebugString("P2")
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then
          			outputDebugString("P3 - acl valid")
					message = table.concat({...}, " ")
					groupName = names[group]
					outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Try that and tell me what outputs in your /debugscript 3.

 

Maybe something shows up when the resource starts? at debugscript 3 )

Edited by Gourmet.
Posted
29 minutes ago, Gourmet. said:

function adminuzi(thePlayer, commandName, ...)
  	outputDebugString("function is working P1")
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
        		outputDebugString("P2")
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then
          			outputDebugString("P3 - acl valid")
					message = table.concat({...}, " ")
					groupName = names[group]
					outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Try that and tell me what outputs in your /debugscript 3.

 

Maybe something shows up when the resource starts? at debugscript 3 )

output this in debugscript 3:

http://imgur.com/a/WTD1D

but the word does not output in chatbox ._.

No, nothing shows up when i start the script

Posted
2 minutes ago, Gourmet. said:

That is probably caused due to that function getFixedName.

See what happens if you remove it.

Lol, the script now working again O.o 

Posted
1 hour ago, Gourmet. said:

That is probably caused due to that function getFixedName.

See what happens if you remove it.

when i reconnect, the script does not work again, wtf? O.o 

Posted
5 minutes ago, Gourmet. said:

You gotta log in, I guess.

when i connect to the server, i login immediately, because i have a login panel :/ 

Posted (edited)

Try with simple words like "hello", maybe you go over the character limit of outputChatBox

 

Edit: What is the purpose of this script? You do /asay and every single player sees the message, right? If so change this

outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)

To this:

outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,root,0,0,0,true)

And you don't need the for loop with players anyway..

Edited by pa3ck
Posted (edited)
34 minutes ago, pa3ck said:

Try with simple words like "hello", maybe you go over the character limit of outputChatBox

 

Edit: What is the purpose of this script? You do /asay and every single player sees the message, right? If so change this


outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)

To this:


outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,root,0,0,0,true)

And you don't need the for loop with players anyway..

Yeah, but with 'root' flood again the message :S 

Edited by 50cent

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