Eth Posted December 14, 2014 Share Posted December 14, 2014 So hello everyone, My name is Eth and I have recently moved from SAMP to MTA [let's face it, MTA Is way better than SAMP] So when I joined MTA I started to script my own gamemode right away as I have Large experience in programming in different languages and everything works great! but I have a little problem here, I am trying to do an announce command for admins that will announce a text for 5 seconds then disappears again, I have searched in MTA wiki but I didn't find the best way to do it. here is my announce command: function Announce( sourcePlayer, commandname, ...) local message = table.concat({...}, " ") if(message ~= nil and message ~= "") then if(tonumber(getElementData(sourcePlayer,"Admin")) < 2) then outputChatBox("ERROR: you Can't use This CMD.",sourcePlayer) outputDebugString("WARNING: Player " .. getPlayerName(sourcePlayer) .. " has attempt to use An ADMIN command. [/"..commandname.."]") return end -- I want my code to be here to announce message else outputChatBox("Error Right Syntax: /announce [text] ",sourcePlayer) end end so how can I do that? thank you. Link to comment
Eth Posted December 14, 2014 Author Share Posted December 14, 2014 Little help please thank you :0 Link to comment
Moderators IIYAMA Posted December 14, 2014 Moderators Share Posted December 14, 2014 https://wiki.multitheftauto.com/wiki/TextCreateTextItem and there are more functions below you can use.(on that site) > Take a closer look at the examples and you will know how to use them. Personally I am more a fan of clientside dx functions, I never tried to use those functions myself. Link to comment
Mr_Moose Posted December 14, 2014 Share Posted December 14, 2014 I would also recommend DX functions, have a look at this maybe which already does most of the job for you: https://github.com/GTWCode/GTW-RPG/tree/master/resources/GTWtopbar, by including that a simple announce command based on your code would look like this: function Announce( sourcePlayer, commandname, ...) local message = table.concat({...}, " ") if(message ~= nil and message ~= "") then if(tonumber(getElementData(sourcePlayer,"Admin")) < 2) then outputChatBox("ERROR: you Can't use This CMD.",sourcePlayer) outputDebugString("WARNING: Player " .. getPlayerName(sourcePlayer) .. " has attempt to use An ADMIN command. [/"..commandname.."]") return end export.GTWtopbar("Note: "..message, root, 255, 255, 255) else outputChatBox("Error Right Syntax: /announce [text] ",sourcePlayer) end end addCommandHandler("announce", Announce) Link to comment
Dealman Posted December 14, 2014 Share Posted December 14, 2014 I strongly advice against storing Admin permission related stuff in Element Data... Link to comment
Eth Posted December 15, 2014 Author Share Posted December 15, 2014 Too many nice people, Thank you everyone! already solved please /lock this topic Link to comment
johny46 Posted December 15, 2014 Share Posted December 15, 2014 I strongly advice against storing Admin permission related stuff in Element Data... Can you recommend any alternative? Where do you think such data should be stored? 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