I'm currently working on the code of a new Enforcer which has a flashlight equipped, which will be configurable to adjust brightness, colors and other more complex options like a rechargeable battery, similar to the flashlight from Half Life.
Now I'm struggling a little with the key inputs because they work but not as they should. I managed to make the flashlight turn on and off with the same key press, however, doing this activates all the flashlights from all Enforcers, not just the one that I am using, it also turns on an off when other weapons are equipped and that's not how it should works, I want it to turn itself on only for me and only when I have the enforcer equipped.
I'm posting on my phone so I can't add any code but anything helps, I would check key press functions from other weapons but I don't have any.
I need help (Key Input).
-
- Masterful
- Posts: 542
- Joined: Tue Jan 22, 2013 5:23 pm
- Personal rank: Nullified!
- Location: (X) Unable To Locate....
Re: I need help (Key Input).
I/We won't get the solution to your problem unless you drop code here.
And btw Welcome to the Forums!
And btw Welcome to the Forums!
-
- Godlike
- Posts: 3774
- Joined: Fri Jan 14, 2011 1:53 pm
- Personal rank: -Retired-
Re: I need help (Key Input).
If you are using the keypress for ActivateItem then you aren't subclassing your flashlight properly. You are running into a consistent problem in the unreal series in that item usage is a pain in the ass to make it work easily on the client without adding commands to the User.ini.
Rocky is right, we need to see your code. You can post publicly or send it to me privately if you'd rather not show it yet and we/I can help you. I'm working on this very thing myself for my Unreal coop server. I don't like how the flashlight beam lags on server so I'm going to disconnect it to be rendered client-side only if you are the owner.
Rocky is right, we need to see your code. You can post publicly or send it to me privately if you'd rather not show it yet and we/I can help you. I'm working on this very thing myself for my Unreal coop server. I don't like how the flashlight beam lags on server so I'm going to disconnect it to be rendered client-side only if you are the owner.
So long, and thanks for all the fish
Re: I need help (Key Input).
I am not using the standard activate, I'm making my own key binds to avoid issues.
I'm pretty sure the issue is in the mutator class that has the mutate function:
This mutator is called by the Enforcer itself, and I'm sure this is the issue because of that "ForEach AllActors" but I don't know how to make it work differently yet.
Edit.
I found the solution, exec functions!
I deleted the key binds and mutators and simply made it an exec function and it worked, I just need to add the function to the user.ini via mod menu.
I'm pretty sure the issue is in the mutator class that has the mutate function:
Code: Select all
Class Enforcer_Switch Extends Mutator;
Function AddMutator (Mutator M)
{
If (M.IsA ('Enforcer_Switch')) Return;
Super.AddMutator (M);
}
Function Mutate (String MutateString, PlayerPawn Sender)
{
Local XEnforcer Other;
If (MutateString == "Enforcer_Flashlight")
{
ForEach AllActors (Class 'X.XEnforcer', Other)
{
If (Other.IsA (('XEnforcer')) Other.Flashlight (); // This is the function that activates the light.
}
}
If (NextMutator != None) NextMutator.Mutate (MutateString, Sender);
}
This mutator is called by the Enforcer itself, and I'm sure this is the issue because of that "ForEach AllActors" but I don't know how to make it work differently yet.
Edit.
I found the solution, exec functions!
I deleted the key binds and mutators and simply made it an exec function and it worked, I just need to add the function to the user.ini via mod menu.
-
- Godlike
- Posts: 3774
- Joined: Fri Jan 14, 2011 1:53 pm
- Personal rank: -Retired-
Re: I need help (Key Input).
Don't use IsA to iterate your changes. Change this line from
to
It's a grand idea to never use IsA unless you are given no real choice. IsA will grab all children of a class and since you just never know what might get reused by someone else you need to make sure your stuff doesn't affect someone else down the line.
Code: Select all
If (Other.IsA (('XEnforcer')) Other.Flashlight (); // This is the function that activates the light.
Code: Select all
if(Other.Class==Class'XEnforcer') Other.Flashlight (); // This is the function that activates the light.
So long, and thanks for all the fish
Re: I need help (Key Input).
Thanks a lot Jack, I will make sure to try it out. In any case, I learnt about exec functions and that's cool.