Jump to content

[script] add resources at player creation


LoSboccacc

Recommended Posts

I want to make an easier start to a more difficult server, I'd like to give starting players 100k credit, 10k iron and 1k titanium

 

 

I think I can work around the mail system to attach and send the stuff, but I can't find where/how to register the script so it runs at player first creation

 

any pointer? I found in the doc the galaxy has a 'onPlayerCreation' callback, but I still need some way to have that method called and a script attached properly

 

nevermind found it, in the end it's yet another piece of code going in server.lua

 

function onPlayerCreated(index)
    -- default stuff do no touch
    local player = Player(index)
    Server():broadcastChatMessage("Server", 0, "Player %s created!"%_t, player.name)

    -- welcome mail
    local mail = Mail()
    mail.money = 100000
    mail.sender = "The Tutorial Hating Co"
    mail.header = "Greetings"
    mail:setResources(10000, 1000, 0, 0, 0, 0, 0)
    mail.text = "Here's a starting package to boostrap your exploration. This is a dangerous galaxy, don't go alone! "
    player:addMail(mail)

end

Link to comment
Share on other sites

I know it is solved, but I would like to add one more thing:

 

Default start resources are handled by scripts/server/factions.lua (lines 112-118):

    if server.difficulty == Difficulty.Beginner then
        player:receive(40000, 5000)
    elseif server.difficulty == Difficulty.Easy then
        player:receive(20000, 2000)
    else
        player:receive(10000)
    end

Link to comment
Share on other sites

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
×
×
  • Create New...