Page 1 of 2
How to make a localized string message contain a variable?
Posted: Thu 13 Oct , 2011 3:02 am
by LegendaryAgent
Hey all, as usual thanks for all the great help ive been offered so far, i would like to know if what im trying to do is easy or not, basically im trying to make a dynamic message, what i mean with that is i want a message which will contain a variable, lets consider this:
Code: Select all
var int countpickuptimes
static function string GetLocalString(
optional int iMessage,
optional PlayerReplicationInfo RelatedPRI_1,
optional PlayerReplicationInfo RelatedPRI_2
) {
switch (iMessage) {
case 0:
return "You cant heal past your normal health limit with Health PowerUps.";
case 1:
return DynamicMessage;
}
return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
}
defaultproperties
{
DynamicMessage="You have picked up this item" $countpickuptimes $"."
}
if i attempt this it will start whinning about only beying able to access "default values of variables" in getlocalstring:
Error, You can only access default values of variables here
Im not following what on earth is going on here, is there a simple way to overcome this? whats causing this such extreme issue that it wont let me access variables outside that function?
Best Regards!
Re: How to make a localized string message contain a variabl
Posted: Thu 13 Oct , 2011 12:13 pm
by Azarael
Which line produces the error? I suspect it's your default properties line. If that's the case, you need to construct your string somewhere else.
Code: Select all
var int CountPickupTimes;
static function string GetLocalString(
optional int iMessage,
optional PlayerReplicationInfo RelatedPRI_1,
optional PlayerReplicationInfo RelatedPRI_2
) {
switch (iMessage) {
case 0:
return "You can't heal past your normal health limit with Health powerups.";
case 1:
return DynamicMessage $ countpickuptimes $".";
default:
return "Unexpected value of iMessage.";
}
//return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
//pointless
}
defaultproperties
{
DynamicMessage="You have picked up this item"
}
Re: How to make a localized string message contain a variabl
Posted: Thu 13 Oct , 2011 4:49 pm
by LegendaryAgent
Azarael wrote:Which line produces the error? I suspect it's your default properties line. If that's the case, you need to construct your string somewhere else.
Code: Select all
var int CountPickupTimes;
static function string GetLocalString(
optional int iMessage,
optional PlayerReplicationInfo RelatedPRI_1,
optional PlayerReplicationInfo RelatedPRI_2
) {
switch (iMessage) {
case 0:
return "You can't heal past your normal health limit with Health powerups.";
case 1:
return DynamicMessage $ countpickuptimes $".";
default:
return "Unexpected value of iMessage.";
}
//return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
//pointless
}
defaultproperties
{
DynamicMessage="You have picked up this item"
}
Hey the error comes from the case 1: return line, i have even tried leave it unconstructed, ive declared the var string just below the class extending line and left it with no value in defaultproperties, the problem is still the same :\
Re: How to make a localized string message contain a variabl
Posted: Thu 13 Oct , 2011 5:09 pm
by iZumo
It's static function, so only default props can be accessed.
Code: Select all
var int CountPickupTimes;
static function string GetLocalString(
optional int iMessage,
optional PlayerReplicationInfo RelatedPRI_1,
optional PlayerReplicationInfo RelatedPRI_2
) {
switch (iMessage) {
case 0:
return "You can't heal past your normal health limit with Health powerups.";
case 1:
return default.DynamicMessage ....; <- the other must be passed via parameter.
default:
return "Unexpected value of iMessage.";
}
//return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
//pointless
}
defaultproperties
{
DynamicMessage="You have picked up this item"
}
Re: How to make a localized string message contain a variabl
Posted: Thu 13 Oct , 2011 5:52 pm
by LegendaryAgent
Izumo_CZ wrote:It's static function, so only default props can be accessed.
Code: Select all
var int CountPickupTimes;
static function string GetLocalString(
optional int iMessage,
optional PlayerReplicationInfo RelatedPRI_1,
optional PlayerReplicationInfo RelatedPRI_2
) {
switch (iMessage) {
case 0:
return "You can't heal past your normal health limit with Health powerups.";
case 1:
return default.DynamicMessage ....; <- the other must be passed via parameter.
default:
return "Unexpected value of iMessage.";
}
//return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
//pointless
}
defaultproperties
{
DynamicMessage="You have picked up this item"
}
hmm alright so is there a solution to overcome this? or am i stuck with making 1 trillions cases?

Re: How to make a localized string message contain a variabl
Posted: Thu 13 Oct , 2011 7:39 pm
by LegendaryAgent
LegendaryAgent wrote:Izumo_CZ wrote:It's static function, so only default props can be accessed.
Code: Select all
var int CountPickupTimes;
static function string GetLocalString(
optional int iMessage,
optional PlayerReplicationInfo RelatedPRI_1,
optional PlayerReplicationInfo RelatedPRI_2
) {
switch (iMessage) {
case 0:
return "You can't heal past your normal health limit with Health powerups.";
case 1:
return default.DynamicMessage ....; <- the other must be passed via parameter.
default:
return "Unexpected value of iMessage.";
}
//return Super.GetLocalString(iMessage, RelatedPRI_1, RelatedPRI_2);
//pointless
}
defaultproperties
{
DynamicMessage="You have picked up this item"
}
hmm alright so is there a solution to overcome this? or am i stuck with making 1 trillions cases?

Well guys if its trully that hard, then may i ask another question related to this class im making but unrelated to this specific message issue in this thread so i wont have to create a new one?
Re: How to make a localized string message contain a variabl
Posted: Thu 13 Oct , 2011 9:29 pm
by Azarael
Go ahead.
Re: How to make a localized string message contain a variabl
Posted: Thu 13 Oct , 2011 11:52 pm
by LegendaryAgent
Azarael wrote:Go ahead.
ty!
that powerup uses this line to add hp to the instigator:
Code: Select all
Instigator.GiveHealth(HPAmount, Instigator.HealthMax);
this works fine but, normally when u pickup a healt pack or health vial, the health hud icon animates for a second, i think the thing that does it is this:
Code: Select all
simulated static function UpdateHUD(HUD H)
{
H.LastPickupTime = H.Level.TimeSeconds;
H.LastHealthPickupTime = H.LastPickupTime;
}
how can i do that animation here? it adds hp and appears fine in the hud but it doesnt animate the hp(cross like) icon
Is this also complicated?
Re: How to make a localized string message contain a variabl
Posted: Fri 14 Oct , 2011 1:20 am
by Azarael
You can most likely work this out from analysing how the health pickups work first.
Re: How to make a localized string message contain a variabl
Posted: Fri 14 Oct , 2011 1:28 am
by LegendaryAgent
Azarael wrote:You can most likely work this out from analysing how the health pickups work first.
well they are an extension of tournamentpickup, maybe thats why but the item im making is not a tournament pickup, thats why im kinda confused, those 2 lines of code i have got from the healthpack and its super classes.