Jump to content

Welcome to the Forum!

The best place to exchange builds and ideas! Vote for the best ideas and suggestions here.

Join the Avorion Discord!

Connect with other passionate players and talk about the latest news.
Discord

DLC Avorion Into the Rift Out Now!

Now available on Steam!
Steam

[script] add resources at player creation


LoSboccacc
 Share

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
 Share

×
×
  • Create New...