How to call the indiviual player score?

MetaMindMetaMind Join Date: 2012-12-06 Member: 174358Members, Reinforced - Gold
I want to unlock things when a certain amount of score is reached... what is the proper call for this

I tried:

self:GetScore()
if self.score > 10 then
...

but its not working... plz help

Comments

  • Soul_RiderSoul_Rider Mod Bean Join Date: 2004-06-19 Member: 29388Members, Constellation, Squad Five Blue
    if you look at the playerdata that is sent to the scoreboard, you will see things like playerscore, kiills, deaths etc. This playerrecord data is what you can use to do things with. Remember though, use the source data, not the scoreboard end, as that only works on client, and you need to be on the server to unlock things.
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    Look at ScoringMixin ( http://ns2docs.bplaced.net/ns2docs/tables/ScoringMixin/index.html ) ;) As long as you make sure via HasMixin() that your target has it you can call GetScore() just fine.

    Seems like in your case self doesnt has that mixin and is therfor not a player.
  • MetaMindMetaMind Join Date: 2012-12-06 Member: 174358Members, Reinforced - Gold
    Thx for the quick respond, will test it out now
  • MetaMindMetaMind Join Date: 2012-12-06 Member: 174358Members, Reinforced - Gold
    So far no success... I tried to implement it in the "PointGiverMixin.lua":
    function PointGiverMixin:OnUpdatePlayer(deltaTime)   
    
    		//periodically award points in survival phase
        if self:isa("Player") and surviviorGamePhase 
    			and surviviorGamePhase == kSurvivorGamePhase.Survival 
    			and self:GetTeamNumber() == kTeam1Index then
    
    			self.lastTimeSurvivalPointsGiven = self.lastTimeSurvivalPointsGiven or Shared.GetTime()
    			if self.lastTimeSurvivalPointsGiven + kSurvivalSecondsPerPoint < Shared.GetTime() then
    				if HasMixin(self, "Scoring") then
    				  //TODO: replace w/ config value
    				  self:AddScore(1,0,false)
    				  self.lastTimeSurvivalPointsGiven = Shared.GetTime()
    				  
    				  score = player:GetScore(),
    				  if player and HasMixin(self, "Scoring") and score then
    				  if score > 5 then
    				   self:GiveItem(Welder.kMapName)
    				   
    				   end
    				   
    			    end
    			    
    			  end
    			  
    		  end
    
    	  end
    
      end
    
    end
    

    but nothing happens... :(
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited June 2014
    Typo:
    score = player:GetScore(), (the coma)

    also better design it as local
  • MetaMindMetaMind Join Date: 2012-12-06 Member: 174358Members, Reinforced - Gold
    I ve decided to make a new function out of it but still there is something wrong...
    function ItemUnlocker()
      
      local score = player:GetScore()
      if self:isa("Player") and self:GetTeamNumber() == kTeam1Index then
        if HasMixin(self, "Scoring") and score > 5 then
        
        self:GiveItem(Welder.kMapName)
        
        end
        
      end
      
      function PointGiverMixin:OnUpdatePlayer(deltaTime)  
        
    		//periodically award points in survival phase
        if self:isa("Player") and surviviorGamePhase 
    			and surviviorGamePhase == kSurvivorGamePhase.Survival 
    			and self:GetTeamNumber() == kTeam1Index then
    
    			self.lastTimeSurvivalPointsGiven = self.lastTimeSurvivalPointsGiven or Shared.GetTime()
    			if self.lastTimeSurvivalPointsGiven + kSurvivalSecondsPerPoint < Shared.GetTime() then
    				if HasMixin(self, "Scoring") then
    				  //TODO: replace w/ config value
    				  self:AddScore(1,0,false)
    				  self.lastTimeSurvivalPointsGiven = Shared.GetTime()
    				  ItemUnlocker()
    				  
    			    
    			  end
    			  
    		  end
    
    	  end
    
      end
    
    end
    
  • GhoulofGSG9GhoulofGSG9 Join Date: 2013-03-31 Member: 184566Members, Super Administrators, Forum Admins, Forum Moderators, NS2 Developer, NS2 Playtester, Squad Five Blue, Squad Five Silver, Reinforced - Supporter, WC 2013 - Supporter, Pistachionauts
    edited June 2014
    function ItemUnlocker()
      
      local score = player:GetScore()
      if self:isa("Player") and self:GetTeamNumber() == kTeam1Index then
        if HasMixin(self, "Scoring") and score > 5 then
        
        self:GiveItem(Welder.kMapName)
        
        end
        
      end
    


    Where should that function get "self" and "player" from? Those vars are nowhere declared as locals or globals for that function.
  • MetaMindMetaMind Join Date: 2012-12-06 Member: 174358Members, Reinforced - Gold
    Hmm yeah youre right, was just trying to call the player(marine) entity but I just dont know how exactly
Sign In or Register to comment.