Author Topic: Ban command won't work  (Read 1270 times)

So I have this ban command

// in the original script i have stuff like admin checks and host checks
// but i didnt add them so it wouldnt be cluttered.
function serverCmdCustomBan(%client, %victimname, %time)
{

    echo("Banning...");
    %victim = findclientbyname(%victimName);

    %victim.isAdmin = "0";
    %victim.isSuperAdmin = "0";
    commandToClient(%victim,'SetAdminLevel',0); // this is so if the host bans a super admin it wont stop them
    
    commandToServer('ban', 0, %victim.bl_id, %time, "Custom Ban");

}
« Last Edit: July 22, 2016, 10:27:54 AM by KozzyMoto »

findclientbyname(%victim) should be findclientbyname(%victimname).

That was an accident.
The original code has  findClientByName(%victimName);

and btw it echos "Banning..."

Post the entire function as it is currently and don't leave anything out, BLF also has [ code ] [ /code ] tags available to make the code easier to read.

Code: [Select]
function serverCmdModBan(%client, %victimName, %time, %a, %b, %c, %d, %e, %f, %g, %h, %i, %j, %k, %l, %m)
{
echo("Banning...");
%victim = findclientbyname(%victimName);
if(!%client.isModerator && !%client.isAdmin && !%client.isSuperAdmin)
{
return null;
}
%victimBL_ID = %victim.bl_id;
%victimID = %victim.getId();
%reason = "\c2" @ "\"" @ %a @ %b @ %c @ %d @ %e @ %f @ %g @ %h @ %i @ %j @ %k @ %l @ %m @ "\"";
if(%time > 15){ return messageClient(%client,'',"\c6You cannot ban players for more than\c2 15      \c6minutes."); }
if(%victim.isModerator && !%client.isSuperAdmin){return messageClient(%client,'',"\c6You cannot ban \c4Moderators\c6!");}
if(%victim.isAdmin && !%victim.isSuperAdmin && !%client.isSuperAdmin){return messageClient(%client,'',"\c6You cannot ban \c1Admins\c6!");}
if(%victim.isSuperAdmin && !(isHost(%client))){return messageClient(%client,'',"\c6You cannot ban \c2Super Admins\c6!");}

commandToServer('ban', 0, %victimBL_ID, %time, "Banned");
}

%reason has some problems in it. also %victimID is never used

what's wrong with %reason?

Replace commandToServer() with serverCmdBan(%client, etc). Your function won't work properly for others.

what's wrong with %reason?
firstly, its never used. secondly, there seems to an extra " at two parts of it

firstly, its never used. secondly, there seems to an extra " at two parts of it
Using \" can escape quotes so you can display them in a string, this is so when he uses the %reason string it will appear like this: Someone has banned Crown for "this reason".

No. Replace the commandToServer with banBLID(%BL_ID, %time, %reason); because moderators can't use /ban.

Also. Your first connector in %reason is entirely useless. You should also be using SPC for a connector. Otherwise if someone does /modBan Person 5 Being super rude, the reason will be Beingsuperrude.
You should also use trim(%reason); to remove any spaces after it.
You should also be using %reason instead of "Banned", otherwise you're not actually ever telling anyone the reason...

Also, don't mean to rain on your parade, but https://forum.blockland.us/index.php?topic=298482.0

I put it as "Banned" until I could get the %reason to work.
Also I don't want to download the moderator thing, because I want to make my own.

Using \" can escape quotes so you can display them in a string, this is so when he uses the %reason string it will appear like this: Someone has banned Crown for "this reason".
well the more you know

Most of your if statements will cause problems. You can still ban regular admins as a moderator.

return null; replace that with just return;, torque doesn't need a "null" return like the other languages

%reason should work but strip out all the \" and the colors
Doing server side stuff, instead of commandToServer('Blah', ...) it's just serverCmdBlah(%client, ...)
Replace the commandToServer with banBLID(%BL_ID, %time, %reason); because moderators can't use /ban.



Make sure you read everyone's posts so we can see if you are trying to work on this instead of skipping a few solutions