codeluaeveryday Posted October 4, 2011 Share Posted October 4, 2011 (edited) Hey guys, i require some more assistance understanding lua, TAPL, can you explain why this won't work. i have attempted to create a command which outputs to the chatbox, now, i am adding a language system, my meta file contains this setting btw. Its not done. syntax: /note hello output: (NOTE) Chris: Hello meta: <meta> <info author="[EGL]Chris" version="0.5" type="script" name="Essentials" description="This script add's alot of features for admin's and players. Hope you like it." /> <settings> <!--We currently accept the languages of english, spanish, arabic.--> <setting name="*language" value="spanish" /> <setting name="*joinquitcolor" value="255,200,100" /> </settings> <script src="admintag.lua" type="server" /> <script src="admincommands.lua" type="server" /> <script src="ip+serial.lua" type="server" /> <script src="outputs.lua" type="server" /> <script src="joinquit.lua" type="server" /> </meta> Server ofc: local root = getRootElement() local name = getPlayerName(source) local account = getPlayerAccount(source) local language = get('language') function note (text, msgtype) if language == "english" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) outputServerLog("NOTE: ".. name) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255) end end elseif language == "spanish" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255) end end elseif language == "arabic" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255) end addCommandHandler("note", note) Edited October 5, 2011 by Guest Link to comment
Kenix Posted October 4, 2011 Share Posted October 4, 2011 (edited) local root = getRootElement() -- root is global variable MTA local name = getPlayerName(source) -- you can`t use here source local account = getPlayerAccount(source) -- and here -- read wiki [url=https://wiki.multitheftauto.com/wiki/Event_system]https://wiki.multitheftauto.com/wiki/Event_system[/url] local language = get('language') function note (text, msgtype) -- you forgot variable in function "source" read wiki [url=https://wiki.multitheftauto.com/wiki/AddCommandHandler]https://wiki.multitheftauto.com/wiki/AddCommandHandler[/url] if language == "english" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) outputServerLog("NOTE: ".. name) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255) end end elseif language == "spanish" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255) end end elseif language == "arabic" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255) end addCommandHandler("note", note) Correct: local language = get('language') function note (source,cmd,text) local name = getPlayerName(source) local account = getAccountName(getPlayerAccount(source)) if language == "english" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) outputServerLog("NOTE: ".. name) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255) end elseif language == "spanish" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255) end elseif language == "arabic" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255) end end end addCommandHandler("note", note) Use the tabulation to keep the code more viewed and you will immediately see where something is missing Edited October 4, 2011 by Guest Link to comment
TAPL Posted October 4, 2011 Share Posted October 4, 2011 wrong wrong wrong look at this local account = getPlayerAccount(source) should be local account = getAccountName(getPlayerAccount(source)) also "true" needed in outputChatBox to enable colorCoded msgtype: not needed because you aren't use event onPlayerChat you use addCommandHandler correct local language = get('language') function note (source,cmd,text) local name = getPlayerName(source) local account = getAccountName(getPlayerAccount(source)) if language == "english" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255, true) outputServerLog("NOTE: ".. name) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000Access to /note denied!",root,255, 255, 255, true) end elseif language == "spanish" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(NOTA) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000El acceso a /nota negado!",root,255, 255, 255, true) end elseif language == "arabic" then if isObjectInACLGroup("user." .. account, aclGetGroup("Admin")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("SuperModerator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Moderator")) then outputChatBox("#FF0000(ملاحظة) "..name..":#FFFFFF "..text,root,255, 255, 255, true) elseif isObjectInACLGroup("user." .. account, aclGetGroup("Everyone")) then outputChatBox("#FF0000 الحصول على /note رفض!",root,255, 255, 255, true) end end end addCommandHandler("note", note) Link to comment
Kenix Posted October 4, 2011 Share Posted October 4, 2011 wrong wrong wronglook at this local account = getPlayerAccount(source) should be local account = getAccountName(getPlayerAccount(source)) Yes you right i forgot this ty also "true" needed in outputChatBox to enable colorCoded Read wiki: bool outputChatBox ( string text [, element visibleTo=getRootElement(), int r=255, int g=255, int b=255, bool colorCoded=false ] ) colorCoded Default: false msgtype: not needed because you aren't use event onPlayerChat you use addCommandHandler Maybe he want to create in future for this variable to use it. Link to comment
TAPL Posted October 4, 2011 Share Posted October 4, 2011 outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255, true) What is the difference between them? The first will be: #FF0000(NOTE) TAPL:#FFFFFF Hello The second will be: (NOTE) TAPL: Hello you see the difference? Link to comment
Kenix Posted October 4, 2011 Share Posted October 4, 2011 outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255) outputChatBox("#FF0000(NOTE) "..name..":#FFFFFF "..text,root,255, 255, 255, true) What is the difference between them? The first will be: #FF0000(NOTE) TAPL:#FFFFFF Hello The second will be: (NOTE) TAPL: Hello you see the difference? Yes you right i forgot it I tired today. Link to comment
codeluaeveryday Posted October 5, 2011 Author Share Posted October 5, 2011 Thank you both. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now