Reputation: 23
I've been trying to rack my brain around how I create this function call that I have no problems writing in Lua but I'm converting stuff over to C# to leave Lua and head over to something new. Much appreciated for any help I can get, I've attached the working Lua code and as far as I've got it in C#, I've also added a comment to the part of the code I can't figure out.
Lua CODE:
Progress({
name = "unique_action_name",
duration = 1000,
label = 'Doing Something',
useWhileDead = true,
canCancel = true,
controlDisables = {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
},
animation = {
animDict = "missheistdockssetup1clipboard@base",
anim = "base",
flags = 49,
},
prop = {
model = "p_amb_clipboard_01",
bone = 18905,
coords = { x = 0.10, y = 0.02, z = 0.08 },
rotation = { x = -80.0, y = 0.0, z = 0.0 },
},
propTwo = {
model = "prop_pencil_01",
bone = 58866,
coords = { x = 0.12, y = 0.0, z = 0.001 },
rotation = { x = -150.0, y = 0.0, z = 0.0 },
},
}, function(cancelled)
if not cancelled then
-- Do Something If Action Wasn't Cancelled
else
-- Do Something If Action Was Cancelled
end
end)
So far I've got the C# code to this
Progress(new {
name = "unique_action_name",
duration = 1000,
label = "Doing Something",
useWhileDead = true,
canCancel = true,
controlDisables = new {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
},
animation = new {
animDict = "missheistdockssetup1clipboard@base",
anim = "base",
flags = 49,
},
prop = new {
model = "p_amb_clipboard_01",
bone = 18905,
coords = new { x = 0.10, y = 0.02, z = 0.08 },
rotation = new { x = -80.0, y = 0.0, z = 0.0 },
},
propTwo = new {
model = "prop_pencil_01",
bone = 58866,
coords = new { x = 0.12, y = 0.0, z = 0.001 },
rotation = new { x = -150.0, y = 0.0, z = 0.0 },
},
}, function(cancelled) { // < This part here is the question that rises for me, no clue how to call this in C#
if (!cancelled)
//Do Something If Action Wasn't Cancelled
else
// Do Something If Action Was Cancelled
});
Upvotes: 0
Views: 412
Reputation: 23
Solved it with help from the comments above, I really appreciate all of your help!
Progress(new
{
name = "unique_action_name",
duration = 1000,
label = "Doing Something",
useWhileDead = true,
canCancel = true,
controlDisables = new
{
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
},
animation = new
{
animDict = "missheistdockssetup1clipboard@base",
anim = "base",
flags = 49,
},
prop = new
{
model = "p_amb_clipboard_01",
bone = 18905,
coords = new { x = 0.10, y = 0.02, z = 0.08 },
rotation = new { x = -80.0, y = 0.0, z = 0.0 },
},
propTwo = new
{
model = "prop_pencil_01",
bone = 58866,
coords = new { x = 0.12, y = 0.0, z = 0.001 },
rotation = new { x = -150.0, y = 0.0, z = 0.0 },
},
}, new Action<bool>((isCanceled) =>
{
if (!isCanceled)
Debug.WriteLine("DONE");
else
Debug.WriteLine("CANCELED");
}));
Upvotes: 0