function serverCmdSetKing(%client, %name){ if(%client.isAdmin) { %target = findClientByName(%name); if(isObject(%target)) { messageall('', "\c6The king was killed and his place was taken."); %target.Isking = 1; //Now what would I do to set %target's team to team 3. } } else { messageClient(%client, '', "\c6You must be an admin to use this command."); }}
if(isObject(%target)) { CheckKing(%client); }
function CheckKing(%client){ for(%i=0;%i<clientGroup.GetCount();%i++) { %CurKing = clientgroup.getobject(%i); if(%CurKing.tdmTeam == 2) { %CurKing.setTeam(1); %client.setTeam(2); //add break; here } }}function serverCmdKing(%client, %name){ if(%client.isAdmin) { %target = findClientByName(%name); if(isObject(%target)) { CheckKing(%client); } } else { messageClient(%client, '', "\c6You must be an admin to use this command."); }}Doesn't seem to work. No console errors.
function CheckKing(%client){ for(%i=0;%i<clientGroup.GetCount();%i++) { %CurKing = clientgroup.getobject(%i); %client.setTeam(2); if(%CurKing.tdmTeam == 2) { %CurKing.setTeam(1); //add break; here } }}
"CheckKing(%client); "Should probably be"CheckKing(%target); "Also it wont work unless there's a king to begin with.Code: [Select]function CheckKing(%client){ for(%i=0;%i<clientGroup.GetCount();%i++) { %CurKing = clientgroup.getobject(%i); %client.setTeam(2); if(%CurKing.tdmTeam == 2) { %CurKing.setTeam(1); //add break; here } }}Try that.
Actually %client.setTeam(2); should be after the loop.
function CheckKing(%client){ for(%i=0;%i<clientGroup.GetCount();%i++) { %CurKing = clientgroup.getobject(%i); %client.setTeam(2); if(%CurKing.tdmTeam == 2 && %CurKing != %client) { %CurKing.setTeam(1); //add break; here } }}
Right. Might be better just toCode: [Select]function CheckKing(%client){ %client.setTeam(2); for(%i=0;%i<clientGroup.GetCount();%i++) { %CurKing = clientgroup.getobject(%i); if(%CurKing.tdmTeam == 2 && %CurKing != %client) { %CurKing.setTeam(1); //add break; here } }}
function CheckKing(%client){ %client.setTeam(2); for(%i=0;%i<clientGroup.GetCount();%i++) { %CurKing = clientgroup.getobject(%i); if(%CurKing.tdmTeam == 2 && %CurKing != %client) { %CurKing.setTeam(1); //add break; here } }}
It might be more helpful to not have the break statement in case they've used the teams menu to force more than one player as a 'King' that round.
function CheckKing(%client){ %client.setTeam(2); for(%i=0;%i<clientGroup.GetCount();%i++) { %CurKing = clientgroup.getobject(%i); if(%CurKing.tdmTeam == 2 && %CurKing != %client) { %CurKing.setTeam(1); //don't add break; here } }}