Closed sollaholla closed 8 years ago
The code seems right. Post your ScriptHookVDotNet-[date].log
Just solved this. Here's how...
So I looked at my log and I noticed that I was calling the BigMessageThread class before the game even loaded. Then I looked through some of the other threads here, and found an answer that someone said about using the Wait method to pause the script before the game loads.
Heres my log file:
[15:57:34] [ERROR] Failed to instantiate script 'TreasurMapGTAV' because constructor threw an exception:
System.InvalidOperationException: Illegal call to 'Script.Wait()' outside main loop!
at GTA.Script.Wait(Int32 ms)
at NativeUI.BigMessageHandler.Load()
at NativeUI.BigMessageHandler.ShowMissionPassedMessage(String msg, Int32 time)
at TreasurMapGTAV..ctor()
So then I said, "Okay I'll try to use the wait method while the game's loading.", and here's what I have now:
while (Game.IsLoading)
{
Wait(50);
return;
}
if (e.KeyCode == Keys.B)
{
if (!Game.IsLoading)
{
BigMessageThread.MessageInstance.ShowMissionPassedMessage("Treasure Map Successfully loaded!");
}
}
I don't know if this is the correct way to do it (I don't think I have to tell it to return if it's already "waiting"), but this is working. And dude I gotta say it looks really awesome, and just like the vanilla. If I wrote that code wrong please let me know I do really want to learn this, I would love to start developing stuff!
I also probably don't need that, "if (!Game.isLoading)"
You can't call Wait() in the constructor, if the game is still loading. So inside your while (Game.IsLoading) loop, remove the Wait();
Okay got it, thanks man. Also would it be legal to use a bool to call BigMessage inside of Tick, just once? Like:
PsuedoCode
bool didShowMessage = false;
private void TreasurMapGTAV_Tick(object sender, EventArgs e)
{
[Insert that while loop here]
if (!didShowMessage) {
[Call the BigMessage]
didShowMessage = true;
}
}
`
Yes, that's how I do it.
Alright, awesome! Case closed then, Thanks for this great addition to scripthook, and for being a big help!
Thank you for using NativeUI!
I'm fairly new to GTA scripting but I do have a good amount of training in C#. I've been trying to use this library (I'm currently making a mod), but I can't seem to get this to do anything... I'm not trying to actually show the message everytime I press 'b', I'm just test it out. Although nothing appears on screen. Maybe I read the documentation incorrectly. Hopefully you can help me out.
Here's a snippet:
Thanks in advance! :)