Jump to content

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


Tokio

Recommended Posts

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? 

Link to post
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"
}

 

Link to post
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.

Link to post
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

Link to post

 


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
Link to post
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

Link to post
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
Link to post
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 

Link to post
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?

Link to post
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 :/ 

Link to post
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

Link to post
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.
Link to post
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

Link to post
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 

Link to post

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
Link to post
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
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...