Jump to content

sending mail to new created player


Best4Gamers

Recommended Posts

i having an issue that im not fully understand how to send a mail to a new created player

 

http://stonelegion.com/Avorion/Documentation/Player%20[server].html#Player

 

function onPlayerCreated(index)

    local player = Player(index)

    Server():broadcastChatMessage("Server", 0, "Player %s created!"%_t, player.name)

    function var addMail(Mail )

end

 

 

need some help , thanx

Link to comment
Share on other sites

using the API of the Mail object:

http://stonelegion.com/Avorion/Documentation/Mail.html

you want something like this:

function onPlayerCreated(index)
    local player = Player(index)
    Server():broadcastChatMessage("Server", 0, "Player %s created!"%_t, player.name)
    local mail = Mail()
    mail.money = 1
    mail.sender = "Your Server name"
    mail.receiver = player.id
    mail.header = "Greetings newcomer"
    mail.text = "You get ".. mail.money .." free money!"
    addMail(mail)
end 

Link to comment
Share on other sites

could not execute function 'onPlayerLogIn' in '"data/scripts/server/server.lua"':

data/scripts/server/server.lua:56: attempt to call global 'addMail' (a nil value)

stack traceback:

data/scripts/server/server.lua:56: in function <data/scripts/server/server.lua:47>

Link to comment
Share on other sites

function onPlayerLogIn(playerIndex)
    local player = Player(playerIndex)
    Server():broadcastChatMessage("Server", 0, "Commander %s entered Apocalyptic Galaxy"%_t, player.name)

    player:addScriptOnce("headhunter.lua")
    player:addScriptOnce("eventscheduler.lua")
    player:addScriptOnce("story/spawnswoks.lua")
    player:addScriptOnce("story/spawnai.lua")
    player:addScriptOnce("story/spawnguardian.lua")
    player:addScriptOnce("story/spawnadventurer.lua")

    matchResources(player)

local mail = Mail()
    mail.sender = "Apocalyptic Galaxy"
    mail.receiver = player.id
    mail.header = "Greetings newcomer"
    mail.text = "Welcome to Apocalyptic Galaxy , Join our steam group at http://steamcommunity.com/groups/bestforgamers"
    addMail(mail)
end

 

what i did wrong ?

Link to comment
Share on other sites

Well I just tried it:

function onPlayerLogIn(playerIndex)
    local player = Player(playerIndex)
    Server():broadcastChatMessage("Server", 0, "Player %s joined the galaxy"%_t, player.name)

    player:addScriptOnce("headhunter.lua")
    player:addScriptOnce("eventscheduler.lua")
    player:addScriptOnce("story/spawnswoks.lua")
    player:addScriptOnce("story/spawnai.lua")
    player:addScriptOnce("story/spawnguardian.lua")
    player:addScriptOnce("story/spawnadventurer.lua")

    matchResources(player)
    print("Mail")
    local mail = Mail()
    mail.money = 1000
    mail.sender = "Apocalyptic Galaxy"
    mail.header = "Greetings newcomer"
    mail.text = "Welcome to Apocalyptic Galaxy "
    player:addMail(mail)
end

 

and it had the following result:

http://imgur.com/a/wb2zZ

 

edit: img-tags didn't work :P

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