Deus Ex Clan [A]lpha
homeabout usprojectsmembersmatches
join uschallenge usdownloadsforum
Knowledge Base

Useful functions

home / Knowledge Base / Coding / Useful functions

Obtaining player's IP address

PlayerIP = Player.GetPlayerNetworkAddress();
PlayerIP=left(PlayerIP,instr(PlayerIP,":"));  

The first line gets your IP and port (e.g. 213.170.168.2:4000, where 213.170.168.2 is a IP and 4000 is a port) and the second line filters port leaving only an IP address.

Recognising maps

if (Level.NetMode != NM_Standalone)
{
switch LevelString
{
case "DXMP_CMD.LevelInfo0":
// Actions only for DXMP_CMD
break;
case "DXMP_Area51Bunker.LevelInfo0":
// Actions only for DXMP_Area51Bunker
break;
}
}

Recognising custom parameters 

If you're planning to make functions of your mutator recognise user typed string, like, for example, user ID on the server (MMSwitcher), that's how you can do it:

function Mutate (String S, PlayerPawn Player)
{
local string usrstr;

// The following code will obtain everything user
// typed after command "mutate typed". If you
// typed "mutate typed blah", it should return "blah"
// in a client message

if (mid(S, 0, 5) ~= "typed ")
{
usrstr = mid(S, 5);
Player.ClientMessage("You typed"@usrstr);
}
Super.Mutate(S,Player);
}

Switching teams 

The essence of MMSwitcher — the code of switching player's team without killing him or her and with updating his or her user.ini. Team IDs:
0 — UNATCO
1 — NSF

local pawn victim;

Level.Game.ChangeTeam(victim,0); // set to needed team
PlayerPawn(victim).ClientChangeTeam(0); // set to needed team

Spawning 

That's how we can find a suitable for spawning spawn point (thanks to Nobody for the code):

local navigationpoint navpoint;

navpoint=Level.Game.FindPlayerStart(victim,0);
// Move victim to it
victim.setLocation(navpoint.location);

Managing augmentations 

If you want to delete all augs of a player and to add a specific one, that's how you can do it:

local augmentation aug;

DeusExPlayer(Owner).AugmentationSystem.ResetAugmentations();
aug = DeusExPlayer(Other).AugmentationSystem.Spawn(class'DeusEx.AugLight', DeusExPlayer(Other).AugmentationSystem);
DeusExPlayer(Other).AugmentationSystem.FirstAug = aug;
DeusExPlayer(Other).AugmentationSystem.GivePlayerAugmentation(class'DeusEx.AugLight')

Written by Daedalus and Alex.


indexnext →

Powered by [A]