| Blockland Forums > Modification Help |
| Toggling A Mod |
| << < (5/7) > >> |
| jes00:
Whenever I push the keybind it turns it on then off a few milliseconds late : / |
| M:
connected. i am a gigantic friend Have fun with your getting banned from stuff, still, for using a stuffty mod that is coded badly, and whose very purpose annoys the forget out of many people. I've had people say that "it shows we care" when in fact it's automatic, thus showing that you don't care because you can't be bothered to type "Hi!" yourself (you lazy forget). When this is pointed out, I've then had those people say "NUH-UH IT SHOWS I CARE UR GAY" at which point I add them to my ever-growing list of people whose chat my client ignores (it's literally over three hundred people now) and permaban them if I can. So here's a couple of pointers: 1) Everybody hates these, don't make them 2) If you are going to make them at least write them yourself instead of copy-pasting the code from that horribly broken abusable one (oh wait you can't actually code so you'll just be typing the same code instead of copy-pasting it) 3) Since the keybind problem is something that you can learn from: --- Code: ---function thCIAAKeybind(%down) { if(%down) { // The key has been depressed // Do stuff for when it's pressed } else { // The key has been released // So it's turning on then off again because you're toggling it on depression and release of the key } } --- End code --- In conclusion: I hate you, please die. Good luck with learning to code better! |
| Headcrab Zombie:
--- Quote from: Red_Guy on September 05, 2011, 01:44:19 AM ---slightly simpler version. Also with formatting fixed. --- End quote --- While that is better, it's a rather odd formatting style, and inconsistent in a few places. Explaining the problem in just a little bit more detail (if you can't figure it out yourself) - the function is called both when you press the key, and when you release the key, and there's an argument passed to indicate whether you're pressing or releasing it. So like in the above post, you need to check the value of it. As for using this - please don't. It's fine as a learning exercise, but don't use it beyond one test, and make sure you're not in a server with people who get really annoyed by it. |
| Aide33:
--- Quote from: Aide33 on September 04, 2011, 10:01:34 PM --- --- Code: ---package AutoGreeter { function newChatHud_addLine(%text) { if($canGreet == 1) { //Called when any line of text is added to the chat box Parent::newChatHud_addLine(%text); //This will turn the "jes00 connected." into "jes00" %nameToGreet = strReplace(%text," connected.",""); //If the %nameToGreet variable is different to the original line greet them, //otherwise it's something else if(%nameToGreet !$= %text) { //Send a chat message saying hi to the player who joined (%nameToGreet) commandtoserver('messagesent',"Hi, " @ %nameToGreet); } } } }; activatePackage(AutoGreeter); function ToggleGreet() { if($canGreet == 1) { $canGreet = 0; clientCmdMessageBoxOK("Auto Greeter, by jes00","Auto Greeter is now: Off."); } else if($canGreet == 0) { $cangreet = 1; clientCmdMessageBoxOK("Auto Greeter, by jes00","Auto Greeter is now: On."); } } --- End code --- This should work I tested it and ironed out the bugs --- End quote --- Wow I retested and it breaks the chat when its off |
| adam savage:
--- Code: ---package AutoGreeter { function newChatHud_addLine(%text) if($Greeter::On == 1) { { //Called when any line of text is added to the chat box Parent::newChatHud_addLine(%text); //This will turn the "jes00 connected." into "jes00" %nameToGreet = strReplace(%text," connected.",""); //If the %nameToGreet variable is different to the original line greet them, //otherwise it's something else if(%nameToGreet !$= %text) { //Send a chat message saying hi to the player who joined (%nameToGreet) commandtoserver('messagesent',"Hi, " @ %nameToGreet); } } } }; activatePackage(AutoGreeter); function GreetToggle() { switch$($Greeter::On) { case "1": $Greeter:On = 0; echo("Greeter is now Off"); break; case "0": $Greeter::On = 1; echo("Greeter is now On"); break; } } --- End code --- |
| Navigation |
| Message Index |
| Next page |
| Previous page |