For the past month or so I've been working on further developing the DrHyde's Vaccine mod to suit the needs of PZ roleplaying servers. There is one feature I'd really like to implement but am unable to.
Vaccinating OTHER PLAYERS -- how can I code a function that will change the other player's bodyDamage()?
So far I've successfully added a UI-button to the HealthPanelUI that opens up when medically checking right-clicked player, but I just can't manage to add function that will change right-clicked player's stats. The code I'm using is simple: adds UI-button and a 'confirmPress' function that runs when that button is pressed. But how do I change the local function confirmPress(button, args) to apply changes to the other player's stats and not the one that initiates the button press (me)?
Any help is appreciated-- please help me solve something that I couldn't figure out in a month worth of time..
-- Functions for button of UIs
local function confirmPress(button, args)
local player = getPlayer();
if player:getInventory():getItemFromType('CmpSyringeWithVirus') then
if player:getInventory():getItemFromType('AlcoholedCottonBalls') then
player:getBodyDamage():setInfected(true);
player:getInventory():Remove("CmpSyringeWithVirus");
player:getInventory():Remove("AlcoholedCottonBalls");
else
player:Say("Cotton balls?");
end--if
else
player:Say("Nothing to inject with..");
end--if
end--function
-- Add HealthPanelUI Syringe Button
local ISHealthPanel_createChildren = ISHealthPanel.createChildren
function ISHealthPanel:createChildren()
ISHealthPanel_createChildren(self);
self.fitness:setWidth(self.fitness:getWidth()/1.5);
self.TOCButton = ISButton:new(self.fitness:getRight(), self.healthPanel.y, 20, 20, "", self, confirmPress);
self.TOCButton:setImage(getTexture("media/ui/iconForMenu.png"));
self.TOCButton.anchorTop = false
self.TOCButton.anchorBottom = true
self.TOCButton:initialise();
self.TOCButton:instantiate();
self:addChild(self.TOCButton);
if getCore():getGameMode() == "Tutorial" then
self.TOCButton:setVisible(false);
end
end
local ISHealthPanel_render = ISHealthPanel.render
function ISHealthPanel:render()
ISHealthPanel_render(self);
self.TOCButton:setY(self.fitness:getY());
end