• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

Code Need help -> BroadcastLocalizedMessage

O'Shannon

Grizzled Veteran
Oct 18, 2006
380
90
Germany
OK, first off... i am a total scripting-noob....

first i made myself some new rifles( rifles with only 2 clips, for my funmap) after i watched some scripting tuts on 3dbuzz.... and they work!!!

then i thought, you shouldn't be allowed to use ironsights ....haxxed some stuff together ... and it worked(still dont know if my way off removing the ironsights is the right one).

then i thought; man.. would be cool if there would be a message if someone tries to use Ironsights...watch though some classes to figure out how the "PLAYER left the battlefield" message works.... hacked stuff together again and : as soon as i tried to use ironsight a "O'Shannon tried to use Ironsights" messages poped up...

so far so good...

then i tried this on a dedicated server... and nothing is happening....
no massage is poping up but the logMessage still is...

please enlightened me with your scripting skills...why is it not working online but offline.. WHY?????? WHY?????

Kar981Clip.uc
Code:
//=============================================================================
// Kar98k with 2 Clips
//=============================================================================
// Weapon class for the German Karbiner 98k bolt action rifle with only two clip at spawn
//=============================================================================
class Kar981Clip extends Kar98Weapon;

simulated function ROIronSights()
{
   BroadcastLocalizedMessage(Class'NoIronsightsMessage', 1337, Instigator.Controller.PlayerReplicationInfo, none, Class'Kar981Clip');
   log('Disabled ironsights');
}

defaultproperties
{
    InitialNumPrimaryMags=2
	MaxNumPrimaryMags=2
    PickupClass=class'Kar981ClipPickup'
    AttachmentClass=class'Kar981ClipAttachment'
}



NoIronsightsMessage.uc
Code:
//=============================================================================
// NoIronsightsMessage
//=============================================================================
// works offline(kind of) but won't work online
//=============================================================================

class NoIronsightsMessage extends ROGameMessage;

//=============================================================================
// Variables
//=============================================================================

var(Message) localized string NoIronsightsHere;
var(Message) localized string TriedToUseIronsights;

//=============================================================================
// Functions
//=============================================================================

static function string GetString(
    optional int Switch,
    optional PlayerReplicationInfo RelatedPRI_1,
    optional PlayerReplicationInfo RelatedPRI_2,
    optional Object OptionalObject
    )
{
    switch (Switch)
    {
        case 1337:
            if (RelatedPRI_1 == none)
                return Default.NoIronsightsHere;

            return (RelatedPRI_1.PlayerName$Default.TriedToUseIronsights);
            break;
    }
    return "";
}

defaultproperties
{
	NoIronsightsHere="no ironsights here, n00b!!!"
	TriedToUseIronsights=" tried to use Ironsights. what a noob."
	bIsSpecial=false
}
 
Last edited: