I've got a mod I'm working on that does the following:
1) You can buy a freelancer hunter license at space ports
2) When equipped (or maybe just in inventory), everytime you kill a pirate, you gain %0% credits. I'm basically going to mimic this function in the collision.js file:
actions.InvokeTrigger("onNpcDie",
{
killer_ship_id: args.caster_id,
ship_id: args.ship_id,
npc_id: game.GetShipOwner(args.ship_id)
});
}
var level = ship.GetLevel(args.ship_id);
var exp_earned = 150 + Math.pow(level, 1.3);
var money_earned = 300 + Math.pow(level,1.3);
if (args.caster_id > 0 && game.IsShipPlayerControlled(args.caster_id))
{
ship.SetCurrentValueDelta(args.caster_id, "experience", exp_earned);
ship.SetCurrentValueDelta(args.caster_id, "money", money_earned);
}
}
But what I'm not piecing together is this line in in the localization file:
Line 235: Notifications.Money.Added: %amount%d added
How do I call that value?
I guess what I'm asking is, whenever i kill a pirate, what is the code to add some amount to the player?
edit: ok, i learned how to do it..partially..still have a question.
if (args.caster_id > 0 && game.IsShipPlayerControlled(args.caster_id))
{
ship.SetCurrentValueDelta(args.caster_id, "experience", exp_earned);
player.AddMoney("jeeplaw", 100500);
player.AddExperience("jeeplaw", 100500);
THAT WORKS. But, that's not going to work for a real mod to be released. Why isn't player.AddExperience(PLAYER, 100500); working? I've got using(player); in the header of the file.
Something isn't adding up.
Hello!
I think there a little misleading in our WIKI:
When you're writing a topic script, then it will contain constants PLAYER (which is your nickname) and PLAYER_SHIP (which is a number).
However, this doesn't works in regular scripts. There are no PLAYER and PLAYER_SHIP constants (as scripts are common for ALL players; topics are created per-player). You need to get the player name from the game by using ship ID number and then give it to the function.
example:
// get player name
var playerName = game.GetShipOwner(args.caster_id);
// now we can use this player name to add money and experience
player.AddMoney(playerName, 100500);
player.AddExperience(playerName, 100500);