| 07-03-2008, 02:12 PM | #1 |
Do I have to explain what SimError is? I hope not. vJass always help to make these functions less of a mess, using the same sound instead of creating and destroying one is always troublesome JASS:library SimError initializer init //************************************************************************************************** //* //* SimError //* //* Mimic an interface error message //* call SimError(ForPlayer, msg) //* ForPlayer : The player to show the error //* msg : The error //* //* To implement this function, copy this trigger and paste it in your map. //* Unless of course you are actually reading the library from wc3c's scripts section, then just //* paste the contents into some custom text trigger in your map. //* //************************************************************************************************** //================================================================================================== globals private sound error endglobals //==================================================================================================== function SimError takes player ForPlayer, string msg returns nothing set msg="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+msg+"|r" if (GetLocalPlayer() == ForPlayer) then call ClearTextMessages() call DisplayTimedTextToPlayer( ForPlayer, 0.52, 0.96, 2.00, msg ) call StartSound( error ) endif endfunction private function init takes nothing returns nothing set error=CreateSoundFromLabel("InterfaceError",false,false,false,10,10) //call StartSound( error ) //apparently the bug in which you play a sound for the first time //and it doesn't work is not there anymore in patch 1.22 endfunction endlibrary |
| 07-03-2008, 02:23 PM | #2 |
This displays the error lower down, closer to where it should be: call DisplayTimedTextToPlayer(ForPlayer, 0.51, 0.96, 2.00, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"+msg) |
| 07-03-2008, 02:42 PM | #3 |
ok then. I just hope there aren't side effects... Edit: Just tested and it isn't resolution independent, so I won't use it. |
| 07-03-2008, 02:47 PM | #4 |
The 0.96 instead of -1.00 in y is fairly essential for it to work. |
| 07-03-2008, 02:54 PM | #5 |
ok it works now. |
| 07-03-2008, 03:24 PM | #6 | |
Quote:
I tested this awhile back and it appears that as long as the sound is created in a thread before you use it, you don't have to play it the first time. You only have to play it before hand if you create it in the same thread you use it (waits start a new thread). |
| 07-03-2008, 04:13 PM | #7 |
I am not sure, but isn't GetlocalPlayer() not safe? I remember that Purgeandfire has made a safe function for that... Or doesn't it matter? |
| 07-03-2008, 04:21 PM | #8 |
GetLocalPlayer is safe if you use it correctly. |
| 07-03-2008, 05:10 PM | #9 | |
Quote:
So is nuclear power plant. (joke) |
| 07-04-2008, 01:23 AM | #10 |
I was thinking, how about recoding simerror to use text tags and move them locally for each player depending on their camera view to simulate an error This way it wont screw up text messages that are displayed before the error message, and you could make it "fully" accurate EDIT: NVM i realised this most likely might not work because of camera angles |
| 01-20-2009, 09:42 PM | #11 |
If you using shif method, use it correctly. http://www.wc3campaigns.net/showthread.php?t=96955 First param is 0.51 |
| 01-20-2009, 11:08 PM | #12 |
Sorry, but I find myself incredibly unable to care about that. |
| 07-28-2011, 06:35 AM | #13 |
There are cases where users are really stupid and want to do something wrong in rapid succession, so you need to play lots of error sounds to tell them not to. Since this only uses one sound, it fails if you try to use it within the same time frame. I'd suggest either having it use Rising_Dusk's SoundUtils, or implementing something like: JASS:library SimError initializer init //************************************************************************************************** //* //* SimError - updated to allow multiple sound playings within the time allotted. //* //* Mimic an interface error message //* call SimError(ForPlayer, msg) //* ForPlayer : The player to show the error //* msg : The error //* //* To implement this function, copy this trigger and paste it in your map. //* Unless of course you are actually reading the library from wc3c's scripts section, then just //* paste the contents into some custom text trigger in your map. //* //************************************************************************************************** //================================================================================================== globals private sound array error private constant integer MAX_SOUNDS = 4 private integer soundN = 0 endglobals //==================================================================================================== function SimError takes player ForPlayer, string msg returns nothing set msg="\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n|cffffcc00"+msg+"|r" if (GetLocalPlayer() == ForPlayer) then call ClearTextMessages() call DisplayTimedTextToPlayer( ForPlayer, 0.52, 0.96, 2.00, msg ) call StartSound( error[soundN] ) endif set soundN=soundN+1 if(soundN==MAX_SOUNDS)then set soundN=0 endif endfunction private function init takes nothing returns nothing local integer i=0 loop exitwhen i==MAX_SOUNDS set error[i]=CreateSoundFromLabel("InterfaceError",false,false,false,10,10) set i=i+1 endloop endfunction endlibrary |
