| Blockland Forums > Modification Help |
| This server command will not do ANYTHING. |
| (1/1) |
| TheBlackParrot:
So I'm trying to re-do my old add-on v18 broke, and I'm trying to re-create the color change command. --- Code: ---$SIAversion = "0.2"; $SIAbuild = "6-6"; $line1c = "FF3344"; $line2c = "FFEE00"; $line3c = "44CC77"; $line4c = "3388FF"; messageAll('',"Executed Server Info Announcer 2 version " @ $SIAversion @ " (build " @ $SIAbuild @ ")"); function getHostsName() { $hostsname = $pref::Player::NetName; } getHostsName(); function DoSIAAnnounce(%client) { $bricks = $Server::BrickCount; $players = $Server::PlayerCount @ "/" @ $Pref::Server::MaxPlayers; for(%i = 0; %i < ClientGroup.getCount(); %i++) { %cl = ClientGroup.getObject(%i); %cl.perce = %cl.brickGroup.getCount()/$Server::BrickCount*100; %cl.perce = mFloatLength(%cl.perce,1); messageClient(%cl,"","<color:" @ $line1c @ "> >> " @ $hostsname @ "'s " @ $Server::Name); messageClient(%cl,"","<color:" @ $line2c @ "> >> There are " @ $bricks @ " bricks in the server, " @ %cl.perce @ "% of which are yours."); messageClient(%cl,"","<color:" @ $line3c @ "> >> There are " @ $players @ " players in the server."); messageClient(%cl,"","<color:" @ $line4c @ "> >> You have a " @ %cl.getPing() @ " ms. delay with the server."); } } -----> function servercmdSetSIAColor(%client,%servername,%brickcount,%playercount,%playerlag) { if(%client.isHost) { $line1c = %servername; $line2c = %brickcount; $line3c = %playercount; $line4c = %playerlag; messageAll('',"<color:00ffff>" @ $hostsname @ " has changed the announcer colors to " @ %servername @ ", " @ %brickcount @ ", " @ %playercount @ ", and " @ %playerlag @ "."); } } --- End code --- And it does absolutely nothing. |
| Destiny/Zack0Wack0:
1. %client.isHost is undefined. You need a package that sets it when the player connects. <- problem 2. You're using global variables when you should be using local variables (%) <- advice |
| Truce:
--- Quote from: Destiny/Zack0Wack0 on January 10, 2011, 04:28:51 AM ---1. %client.isHost is undefined. You need a package that sets it when the player connects. <- problem --- End quote --- --- Quote from: Truce on December 25, 2010, 12:18:29 AM ---Paste this at the bottom of your code / in another file and exec it to use .isHost: --- Code: ---package isHost { function GameConnection::autoAdminCheck(%this) { %this.isHost = (%this.isLocalConnection() || %this.bl_id == getNumKeyID()); return Parent::autoAdminCheck(%this); } }; activatePackage(isHost); --- End code --- --- End quote --- --- Quote from: Destiny/Zack0Wack0 on January 10, 2011, 04:28:51 AM ---2. You're using global variables when you should be using local variables (%) <- advice --- End quote --- Yeah, you'll (OP, not Dest) make this transition pretty quickly when you start coding more. |
| TheBlackParrot:
Thanks, this fixed it. |
| Navigation |
| Message Index |