Izzy Posted March 5, 2015 Share Posted March 5, 2015 Hi everyone, I'm kinda new to scripting as terms of LUA etc. So I need some help creating a script that will show up in my server as "# ff0000(Player Name, who connected) # 008800(is also known as: ) # D4A017(Izzy, IZZY, Izzy696)" Here's an example: http://i1216.photobucket.com/albums/dd3 ... gkrlja.png Could you guys help me out please? Link to comment
John Smith Posted March 5, 2015 Share Posted March 5, 2015 instead of creating your own script, faster way is to edit joinquit resource path: mta directory\server\mods\deathmatch\resources\[gameplay]\joinquit Link to comment
Izzy Posted March 5, 2015 Author Share Posted March 5, 2015 what code would I use to add players' other names, with colours? Link to comment
John Smith Posted March 5, 2015 Share Posted March 5, 2015 outputChatBox has latest argument which can be true/false use 'true' if you want color codes e.g -- server side outputChatBox("a #FFFFFFmessage!",root,255,0,0,true) -- true makes it color coded --client side outputChatBox("a #FFFFFFmessage!",255,0,0,true) -- true makes it color coded Link to comment
Gallardo9944 Posted March 5, 2015 Share Posted March 5, 2015 outputChatBox has latest argument which can be true/falseuse 'true' if you want color codes e.g -- server side outputChatBox("a #FFFFFFmessage!",root,255,0,0,true) -- true makes it color coded --client side outputChatBox("a #FFFFFFmessage!",255,0,0,true) -- true makes it color coded I'm pretty sure he meant the way of outputting all player's previous names depending on the serial. Link to comment
JR10 Posted March 5, 2015 Share Posted March 5, 2015 You could use a database to store all the names related to a certain serial, load the database on start and store the data in a table. You could then append to it any new names and update the database. Link to comment
Gallardo9944 Posted March 5, 2015 Share Posted March 5, 2015 You could use a database to store all the names related to a certain serial, load the database on start and store the data in a table. You could then append to it any new names and update the database. This has a disadvantage. You still have to check names for similarity so the names' lengths don't become extremely huge due to the amount of old nicks. It's better to save last 5 or something Link to comment
Izzy Posted March 5, 2015 Author Share Posted March 5, 2015 Ok guys, I'm new to this after all. So what do I have to do? Link to comment
MisterQuestions Posted March 5, 2015 Share Posted March 5, 2015 Why not create an xml file for saving when player change it nick? Link to comment
darhal Posted March 7, 2015 Share Posted March 7, 2015 Guys he is new why you dont give him example to understand more Link to comment
Tekken Posted March 8, 2015 Share Posted March 8, 2015 Example: addEventHandler('onClientPlayerJoin', root, function() outputChatBox('#FF0000> #FFFFFF' ..getPlayerName(source).. ' #FF0000joined the game', 255, 0, 0, true) end ) addEventHandler('onClientPlayerChangeNick', root, function(oldNick, newNick) outputChatBox('#FF0000^ #FFFFFF' ..oldNick.. ' #FF0000is now known as #FFFFFF' ..newNick, 255, 0, 0, true) end ) addEventHandler('onClientPlayerQuit', root, function(reason) outputChatBox('#FF0000< #FFFFFF' ..getPlayerName(source).. ' #FF0000left the game [#FFFFFF' .. reason .. '#FF0000]', 255, 0, 0, true) end ) Link to comment
Izzy Posted March 10, 2015 Author Share Posted March 10, 2015 That's the default joinquit resource. I'm not talking about adding #ff0000 etc. to the original default joinquit resource. I need to make a script so that when a regular player joins the server with another name, it shows his other names too. I hope you're getting me. In my link I sent before, it has an example of what I am speaking of. I'll give an example. "# ff0000(Player Name, who connected) # 008800(is also known as: ) # D4A017(Izzy, IZZY, Izzy696)" OR [Joinquit] Player is connecting [iP] Izzy is also known as: IzzY, IZZY, Izzy696 Here's another example: http://s22i.imgup.net/knownas5263.png THE JOINQUIT SHOULDN'T BE CHANGED UNLESS IT REALLY NEEDS TO. IT SHOULD WORK AS IT SHOULD, just like the example shown in the link. If I was going to make a Database for this? How would I do it, could someone add me on Skype or something so we can go through this together, only people who know what i'm talking about and are willing to help me please. Skype: izymta XFire: izzymta Link to comment
JR10 Posted March 11, 2015 Share Posted March 11, 2015 If you want to learn more about SQL and databases then I suggest you Google first what SQL is and view some simple examples. You could also take a look at my tutorial: viewtopic.php?f=148&t=38203 Link to comment
Izzy Posted March 13, 2015 Author Share Posted March 13, 2015 I don't think I need SQL for this man, is there any other way to edit the joinquit then? Like add another line which shows the player's other names etc? Link to comment
Mega9 Posted March 13, 2015 Share Posted March 13, 2015 Well, to avoid direct contact with SQL, you could use MTA's account data functions which will deal with SQL themselves you just need to have save-logic system. And yeah, you do need SQL because past names don't magically save by their own. Link to comment
Izzy Posted March 13, 2015 Author Share Posted March 13, 2015 This is lame. I know nothing of what you speak. I understand very little of scripting, I wish that someone could really guide me step to step with an appropriate method. I'm really lost. Link to comment
Addlibs Posted March 13, 2015 Share Posted March 13, 2015 --Initialize: executeSQLQuery("CREATE TABLE IF NOT EXIST names_database (serial TEXT, nick TEXT)") function getOtherNicknames(serial) return executeSQLQuery("SELECT * FROM names_database WHERE serial = ?", serial) --collect data of old nicknames end function recordNewName(serial, name) local oldnames = getOtherNicknames(serial) if oldnames then --if data retrieved, then if #oldnames > 5 then --check if number of records for serial exceeds 5, executeSQLQuery("DELETE FROM names_database WHERE rowid = ?", oldnames[1]['rowid']) --and delete oldest row if that's the case end end executeSQLQuery("INSERT INTO names_database (serial, nick) VALUES(?, ?)", serial, name) --record new nickname end addEventHandler("onPlayerJoin", root, function() local currentName = getPlayerName(source) local serial = getPlayerSerial(source) -- *ACL admin rights required* local aka = getOtherNames(serial) --collect other names before recording current one, to avoid duplicates on message output local othernames = {} --create a temporary table for k, v in ipairs(aka) do table.insert(othernames, v['nick']) --add the name to a separate table end recordNewName(serial, currentName) outputChatBox(currentName .. " #008800is also known as #D4A017" .. table.concat(othernames, ", "), root, 255, 0, 0, true) end ) addEventHandler("onPlayerChangeNick", root, function(old, new) local serial = getPlayerSerial(source) -- *ACL admin rights required* recordNewName(serial, new) end ) ^^ Untested ^^ Also, the order might not be the same as you wanted, therefore, it's better if you insert the code into joinquit resource (without duplicating event handlers eg. just put everything from onPlayerJoin into the first lines of onPlayerJoin in joinquit resource) Link to comment
MisterQuestions Posted March 16, 2015 Share Posted March 16, 2015 .-. already awnsered you, but if you don't know anything of lua scripting. Then try something easier do a script, this should create an xml file, when player changes of nick, add the oldnick to xml file. 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