MitchPS Posted January 4, 2008 Share Posted January 4, 2008 How you script a welcome message in lua for an MTA server? Link to comment
MaTrIx4057 Posted January 4, 2008 Share Posted January 4, 2008 local joinedPlayerName = getClientName ( source ) outputChatBox ( "Welcome " .. joinedPlayerName .. " to the server!" , source, 255, 255, 255 ) Link to comment
ThePsyco Posted January 4, 2008 Share Posted January 4, 2008 were do i put that code? sorry im not very good with lua Link to comment
Franc[e]sco Posted January 4, 2008 Share Posted January 4, 2008 function onPlayerConnect() local joinedPlayerName = getClientName ( source ) outputChatBox ( "Welcome " .. joinedPlayerName .. " to the server!" , source, 255, 255, 255 ) end addEventHandler("onPlayerJoin", getRootElement (), onPlayerConnect) Link to comment
ThePsyco Posted January 4, 2008 Share Posted January 4, 2008 Were do i put it Franesco? Thanks Link to comment
Franc[e]sco Posted January 4, 2008 Share Posted January 4, 2008 its a function, just put it somewhere on your gamemode, try to put it on the top Link to comment
The_Stig Posted January 5, 2008 Share Posted January 5, 2008 When you say add to the gamemode if i run several modes i take it i will have to add this to every gamemode or can this not just be made into a resource? Im kinda new to all this so just now it makes no sense lol While im here is there a script about that will output to everyone at say 5 min intervals advertising our forums? IE:- Visit our forums at http://www.blahblah.com. cheers Link to comment
Frank-De-Ruiter Posted January 5, 2008 Share Posted January 5, 2008 Well ive got this script my self running on my server but i just put it in an .zip file with the following meta.xml| meta.xml: <meta> <info name="Joinmsg" description="Message To Player when connects" author="<yournamehere>"/> <script src="joinmsg.lua" type="server"/> </meta> And then in the .zip is the meta.xml and joinmsg.lua where the script is in. Link to comment
The_Stig Posted January 6, 2008 Share Posted January 6, 2008 could you upload this file for me please as im having huge problems getting this to work. Cheers. Link to comment
Guest Posted January 6, 2008 Share Posted January 6, 2008 (edited) Make an zip folder in resources and put there 2 files 1. I called it "welcome" function onPlayerConnect() local joinedPlayerName = getClientName ( source ) outputChatBox ( "Welcome " .. joinedPlayerName .. " your txt " , source, 255, 255, 255 ) end addEventHandler("onPlayerJoin", getRootElement (), onPlayerConnect) and meta <meta> <info author="your name" name="welcome" version="1" /> <script src="welcome.lua" type="server" /> </meta> 2. Then in ACL file make new group <group name="welcome"> <object name="resource.welcome"/> </group> Put the "meta" in logs/scripts Run from admin panel in game "welcome" and voila, works in all mods and maps. No need to put script in each map or mode. Edited January 6, 2008 by Guest Link to comment
eAi Posted January 6, 2008 Share Posted January 6, 2008 Can I remind people that you DO NOT have to use zip files for resources. You can just make a folder (named as your resource is) in your resources folder and use that (placing meta.xml, maps, scripts etc in there). You shouldn't need an ACL for this example either, and I'd suggest you avoid using on[something] for function names, it's just going to confuse things. Link to comment
Guest Posted January 6, 2008 Share Posted January 6, 2008 sorry im starting with Lua, wanted help. Link to comment
ChrML Posted January 6, 2008 Share Posted January 6, 2008 No problem Mulder, example is good . Other than that that resource doesn't need an ACL entry because it doesn't use restricted commands/functions. Link to comment
The_Stig Posted January 9, 2008 Share Posted January 9, 2008 Is it possible to change the colour of the text of the welcome message? Im looking to change mine to yellow as opposed to white. Cheers. Link to comment
Jumba' Posted January 9, 2008 Share Posted January 9, 2008 function onPlayerConnect() local joinedPlayerName = getClientName ( source ) outputChatBox ( "Welcome " .. joinedPlayerName .. " your txt " , source, 255, 255, 0 ) end addEventHandler("onPlayerJoin", getRootElement (), onPlayerConnect) This should make it yellow. by the way, the difference is the 255 255 0 instead of 255 255 255 That's the rgb color. So if you want to change it to another color just change those. (or add#RRGGBB infront) here's a nice list. http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html Link to comment
50p Posted January 9, 2008 Share Posted January 9, 2008 Can I remind people that you DO NOT have to use zip files for resources. You can just make a folder (named as your resource is) in your resources folder and use that (placing meta.xml, maps, scripts etc in there). What server have you tested it? On XP I have to create .zip for the resource! If I have to correct something while testing I have to update the whole .zip file! If I don't have the .zip file, server will not detect the resource at all. If I want to start the resource using "start " in server console I see this message: [time] start: Resource could not be found If you create .zip, you won't get that message and resource loads correctly. If I remove the .zip while the resource is loaded and I type "refresh" in console, I see: [time] ERROR: Resource '[resourcename]' has been removed while running! Stopping resource. So why you're saying that we don't have to create .zip? Link to comment
Jumba' Posted January 9, 2008 Share Posted January 9, 2008 Hmm, Odd, you put the folder in the ~\MTA San Andreas\server\mods\deathmatch\resources folder? it works perfectly for me =/. Link to comment
The_Stig Posted January 9, 2008 Share Posted January 9, 2008 function onPlayerConnect() local joinedPlayerName = getClientName ( source ) outputChatBox ( "Welcome " .. joinedPlayerName .. " your txt " , source, 255, 255, 0 ) end addEventHandler("onPlayerJoin", getRootElement (), onPlayerConnect) This should make it yellow. by the way, the difference is the 255 255 0 instead of 255 255 255 That's the rgb color. So if you want to change it to another color just change those. (or add#RRGGBB infront) here's a nice list. http://www.pitt.edu/~nisg/cis/web/cgi/rgb.html Ah superb:D Cheers for that Link to comment
The_Stig Posted January 10, 2008 Share Posted January 10, 2008 Ok just changed it and it throws up this error... mtasadm/mods/deathmatch/resources/Joinmsg/Joinmsg.lua:3: ')' expected near '255' Link to comment
Jumba' Posted January 10, 2008 Share Posted January 10, 2008 Ok just changed it and it throws up this error... mtasadm/mods/deathmatch/resources/Joinmsg/Joinmsg.lua:3: ')' expected near '255' post the changed script. Link to comment
The_Stig Posted January 10, 2008 Share Posted January 10, 2008 Ok just changed it and it throws up this error... mtasadm/mods/deathmatch/resources/Joinmsg/Joinmsg.lua:3: ')' expected near '255' post the changed script. Its ok, i got it working lol When i changed it from 255, 255, 255 to 255, 255, 0 i forgot to add back in the comas Link to comment
[email protected] Posted January 11, 2008 Share Posted January 11, 2008 Welcome messages have been added to the admin-panel, that comes with the server program in developers preview 2 (didn't test it myself though) 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