| 02-11-2008, 07:38 PM | #1 |
Hey I have some functions that seem to be malfunctioning. There is also one that I'm not sure if it contains a leak or not. 1. Not a function but at the end of the game the final score of each player stays 0( score all the way to the right ) even though they have obtained resources. 2. Someone with a bad computer was complaining about really bad lag, and my map is only 42kbs. So maybe a leak, I couldn't find one but please if you find one tell me. JASS:function Set_Spacebar takes nothing returns nothing //Locals local group g = CreateGroup() local integer n = 0 local unit u = null local real x = 0. local real y = 0. loop exitwhen n > 11 call GroupEnumUnitsOfPlayer(g,Player(n),null) set u = FirstOfGroup(g) set x = GetUnitX(u) set y = GetUnitY(u) if GetLocalPlayer() == Player(n) then call SetCameraQuickPosition(x, y) endif call GroupClear(g) set n = n + 1 endloop set u = null call DestroyGroup(g) endfunction //=========================================================================== function InitTrig_Spacebar takes nothing returns nothing set gg_trg_Spacebar = CreateTrigger( ) call TriggerRegisterTimerEvent( gg_trg_Spacebar, 0.01, true ) call TriggerAddAction( gg_trg_Spacebar, function Set_Spacebar ) endfunction My next one is about weather, I have a function that creates weather for the local player that types the command. Weathers are stored in a variable and I want it to always delete the last weather effect created, so no stacking of weathers. This isn't doing that and it is only allowing each to be used once in the game total. JASS:function Weather takes nothing returns nothing local string s = StringCase(GetEventPlayerChatString(), false) if(GetLocalPlayer() == GetTriggerPlayer()) then call RemoveWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())]) endif //Decides which weather if(s == "-rain") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'RAhr') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-bubbles") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'MEds') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-blue fog") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'FDbh') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-green fog") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'FDgh') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-red fog") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'FDrh') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-snow") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'SNhs') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-wind") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'WNcw') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-sunny") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'LRaa') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif endif endfunction //=========================================================================== function InitTrig_Weather takes nothing returns nothing local integer a = 0 local integer b = 11 set gg_trg_Weather = CreateTrigger( ) loop call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-rain", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-bubbles", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-blue fog", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-green fog", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-red fog", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-snow", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-wind", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-sunny", true ) call TriggerRegisterPlayerChatEvent( gg_trg_Weather, Player(a), "-no weather", true ) set a = a+1 exitwhen a>b endloop call TriggerAddAction( gg_trg_Weather, function Weather ) endfunction My last function is a name changer/name color changer/ custom color name changer(they have to enter the hexadecimals Ex: -custom color 336699) None of them seem to be working. JASS:function check1 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "a") endfunction function check2 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "b") endfunction function check3 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "c") endfunction function check4 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "d") endfunction function check5 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "e") endfunction function check6 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "f") endfunction function check7 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "0") endfunction function check8 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "1") endfunction function check9 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "2") endfunction function check10 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "3") endfunction function check11 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "4") endfunction function check12 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "5") endfunction function check13 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "6") endfunction function check14 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "7") endfunction function check15 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "8") endfunction function check16 takes string s, integer a, integer b returns boolean return(SubString(s, a, b) == "9") endfunction function check17 takes string s, integer a, integer b returns boolean return (check1(s,a,b) or check2(s,a,b) or check3(s,a,b) or check4(s,a,b) or check5(s,a,b) or check6(s,a,b) or check7(s,a,b) or check8(s,a,b) or check9(s,a,b) or check10(s,a,b) or check11(s,a,b) or check12(s,a,b) or check13(s,a,b) or check14(s,a,b) or check15(s,a,b) or check16(s,a,b)) endfunction function NameChange takes nothing returns nothing local integer a = 0 local string s = StringCase(GetEventPlayerChatString(), false) //Changes name if(SubString(s, 0, 6) == "-name ") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then if(StringLength(GetEventPlayerChatString()) > 21) then call SetPlayerName(GetTriggerPlayer(), SubString(GetEventPlayerChatString(), 6, 21)) else call SetPlayerName(GetTriggerPlayer(), SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString()))) endif endif endif set a = a + 1 exitwhen a>11 endloop set udg_STRNames[GetPlayerId(GetTriggerPlayer())] = SubString(GetEventPlayerChatString(), 6, 21) //Custom color elseif(SubString(s, 0, 14) == "-custom color ") then set a = 0 if( check17(s, 14, 15) and check17(s, 15, 16) and check17(s, 16, 17) and check17(s, 17, 18) and check17(s, 18, 19) and check17(s, 19, 20)) then loop if(udg_BLNChat[a] == true) then if(StringLength(s) == 20) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff" + ( SubString(s, 14, 20) + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) ) endif endif endif set a = a + 1 exitwhen a>11 endloop endif //Regular colors elseif(s == "-color red") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFF0000" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color blue") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff0000FF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color teal") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff00FFFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color purple") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff660099" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color yellow") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFFFF00" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color orange") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFF6600" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color green") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff00FF00" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color pink") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFF3399" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color gray") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff999999" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color light blue") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff99CCFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color lightblue") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff99CCFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color dark green") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff003333" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color darkgreen") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff003333" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color brown") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff330000" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color white") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFFFFFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(s == "-color black") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff000000" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop endif endfunction //=========================================================================== function InitTrig_Name_Change takes nothing returns nothing local integer a = 0 set gg_trg_Name_Change = CreateTrigger( ) loop call TriggerRegisterPlayerChatEvent( gg_trg_Name_Change, Player(a), "", true ) set a = a + 1 exitwhen a>11 endloop call TriggerAddAction( gg_trg_Name_Change, function NameChange ) endfunction |
| 02-11-2008, 07:52 PM | #2 |
1) No idea. 2) Group creation and enuming are expensive operations. Doing them 1200 times per second will cause lag on slow computers. I'm sure there's a better way of doing what you want to do. |
| 02-11-2008, 09:13 PM | #3 |
Regarding your first function: It seems like you're trying to force players to look at 1 of their units all the time. Wouldn't it be better to just store that unit in a variable? You wouldn't have to use the GroupEnumUnit at all then. I'd also suggest that you change the interval to something less high. You can use 0.04 or 0.035 as a period instead. call TriggerRegisterTimerEvent( gg_trg_Spacebar, 0.04, true ) Regarding the second one: I don't really know, but what will happen if you Create the effect only for the local player? I mean, when you destroy the effect, it seems to me that you do it only for the local player. JASS:if(GetLocalPlayer() == GetTriggerPlayer()) then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'RAhr') call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif Regarding the last one: Woah, that's a LOT of code. I hope you find a way to make that more compact/optimized. I fail to see why you use GetLocalPlayer() here. |
| 02-11-2008, 09:23 PM | #4 | |
Quote:
Group creating involves handle allocation, that is extremely slow. Group enum is slow only if you use a null boolexpr; maybe it forces WC3 to allocate new memory because of the "null leak." Conclusion: Use a global group, don't create one each iteration. Put a "returns true" boolexpr on the enum. Now it should run without lagging... although the function seems wasteful either way. |
| 02-12-2008, 12:11 AM | #5 |
ok, I will probably just delete the first function then. But any idea what happens to be wrong with the other two? Oh and someone asked why I'm using GetLocalPlayer() on them. I'm using GetLocalPlayer so that they only create the weather effect for themselves and for the last trigger I use it so that it can be combined with my -hide chat/enable chat. Oh also any idea why the final score at the end stays at 0, when the resources are more than 0. |
| 02-12-2008, 05:57 AM | #6 |
The way you create the weather effects is done properly; the way you destroy them is not. You don't need GetLocalPlayer() if-block there as it will cause desyncs. JASS://Change this: if(GetLocalPlayer() == GetTriggerPlayer()) then call RemoveWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())]) endif //To this: call RemoveWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())]) JASS:elseif(SubString(s, 0, 14) == "-custom color ") then call SetPlayerName(GetTriggerPlayer(), ("|cff" + (SubString(s, 14, 20) + udg_STRNames[GetPlayerId(GetTriggerPlayer())]))) JASS:function VerifyColorCode takes string Code returns boolean local integer Length = StringLength(Code) local integer I = -1 local string S if Length != 6 then return false else loop set I = I+1 exitwhen I > 5 set S = SubString(Code, I, I+1) loop exitwhen (S == "0") //Just a different method than having a whole string of booleans exitwhen (S == "1") exitwhen (S == "2") exitwhen (S == "3") exitwhen (S == "4") exitwhen (S == "5") exitwhen (S == "6") exitwhen (S == "7") exitwhen (S == "8") exitwhen (S == "9") exitwhen (S == "a") exitwhen (S == "b") exitwhen (S == "c") exitwhen (S == "d") exitwhen (S == "e") exitwhen (S == "f") return false endloop endloop endif return true endfunction //Later in your code, in that elseif elseif(SubString(s, 0, 14) == "-custom color ") then if VerifyColorCode(SubString(s, 14, 20) then call SetPlayerName(GetTriggerPlayer(), ("|cff" + (SubString(s, 14, 20) + udg_STRNames[GetPlayerId(GetTriggerPlayer())]))) endif |
| 02-12-2008, 07:23 PM | #7 |
Wow thank you pyro for helping me out! Reason why I'm setting names locally: In my block chat script it blocks all the player names locally, for the player who wished to block the chat. Now in this script it checks the boolean variable and if it chat is allowed it will change the name of the player to what he wants it to be for a local player. Since name change is normally global it would mess up the blocked chat since the local name change would be overwritten. The trigger worked before, but then I had done something to it. So now the trigger doesn't work; any idea what the problem may be. I updated it with pyrogasm's help. JASS:function VerifyColorCode takes string Code returns boolean local integer Length = StringLength(Code) local integer I = -1 local string S if Length != 6 then return false else loop set I = I+1 exitwhen I < 5 set S = SubString(Code, I, I+1) loop exitwhen (S == "0") exitwhen (S == "1") exitwhen (S == "2") exitwhen (S == "3") exitwhen (S == "4") exitwhen (S == "5") exitwhen (S == "6") exitwhen (S == "7") exitwhen (S == "8") exitwhen (S == "9") exitwhen (S == "a") exitwhen (S == "b") exitwhen (S == "c") exitwhen (S == "d") exitwhen (S == "e") exitwhen (S == "f") exitwhen (S == "A") exitwhen (S == "B") exitwhen (S == "C") exitwhen (S == "D") exitwhen (S == "E") exitwhen (S == "F") return false endloop endloop endif return true endfunction function NameChange takes nothing returns nothing local integer a = 0 //Changes name if(SubString(GetEventPlayerChatString(), 0, 6) == "-name ") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then if(StringLength(GetEventPlayerChatString()) > 21) then call SetPlayerName(GetTriggerPlayer(), SubString(GetEventPlayerChatString(), 6, 21)) else call SetPlayerName(GetTriggerPlayer(), SubString(GetEventPlayerChatString(), 6, StringLength(GetEventPlayerChatString()))) endif endif endif set a = a + 1 exitwhen a>11 endloop set udg_STRNames[GetPlayerId(GetTriggerPlayer())] = SubString(GetEventPlayerChatString(), 6, 21) //Custom color elseif(SubString(GetEventPlayerChatString(), 0, 14) == "-custom color ") then if(VerifyColorCode(SubString(GetEventPlayerChatString(), 14, 20))) then loop if(udg_BLNChat[a] == true) then if(StringLength(GetEventPlayerChatString()) == 20) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff" + ( SubString(GetEventPlayerChatString(), 14, 20) + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) ) endif endif endif set a = a + 1 exitwhen a>11 endloop endif //Regular colors elseif(GetEventPlayerChatString() == "-color red") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFF0000" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color blue") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff0000FF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color teal") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff00FFFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color purple") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff660099" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color yellow") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFFFF00" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color orange") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFF6600" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color green") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff00FF00" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color pink") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFF3399" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color gray") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff999999" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color light blue") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff99CCFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color lightblue") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff99CCFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color dark green") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff003333" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color darkgreen") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff003333" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color brown") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff330000" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color white") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cffFFFFFF" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop elseif(GetEventPlayerChatString() == "-color black") then loop if(udg_BLNChat[a] == true) then if(GetLocalPlayer() == Player(a)) then call SetPlayerName( GetTriggerPlayer(), ( "|cff000000" + udg_STRNames[GetPlayerId(GetTriggerPlayer())] ) ) endif endif set a = a + 1 exitwhen a>11 endloop endif endfunction //=========================================================================== function InitTrig_Name_Change takes nothing returns nothing local integer a = 0 set gg_trg_Name_Change = CreateTrigger( ) loop call TriggerRegisterPlayerChatEvent( gg_trg_Name_Change, Player(a), "", true ) set a = a + 1 exitwhen a>11 endloop call TriggerAddAction( gg_trg_Name_Change, function NameChange ) endfunction |
| 02-12-2008, 08:13 PM | #8 |
i personally i can see 1 obvious error. it's this line: exitwhen I < 5 you init I with -1 so the loop won't be executed at all. I'll take a closer look and edit this post if i find something else. ---Edit--- 1 Question, why do you local player for changing the name? |
| 02-12-2008, 08:40 PM | #9 |
I have repeated the answer to that many times. It is part of my system that blocks chat. Each player can type -enable chat/disable chat. When they type -disable chat it sets a variable array and then it sets the names of each player for the triggering player locally. The name is set to a bunch of spaces so each person has too big of a name for anything to appear. That blocks the chat, now if you were to use this trigger it would write over the name and then chat would not be blocked. In order to keep chat blocked for the players that have it blocked I have to loop through and check if the player has chat blocked and then if they don't it sets the name of the triggering player locally so that there new name doesn't appear to the players that blocked chat. *****Nevermind found out what I did wrong***** |
| 02-13-2008, 03:52 AM | #10 |
Whoops... I mean to put >, not < ![]() |
| 02-15-2008, 08:33 PM | #11 |
So basiclly in my weather command people are supposed to be able to have their own weather locally. So that when they type -rain, the rain weather effect appears for them. Also when they type a weather effect it should delete the last weather effect that was created for them. I have a variable for it all, but for some reason it's deleting all the weather effects instead of just one player's. Any ideas? JASS:function Weather takes nothing returns nothing local string s = StringCase(GetEventPlayerChatString(), false) call RemoveWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())]) //Decides which weather if(s == "-rain") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'RAhr') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-bubbles") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'MEds') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-blue fog") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'FDbh') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-green fog") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'FDgh') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-red fog") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'FDrh') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-snow") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'SNhs') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-wind") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'WNcw') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif elseif(s == "-sunny") then set udg_WEWeather[GetPlayerId(GetTriggerPlayer())] = AddWeatherEffect(GetWorldBounds(), 'LRaa') if(GetLocalPlayer() == GetTriggerPlayer()) then call EnableWeatherEffect(udg_WEWeather[GetPlayerId(GetTriggerPlayer())], true) endif endif endfunction |
| 02-15-2008, 10:48 PM | #12 |
Well, you can reduce the amount of lines of code in that function by a lot by simplifying your elseifs: JASS:function Weather takes nothing returns nothing local string s = StringCase(GetEventPlayerChatString(), false) local integer WEId = 0 // local integer Index = GetPlayerId(GetTriggerPlayer()) if udg_WEWeather[Index] != null then //So you don't perform operations on uninitialized variables. call RemoveWeatherEffect(udg_WEWeather[Index]) endif //Decides which weather if (s == "-rain") then set WEId = 'RAhr' elseif (s == "-bubbles") then set WEId = 'MEds' elseif (s == "-blue fog") then set WEId = 'FDbh' elseif (s == "-green fog") then set WEId = 'FDgh' elseif (s == "-red fog") then set WEId = 'FDrh' elseif (s == "-snow") then set WEId = 'SNhs' elseif (s == "-wind") then set WEId = 'WNcw' elseif (s == "-sunny") then set WEId = 'LRaa' endif set udg_WEWeather[Index] = AddWeatherEffect(bj_mapInitialPlayableArea, WEId) //I've been told GetWorldBounds is bad and can return a different rect on different calls if GetLocalPlayer = GetTriggerPlayer() then call EnableWeatherEffect(udg_WEWeather[Index], true) else //To be honest, I don't think you need the Else call EnableWeatherEffect(udg_WEWeather[Index], false) endif endfunction |
| 02-15-2008, 11:02 PM | #13 |
I love it when you clean my script :P, just wish I knew what the problem was. Is it possible for weather effects to be stored in arrays, I'm nto sure if thats the problem or not :/. |
| 02-15-2008, 11:46 PM | #14 |
I don't see why you wouldn't be able to have arrays of weather effects... that new code doesn't work? |
| 02-16-2008, 12:35 AM | #15 |
Oh I didn't test it out yet, because I've been trying to figure out what's wrong with this. I also thought it wouldn't fix it because you said you cleaned it up a bit. JASS:set udg_WEWeather[Index] = AddWeatherEffect(bj_mapInitialPlayableArea, WEId) It says syntax error, but I checked it over so many times and can't see whats wrong with it. It looks perfectly fine to me, I even tried replacing the values in there with other things and it keeps giving me a syntax error. I'm using Newgen WE. |
