A SpecialEvent that, when triggered, executes a command.
set bInstigatorContext to true if you want to execute the command in the context of the instigator instead of the SpecialEvent itself. Which means, if bInstigatorContext is set to false you cannot execute commands like "summon", since they need a player to be executed, but commands like "set" will always work since server actors can execute these commands, differently from a player, who needs to be admin, so if a non-admin player will trigger it when it has bInstigatorContext set to true and the command is a "summon" command, nothing will be summoned.
CommandEvent
-
- Godlike
- Posts: 1204
- Joined: Mon Aug 31, 2015 10:31 pm
CommandEvent
You do not have the required permissions to view the files attached to this post.
Last edited by PrinceOfFunky on Sun Oct 29, 2017 4:01 am, edited 1 time in total.
Some of the stuff I created:
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
-
- Skilled
- Posts: 217
- Joined: Wed Jun 09, 2010 12:29 pm
- Personal rank: Phenix
- Location: Portugal
Re: CommandEvent
I´m sorry, I´m probably missing something super obvious but the file that comes with the map is .uc? tried to put it in the system folder but when i try playing the test map i get the message "missing package Comand Event"
-
- Godlike
- Posts: 1204
- Joined: Mon Aug 31, 2015 10:31 pm
Re: CommandEvent
Damn, you're right! That's the source code. I'll update the 7z file with the .u file inside.XaNKoNII wrote:I´m sorry, I´m probably missing something super obvious but the file that comes with the map is .uc? tried to put it in the system folder but when i try playing the test map i get the message "missing package Comand Event"
EDIT: Updated. I placed map/source/u all together in the 7z.
Some of the stuff I created:
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
-
- Skilled
- Posts: 217
- Joined: Wed Jun 09, 2010 12:29 pm
- Personal rank: Phenix
- Location: Portugal
Re: CommandEvent
This does exactly what I was describing many thanks!
2 Questions:
1st- Do you mind if I use it Myleved in my Dimentions map (full credits provided of course)?
2nd- As someone that´s beggining to be ready to accept learning about coding, could you run me a super simple explanation on what you did here?
I only took C# in a few classes back in High school so I have minimal knowledge.I did quick look at the Unreal script... I guess what I dont understand are the entities (for lack of a better name) here
var() String command; - I´m guess this is the actuall mechanism for the comand
var() bool bInstigatorContext; - My guess here would be that this creates the option in the actor propreties window, but how does it actually make it be the instigator to do the action? is Instigator Context some variable that Unreal already has in it´s code?
function Trigger Well this with Super if and else is the final gear and what makes everything spin right?
Like the trigger checks the Instigator option, if true it makes the command work through the pawn that triggers it. If False then some other entity makes the command?
Sorry if i´m being annoying but i´m actually curious
2 Questions:
1st- Do you mind if I use it Myleved in my Dimentions map (full credits provided of course)?
2nd- As someone that´s beggining to be ready to accept learning about coding, could you run me a super simple explanation on what you did here?
I only took C# in a few classes back in High school so I have minimal knowledge.I did quick look at the Unreal script... I guess what I dont understand are the entities (for lack of a better name) here
var() String command; - I´m guess this is the actuall mechanism for the comand
var() bool bInstigatorContext; - My guess here would be that this creates the option in the actor propreties window, but how does it actually make it be the instigator to do the action? is Instigator Context some variable that Unreal already has in it´s code?
function Trigger Well this with Super if and else is the final gear and what makes everything spin right?
Like the trigger checks the Instigator option, if true it makes the command work through the pawn that triggers it. If False then some other entity makes the command?
Sorry if i´m being annoying but i´m actually curious
-
- Godlike
- Posts: 1204
- Joined: Mon Aug 31, 2015 10:31 pm
Re: CommandEvent
1. Of course, you can avoid typing my name if it's boring lol.XaNKoNII wrote:This does exactly what I was describing many thanks!
2 Questions:
1st- Do you mind if I use it Myleved in my Dimentions map (full credits provided of course)?
2nd- As someone that´s beggining to be ready to accept learning about coding, could you run me a super simple explanation on what you did here?
I only took C# in a few classes back in High school so I have minimal knowledge.I did quick look at the Unreal script... I guess what I dont understand are the entities (for lack of a better name) here
var() String command; - I´m guess this is the actuall mechanism for the comand
var() bool bInstigatorContext; - My guess here would be that this creates the option in the actor propreties window, but how does it actually make it be the instigator to do the action? is Instigator Context some variable that Unreal already has in it´s code?
function Trigger Well this with Super if and else is the final gear and what makes everything spin right?
Like the trigger checks the Instigator option, if true it makes the command work through the pawn that triggers it. If False then some other entity makes the command?
Sorry if i´m being annoying but i´m actually curious
2. Mhm, important is the willing for knowledge, the more you know and practice the more you'll be able to code .o.
Let's see the class lol:
Code: Select all
class CommandEvent extends SpecialEvent;
var() String command;
var() bool bInstigatorContext; //If true, use instigator context instead than this SpecialEvent context.
function Trigger(Actor other, Pawn eventInstigator) {
super.Trigger(other, eventInstigator);
if (!bInstigatorContext)
ConsoleCommand(command);
else if (eventInstigator != None)
eventInstigator.ConsoleCommand(command);
}
The "var" means variable so you were correct, "()" makes the variable visible in the actor properties panel(if you type a name inside the parenthesys this variable will be visible in a subsection)
"command" and "bInstigatorContext" are just variables I declared there, they didn't exist in the Actor class, we cannot re-declare variables if they were already declared in the same class or a parent class.
Code: Select all
function Trigger(Actor other, Pawn eventInstigator)
Code: Select all
super.Trigger(other, eventInstigator);
Of course I'm talking about .uc files, but events, like Trigger() declared in Actor.uc, are actually called by native code.
This is the Trigger() function in SpecialEvent.uc:
Code: Select all
function Trigger( actor Other, pawn EventInstigator )
{
local pawn P;
if( bBroadcast )
BroadcastMessage(Message, true, 'CriticalEvent'); // Broadcast message to all players.
else if( EventInstigator!=None && len(Message)!=0 )
{
// Send message to instigator only.
EventInstigator.ClientMessage( Message );
}
}
About the body of Trigger():
Code: Select all
if (!bInstigatorContext)
ConsoleCommand(command);
else if (eventInstigator != None)
eventInstigator.ConsoleCommand(command);
Code: Select all
if (bInstigatorContext is set to false)
call ConsoleCommand() (which is a function declared in Actor.uc and written in native code) directly in the context of this actor(CommandEvent) using "command" variable's value as parameter;
else, if (EventInstigator (which is the pawn who triggered) is not None (since you can call this function giving None instead of a pawn, since there are some Trigger() functions which don't handle with the EventInstigator so it's ok if you use None instead, but this is not the case so we don't want it to be None))
call ConsoleCommand() function in the context of EventInstigator using "command" variable's value as parameter;
Code: Select all
else if( EventInstigator!=None && len(Message)!=0 )
Some of the stuff I created:
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
-
- Skilled
- Posts: 217
- Joined: Wed Jun 09, 2010 12:29 pm
- Personal rank: Phenix
- Location: Portugal
Re: CommandEvent
Thanks a lot, coding is something hard because at first glance is complicated, but if one doesn´t start to learn when he as little oportunities then he will never learn.
Before ending this post I want to ask you something more, the original file you mentioned it was the "compile"? like you uused an external language coding program and then you brought it to the unreal Script? (wich I assume is a slitghly modified coding language)
Before ending this post I want to ask you something more, the original file you mentioned it was the "compile"? like you uused an external language coding program and then you brought it to the unreal Script? (wich I assume is a slitghly modified coding language)
-
- Godlike
- Posts: 1204
- Joined: Mon Aug 31, 2015 10:31 pm
Re: CommandEvent
Nothing is hard if you know you can do it.XaNKoNII wrote:Thanks a lot, coding is something hard because at first glance is complicated, but if one doesn´t start to learn when he as little oportunities then he will never learn.
Before ending this post I want to ask you something more, the original file you mentioned it was the "compile"? like you uused an external language coding program and then you brought it to the unreal Script? (wich I assume is a slitghly modified coding language)
I don't remember having talking about compiling, but well yes, you need a compiler for certain languages, every language needs to be understood by the machine using binary code, since it's not human readable we needed a language which would let us write logic in a human readable way, also we humans are able to synthesize, that's why we created compilers which converts your new language symbols etc into the "old" language, of course you need the "old" language to write a compiler which will convert the new one. These are called levels of abstraction of languages, UnrealScript(level 4/high level) is written in C(level3), which is written in Assembly(level 2), which is written in binary code(level 0/low level), the more you increase the abstraction, the more limited will be the new language(but it will be easier for us to write more complex logic, so limit is relative). NOTE that when you compile a new language, it will be convert into the lowest level, logically, if Assembly is converted in binary, then even C which is written in Assembly will be converted in binary and so on, UnrealScript is converted in binary when you compile it, not in C.
You could actually create a new compiler using UnrealScript which will compile a new language so that in the end you wouldn't need to use UnrealScript anymore, but UnrealScript was made very limited on purpose, its not worth to do it since the new language would be even more limited.
(Compilers as opposite to interpreters, which don't compile but convert in binary in real time. An example is Java, java code is initially compiled in bytecode(a language made on purpose for this) then when you run a jar(bytecode), Java will interpret it and covert it in binary in real time. Of course interpreters are slower than compilers, but they both have different pros and cos, just look them up on the internet)
You can use UCC to compile your unrealscript code, UCC.exe is usually located in the System folder, if you open it from command line using "ucc make" it will compile whatever you told it to compile in UnrealTournament.ini using "EditPackages=...", there must be a folder in the root directory tho, for example the folder CommandEvent, and in the ini you have to add "EditPackages=CommandEvent" under this section [Editor.EditorEngine]. Also the folder has to contain another folder called "Classes" which will contain your uc files. But read it all in the wiki if you're interested.
Some of the stuff I created:
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2
Mods: VisualStreamPlayer, TeamColorOverlay, FunkyMoves, CommandSystem, FunkyPointer, AdvancedMutator, CommandEvent, ParticleSystem, LifeSucks
Gametypes: UTRoyale, UnrealRace
Hacks : Create/Write files with UScript, Read files with UScript, Running files with UScript
Maps: CTF-(POF)-Escher_Fix, CTF-(NotYet)HyperBlast, DM-(NotYet)Condemned, CTF-StalwartXS, UR-Hyperblast, DM-3072-ItalyKinda, DOM-NRMC-Cathode, CTF-TAMC-UnderPressure
Concepts: RabbitHole, Builder gun, HeatMap, Playable arcade cabinet, Stalwartception, Non Conventional Weapons, MainFrame
Memes: Meme#1, Meme#2