Jump to content

(help needed) "Player also known as" script


Izzy

Recommended Posts

Posted

instead of creating your own script, faster way is to edit joinquit resource

path:

mta directory\server\mods\deathmatch\resources\[gameplay]\joinquit

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted

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 

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted
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 

I'm pretty sure he meant the way of outputting all player's previous names depending on the serial.

Posted
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

Posted

Guys he is new why you dont give him example to understand more

#include <iostream>

int main() {

    std::cout << "C++ is amazing <3" << std::endl;

    return 0;

}

I left MTA !... I m doing some tuts about (servers and scripting here) subscribe please

Posted

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 
) 

Resources I made:

Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!

 

Posted

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

Posted

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?

Posted

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.

 

Posted

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.

Posted
 --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)

Previously known as MrTasty.

Posted

.-. already awnsered you, but if you don't know anything of lua scripting. Then try something easier xD

do a script, this should create an xml file, when player changes of nick, add the oldnick to xml file.

"El conocimiento jamás debe detenerse, por que es lo único que nos salvará cuando no nos quede más".

Att: -|TG|-Mister[Q]<.

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...