| Blockland Forums > Modification Help |
| Client Sided Slash Command |
| << < (5/6) > >> |
| Truce:
--- Quote from: infiniteLoop on September 14, 2011, 07:41:11 AM ---I don't know which way you are trying to do this but look below: You type /j and it'll perform a jump for you, I could get more complex with it but I'm just keeping it simple. This way evaluates code so like if you typed, /moveForward(1); in the chat, it'll move forward for you. --- End quote --- Can we not overwrite packages for support code? The way the code I posted works is that it allows scripters to implement functions beginning with "clCmd" that are triggered when the user types in their chat. So for example, if I created the function clCmdQuit, it would activate when I typed /quit on any server. Arguments are passed as you would expect if you have created "serverCmd" functions before. --- Code: ---// Called when I type /randomnum 1 6 // Above example shows a random number between 1 and 6 function clCmdRandomNum(%min,%max) { commandToServer('messageSent',"Random number: " @ getRandom(%min,%max)); } // Paste the clCmd package below here --- End code --- |
| infiniteLoop:
--- Quote from: Truce on September 14, 2011, 03:37:51 PM ---Can we not overwrite packages for support code? The way the code I posted works is that it allows scripters to implement functions beginning with "clCmd" that are triggered when the user types in their chat. So for example, if I created the function clCmdQuit, it would activate when I typed /quit on any server. Arguments are passed as you would expect if you have created "serverCmd" functions before. --- Code: ---// Called when I type /randomnum 1 6 // Above example shows a random number between 1 and 6 function clCmdRandomNum(%min,%max) { commandToServer('messageSent',"Random number: " @ getRandom(%min,%max)); } // Paste the clCmd package below here --- End code --- --- End quote --- Oh, thought that it was just his package name, not something of yours. |
| phflack:
--- Quote from: Truce on September 13, 2011, 11:29:27 PM ---The code I posted uses /, not @, and it does not send the message to the server either. --- End quote --- oh, nice :D! |
| jes00:
--- Quote from: Truce on September 14, 2011, 03:37:51 PM ---Can we not overwrite packages for support code? The way the code I posted works is that it allows scripters to implement functions beginning with "clCmd" that are triggered when the user types in their chat. So for example, if I created the function clCmdQuit, it would activate when I typed /quit on any server. Arguments are passed as you would expect if you have created "serverCmd" functions before. --- Code: ---// Called when I type /randomnum 1 6 // Above example shows a random number between 1 and 6 function clCmdRandomNum(%min,%max) { commandToServer('messageSent',"Random number: " @ getRandom(%min,%max)); } // Paste the clCmd package below here --- End code --- --- End quote --- Like this? --- Code: ---function clCmdToggleMod(%client) { if($Toggle == On) { $Toggle = Off; clientCmdMessageBoxOK("jes00's Mod","Mod is now:" @ $isOn"); } else if($Toggle == Off) { $Toggle = On; clientCmdMessageBoxOK("jes00's Mod","Mod is now:" @ $isOn"); } package clCmd { function NMH_Type::send(%this) { %msg = %this.getValue(); %wrd = firstWord(%msg); %cmd = "clCmd" @ getSubStr(%wrd,1,strLen(%wrd)); if(getSubStr(%msg,0,1) $= "/" && isFunction(%cmd)) { %eval = "call(%cmd,"; %cnt = getWordCount(%msg); for(%i = 1; %i < %cnt; %i++) %eval = %eval @ "\"" @ getWord(%msg,%i) @ "\","; eval(getSubStr(%eval,0,strLen(%eval) - 1) @ ");"); %this.setValue(""); } Parent::send(%this); } }; activatePackage(clCmd); --- End code --- |
| Headcrab Zombie:
--- Quote from: jes00 on September 15, 2011, 07:29:52 AM ---function clCmdToggleMod(%client) { if($Toggle == true) { $Toggle = false; clientCmdMessageBoxOK("jes00's Mod","Mod is now off"); } else { $Toggle = true; clientCmdMessageBoxOK("jes00's Mod","Mod is now on"); } } --- End quote --- Bolded what I fixed. And god damn man, work on your formatting before you make much else |
| Navigation |
| Message Index |
| Next page |
| Previous page |