mut slap

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Axionysus

Don't Call Us, We Won't Call You :)
Sep 6, 2004
368
0
0
37
DNS #5
flakmonkey.t35.com
I'm making a mutator with an exec function where players can slap each other and remove 1-10 health points per slap, I'm not putting in a limit to slaps yet. My question is how do I make it so that the player string entered (to be slapped) can be checked against the list of players and then have the appropriate amount of health removed.
Code:
class SlapMut extends Mutator;

var int Strength;
var Pawn Other;
var Player Player;

//example - slap Me103xr5 10 being an as$$
exec function slap(out Player Player, out int Strength, optional string Reason)
{
    local Controller C;
    Level.Game.Broadcast(C, Player @ "is slapped with a strength of" @ Strength @ "for" @ Reason);

    if ( (Strength <= 10)&&(Strength > 0) ){
            ModifyPlayer(Other);
    }
}

function ModifyPlayer(Pawn Other)
{
    Other.Health -= Strength;
    Super.ModifyPlayer(Other);
}

defaultproperties
{
    GroupName="Slap"
    FriendlyName="Slap"
    Description="Slap another player and take away some of their health"
}
ps a pawn is any object that is controlled, the controller is the controller of the pawn and other is the pawn. I dont kno about player.
 
Last edited by a moderator:

draconx

RuneUT
Jun 26, 2002
325
0
0
36
Waterloo, Canada
I dont code for 2K3/4, but i think there is a linked list of controllers you can iterate through to find the specified player.

Also, AFAIK exec functions cannot be used in mutators and you need to use mutate() instead.
 

Axionysus

Don't Call Us, We Won't Call You :)
Sep 6, 2004
368
0
0
37
DNS #5
flakmonkey.t35.com
well heres what ive got so far, but like solidsnake said, the player/string comparison thing doesnt work, especially because I dont kno how to do it.
Code:
exec function Slap(out Controller Player, out int Strength, optional string Reason)
{
 local Controller C;
 for (C = Level.ControllerList; C != None; C = C.NextController)
  {
  if (Player == C)
    {
    if ((C.Pawn != None) && (C.Pawn.Health > 5 ))
    C.Pawn.Health -= Strength;
    Level.Game.Broadcast(C, Player @ "is slapped with a strength of" @ Strength @ "for" @ Reason);
    Level.Game.Broadcast(none, C.Pawn.Health);
    }
  }
}

with a few things changed around from this it does iterate through ControllerList and it does boradcast the names and health values.
 
Last edited:

Axionysus

Don't Call Us, We Won't Call You :)
Sep 6, 2004
368
0
0
37
DNS #5
flakmonkey.t35.com
just noticed that with this
Code:
exec function Slap(out string Player, out int Strength, optional string Reason)
{
 local Controller C;
 for (C = Level.ControllerList; C != None; C = C.NextController)
  //{
  //if (Player == C)
    {
    if ((C.Pawn != None) && (C.Pawn.Health > 5 ))
    C.Pawn.Health -= Strength;
    Level.Game.Broadcast(C, Player @ "is slapped with a strength of" @ Strength @ "for" @ Reason);
    Level.Game.Broadcast(none, C.Pawn.Health);
    }
  //}
}

modifies health but does some crazy stuff, if the pawn has 100 heath and I write ex - slap Rae 100, it returns a health of like 290 for the other pawns and - 10 for Rae and something else for me. Does this have anything to do with the fact that its not passing the health value through super.modifyplayer()?
 

livingtarget

BulletCatcher
Mar 15, 2002
226
0
0
Aberdeen
Try this to check for the playername:
"if ( (C.PlayerReplicationInfo != None) && (Player == C.PlayerReplicationInfo.playername) )"

that should pick the right player I think

Code:
exec function Slap(out string Player, out int Strength, optional string Reason)
{
 local Controller C;
 for (C = Level.ControllerList; C != None; C = C.NextController)
 {
    if ( (C.PlayerReplicationInfo != None) && (Player == C.PlayerReplicationInfo.playername) )
    {
      if ((C.Pawn != None) && (C.Pawn.Health > 5 ))
      {
        C.Pawn.Health -= Strength;
        Level.Game.Broadcast(C, Player @ "is slapped with a strength of" @ Strength @ "for" @ Reason);
        Level.Game.Broadcast(none, C.Pawn.Health);
      }
    }
  }
}

Anyway you get the idea :crazydance:

Also each time any player spawn it calls modifyplayer() so their health will decrease by strength each time. Intended?

Anyway i'm sure you'll find your way eventually.
 
Last edited:

MythOpus

You Have Witnessed The MythMaster @ Work
Jul 22, 2003
19
0
0
34
Canada
www.freewebs.com
How?

Axionysus said:
thnx all, I got it working. I can just see the seedy little eyes of l33t h4xx0rs everywhere waiting to have a slap flame fight.

How did you get it to work? Exec functions can't be called within a mutator :(
 

MythOpus

You Have Witnessed The MythMaster @ Work
Jul 22, 2003
19
0
0
34
Canada
www.freewebs.com
Axionysus said:
I just threw it into my gametype, not the most professional way, but it was just for fun.

AH! I see. Well, if you wish to make a mutator with it, you can simply use it with the mutate function. It seems to work quite well on my server mutator. :D