| Blockland Forums > Modification Help |
| "Unable to Find Object" |
| (1/1) |
| brickybob:
--- Code: ---function serverCMDfindit(%client, %target) { %noodles = findclientbyname(%target); %location = %noodles.player.getPosition(); talk(%location); } --- End code --- The code is supposed to find a client from the argument, store it in a local variable named noodles. Then get the position of the "noodles" client and store it in location. Then display globally in console chat where Mr.Noodles is. Also, can someone port this to client sided please? I don't know the client equivalent to serverCMD. |
| Slicksilver:
--- Quote from: brickybob on January 30, 2012, 11:56:29 PM --- --- Code: ---function serverCMDfindit(%client, %target) { %noodles = findclientbyname(%target); %location = %noodles.player.getPosition(); talk(%location); } --- End code --- --- End quote --- Well, that by the looks of it should work. Clientside stuff doesn't work quite the same though. I'm going to go ahead and tell you that getting positions clientside is impossible, there are hacky ways but those are reserved for mods that sink below the popular use line, if you get what I mean. Aside from that, a findPlayerByName function could be created using the following, and I believe Truce has some addon out that supports clientside /commands. --- Code: ---function findPlayerByName(%name) { for(%i=0; %i<serverConnection.getCount();%i++) { if(serverConnection.getObject(%i).getClassname() !$= "Player") continue; if(striPos(serverConnection.getObject(%i).getShapeName(),%name) >= 0) return serverConnection.getObject(%i); } return 0; } --- End code --- |
| CityRPG:
1. The function "getClientByName" does not exist client-side. And, to my knowledge, there is no way to tie a Player object to a client in the NewPlayerListGUI. forget you slick lol 2. There's no built-in way to capture slash commands with the client. You have to hack up the send chat message function. |
| jes00:
--- Quote from: CityRPG on January 31, 2012, 12:30:23 AM ---2. There's no built-in way to capture slash commands with the client. You have to hack up the send chat message function. --- End quote --- True, but there is an easy way to do it. --- Code: ---package myPackage { function NMH_Type::Send(%this) { %firstWord = getWord(%this.getValue(), 0); if(%firstWord $= "/findIt") { //Do whatever } Parent::Send(%this); } }; activatePackage(myPackage); --- End code --- |
| Slicksilver:
Hell, if you're going to do ^ at least make it adaptable. --- Quote from: jes00 on January 31, 2012, 06:46:00 AM --- --- Code: ---package clCmd { function NMH_Type::Send(%this) { %value = %this.getValue(); %firstLetter = getSubStr(%value, 0,1); if(%firstLetter $= "/") { %firstWord = getWord(%value,0); %func = getSubStr(%firstWord,1,strLen(%firstWord)-2); if(!isFunction(("clCmd" @ %func))) { Parent::Send(%this); return; } %start = "call((\"clCmd\" @ \"" @ %func @ "\")"; %varcount = getWordCount(%value)-1; for(%i = 0; %i < %varcount; %i++) { %string = %string @ ", \"" @ getWord(%value,%i+1) @ "\""; } eval(%start @ %string @ ");"); %this.setValue(""); } Parent::Send(%this); } }; activatePackage(clCmd); --- End code --- --- End quote --- Note: untested |
| Navigation |
| Message Index |