Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Event to happen when Player kills someone
#1
Hey, I just recently started modding (actually yesterday), and I've been searching around for a while to find a method that lets me for instance give the player full ammo on his weapon whenever he/she kills someone. I read something about "onPlayerKilled()", tried searching in _rank.gsc and couldn't find it, so I wrote it myself as a seperate method inside _rank.gsc:

onPlayerKilled()
{
self giveMaxAmmo("crossbow_explosive_mp", 0, false);
}

This didn't help at all, so I was wondering if any of you hardcore modders out there could help me with it. (And yes, I had already given the player the weapon indicated) I'd also appreciate if you'd help me nail the basic classes that I need to know about other than _rank.gsc
Thank you in advance!
Reply

#2
In maps/mp/gameptypes/_callbacksetup.gsc

Code:
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
    self endon("disconnect");

        if(eAttacker.team == "allies" && self.team == "axis" && eAttacker.lasthunter == 0)
    {
        self.bounty += 75;

    }

Use it like that.
Reply

#3
(03-20-2012, 18:36)Lemon Wrote: In maps/mp/gameptypes/_callbacksetup.gsc

Code:
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
    self endon("disconnect");

        if(eAttacker.team == "allies" && self.team == "axis" && eAttacker.lasthunter == 0)
    {
        self.bounty += 75;

    }

Use it like that.

What exactly is self.bounty? And why do we add 75 to it? And do I have to call this method within _rank.gsc or how does it come together?
My programming knowledge is limited to basic java, and I'm trying to understand how this language connects.
Reply

#4
he means add the file maps/mp/gameptypes/_callbacksetup.gsc to your mod and find this line

Code:
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
    self endon("disconnect");

//do stuff here

}

then all u have to do is add want you want done then add the file to your mod.csv like
Code:
rawfile,maps/mp/gameptypes/_callbacksetup.gsc

Reply

#5
I had the same problem, you have to call the CallbackOnPlayerDeath.
This is the original Callback
Code:
/*================
Called when a player has been killed.
self is the player that was killed.
================*/
CodeCallback_PlayerKilled(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{
    self endon("disconnect");
    [[level.callbackPlayerKilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);
}

But i had to rewrite it because it was giving me loads of problems, first of all you need to write this new fuction on _rank.gsc
Code:
onserverstart()
{
        wait 1; //to ensure the callbacks are already written
        //store the old callbacks
        level.oldcallbackplayerkilled=level.callbackplayerkilled;
        //now, create new callbacks
        level.callbackplayerkilled=::killed;
}

After doing this, you have to write the following
Code:
killed(eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration)
{


         if(isdefined(eAttacker)&&isplayer(eAttacker)&&eAttacker!=self)
        {
                eAttacker iPrintlnBold("^2You killed "+self.name);
        }
                
[[level.oldcallbackplayerkilled]](eInflictor, eAttacker, iDamage, sMeansOfDeath, sWeapon, vDir, sHitLoc, timeOffset, deathAnimDuration);

}

You just have to play around with eAttacker(the attacker) in the code up here, you get a message when you killed someone, but if you change it around it will show a message when they kill you.

Im also adding the original file where i found the function, i have to upload it lika a .txt, but is a gsc file.

Take care.


Attached Files
.txt   _callbacksetup.txt (Size: 9.19 KB / Downloads: 16)
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Sentry Gun kill = Player kill Snake 8 5,914 11-07-2013, 13:41
Last Post: Nekochan
  Player can write Fl0w_.JACKDAN 2 3,370 09-19-2013, 16:36
Last Post: Fl0w_.JACKDAN
  [CoD 4] Trying to set a player -- DidUknowiPwn 7 5,893 07-03-2013, 21:58
Last Post: Pozzuh
  [Release] Black Ops Single Player/Zombie Trainer V3.6 Craig87 52 88,892 07-01-2013, 15:12
Last Post: explosivebanana55
Video Preview AIZombies eXtreme 2.0 / Zombie Player (Music Player) DidUknowiPwn 4 5,884 06-24-2013, 16:37
Last Post: DidUknowiPwn
  "VEH_LinkCommonChecks: Player already has an owner" - After long games akillj 4 3,647 06-07-2013, 11:38
Last Post: akillj
  Question on how to "Spawn" a flying rocket as a player? akillj 8 5,579 06-04-2013, 01:54
Last Post: rotceh_dnih
  Using Cheat Engine with Zombies Single Player kikkawa 3 11,003 06-03-2013, 01:18
Last Post: kikkawa
  [Request] Random player model hillbilly 1 2,766 05-12-2013, 08:30
Last Post: archit
Brick [Release] MW3 Single Player CONSOLE v1.9.433 can1907 13 29,699 05-01-2013, 15:18
Last Post: vton

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.