Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: Ranking-when you shot somebody you got some xp

  1. #11
    Private First Class
    Join Date
    Jul 2013
    Posts
    170
    Thanks
    44
    Thanked 16 Times in 11 Posts
    Translate at english?

  2. #12
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Code:
    init()
    {
    	level.assist_plusscore = 2;
    	if(getcvar("g_gametype") == "dm")
    		level.dm_style = true;
    	else
    		level.dm_style = false;
    	thread waitforconnect();
    	thread hijack_callbacks();
    }
    
    hijack_callbacks()
    {
    	wait .1;
    	level.old_callbackPlayerDamage = level.callbackPlayerDamage;
    	level.callbackPlayerdamage = ::playerdamage;
    	level.old_callbackPlayerKilled = level.callbackPlayerKilled;
    	level.callbackPlayerKilled = ::playerkilled;
    }
    
    playerdamage(eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset) 
    {
    	if(isdefined(eAttacker) && isplayer(eAttacker) && eAttacker != self && (level.dm_style || eAttacker.pers["team"] != self.pers["team"]))
    	{
    		found = false;
    		for(i = 0; i < self.assist; i++)
    		{
    			if(isdefined(self.assist[i]) && self.assist[i] == eAttacker)
    			{
    				found = true;
    				break;
    			}
    		}
    		if(!found)
    			self.assist[self.assist.size] = eAttacker;
    	}
    	self [[level.old_callbackPlayerDamage]](eInflictor, eAttacker, iDamage, iDFlags, sMeansOfDeath, sWeapon, vPoint, vDir, sHitLoc, timeOffset);
    }
    
    playerkilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
    {
    	for(i = 0; i < self.assist.size; i++)
    	{
    		if(isdefined(self.assist[i]) && (!isdefined(eAttacker) || self.assist[i] != eAttacker) && (level.dm_style || self.assist[i].pers["team"] != self.pers["team"]))
    		{
    			self.assist[i].score += level.assist_plusscore;
    			self.assist maps\mp\gametypes\__damagefeedback::updateDamageFeedback();
    	}
    	self [[level.old_callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
    }
    
    waitforconnect()
    {
    	while(true)
    	{
    		level waittill("connecting", player);
    		player thread waitforspawn();
    	}
    }
    
    waitforspawn()
    {
    	self endon("disconnect");
    	while(true)
    	{
    		self waittill("spawned_player");
    		self.assist = [];
    	}
    }
    Just wrote an updated version of the code, should only require a call to init() instead of that much calls as in the tutorial i linked.

    Untested.

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    Ni3ls (8th October 2013)

  4. #13
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    I will test it after my college

  5. #14
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    PHP Code:
            if(isdefined(self.assist[i]) && (!isdefined(eAttacker) || self.assist[i] != eAttacker) && (level.dm_style || self.assist[i].pers["team"] != self.pers["team"]))
            {
                
    self.assist[i].score += level.assist_plusscore;
                
    self.assist maps\mp\gametypes\__damagefeedback::updateDamageFeedback(); 
    Missing "}"

    PHP Code:
    self.assist maps\mp\gametypes\__damagefeedback::updateDamageFeedback(); 
    1 "_" to much and some potentional infinite loops in the for and while.

    But server crash
    PHP Code:
    pair '0' and 'array' has unmatching types 'int' and 'object': (file 'niels/_assist.gsc'line 26)
      for(
    0self.assisti++) 
    PHP Code:
    playerdamage(eInflictoreAttackeriDamageiDFlagssMeansOfDeathsWeaponvPointvDirsHitLoctimeOffset
    {
        if(
    isdefined(eAttacker) && isplayer(eAttacker) && eAttacker != self && (level.dm_style || eAttacker.pers["team"] != self.pers["team"]))
        {
            
    found false;
            for(
    0self.assisti++)
            {
                if(
    isdefined(self.assist[i]) && self.assist[i] == eAttacker)
                {
                    
    found true;
                    break;
                }
            
    wait 1;
            }
            if(!
    found)
                
    self.assist[self.assist.size] = eAttacker;
        }
        
    self [[level.old_callbackPlayerDamage]](eInflictoreAttackeriDamageiDFlagssMeansOfDeathsWeaponvPointvDirsHitLoctimeOffset);


  6. #15
    Private
    Join Date
    May 2013
    Posts
    27
    Thanks
    0
    Thanked 19 Times in 11 Posts
    Just add .size like in playerkilled():

    for(i = 0; i < self.assist.size; i++)

  7. The Following User Says Thank You to PatmanSan For This Useful Post:

    Ni3ls (8th October 2013)

  8. #16
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    it has some lagg of killing. You kill a player and you see the hitmarker. Then there is the wait of 1 second. After that you see the player death anmation and you get the notify You killed bot0. And sometimes the model of the player who got killed is still there. Looks like ClonePlayer().

  9. #17
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    How did you "fix" the "potential inf loop", as i fail to see where it becomes an inf loop. If you added a wait in the for() loop, then ofc it hangs. Do not add any waits.

  10. #18
    Private
    Join Date
    May 2013
    Posts
    27
    Thanks
    0
    Thanked 19 Times in 11 Posts
    PHP Code:
    self.assist maps\mp\gametypes\_damagefeedback::updateDamageFeedback(); 
    that should be

    PHP Code:
    self.assist[imaps\mp\gametypes\_damagefeedback::updateDamageFeedback(); 

  11. #19
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Thanks patman, but it should also have been threaded, which probably is causing the delay.

    As i said before, code was untested xD

  12. #20
    Private
    Join Date
    May 2013
    Posts
    27
    Thanks
    0
    Thanked 19 Times in 11 Posts
    Wouldn't hurt to thread it, but his delay is definitely coming from the "wait 1;" in his loop (see his code above).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •