Best4Gamers Posted February 4, 2017 Share Posted February 4, 2017 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 More sharing options...
Laserzwei Posted February 4, 2017 Share Posted February 4, 2017 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 More sharing options...
Best4Gamers Posted February 4, 2017 Author Share Posted February 4, 2017 thanks ;D Link to comment Share on other sites More sharing options...
Best4Gamers Posted February 4, 2017 Author Share Posted February 4, 2017 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 More sharing options...
Best4Gamers Posted February 4, 2017 Author Share Posted February 4, 2017 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 More sharing options...
Laserzwei Posted February 4, 2017 Share Posted February 4, 2017 addMail(mail) to player:addMail(mail) addMail(mail) is a method that belongs to the player object Link to comment Share on other sites More sharing options...
Best4Gamers Posted February 4, 2017 Author Share Posted February 4, 2017 tried it ... nothing happened lol . no errors also Link to comment Share on other sites More sharing options...
Laserzwei Posted February 4, 2017 Share Posted February 4, 2017 try without mail.receiver = player.id if that doesn't help add mail.money = 0 Link to comment Share on other sites More sharing options...
Best4Gamers Posted February 4, 2017 Author Share Posted February 4, 2017 im gonna pass on this mail lol never loved sqirell lua scripts XD thank you very much for your help Link to comment Share on other sites More sharing options...
Laserzwei Posted February 4, 2017 Share Posted February 4, 2017 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 More sharing options...
Best4Gamers Posted February 4, 2017 Author Share Posted February 4, 2017 thank you , it works now :) Link to comment Share on other sites More sharing options...
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