Author Topic: Code crashes blockland  (Read 868 times)

This little punk bit of code crashes blockland when used.

This is the whole thing
Code: [Select]
function serverCmdKick(%client, %playername)
{
        // The host kick works fine so I'm ignoring it
if(isHost(%client)) // Skip the crap below if host
{
serverCmdKick(%client, findclientbyname(%playername));
}
if(%client.isModerator || %client.isAdmin || %client.isSuperAdmin)
{
%player = findClientByName(%playername);
if(%player.isModerator || %player.isAdmin || %player.isSuperAdmin) // If the player is staff, don't kick
{return messageClient(%client,'',"\c6You can't kick that player!");}
serverCmdKick(%client, findclientbyname(%playername));
}
}

This part in specific is what I think is causing the problem, but why it is I don't know
Code: [Select]
if(%client.isModerator || %client.isAdmin || %client.isSuperAdmin) // if client is staff continue
{
%player = findClientByName(%playername);
if(%player.isModerator || %player.isAdmin || %player.isSuperAdmin) // If the player is staff, don't kick
{return messageClient(%client,'',"\c6You can't kick that player!");}
serverCmdKick(%client, findclientbyname(%playername));
}


You're calling serverCmdKick() within itself, thereby causing an infinite loop which crashes Blockland.

If you want to disconnect a player from the server, you can try using %client.delete("reason"); instead - I don't know what the native function is for actually kicking a player in Blockland or if there's a better way entirely but I can't check at the moment.

I also don't know if serverCmdKick() is already a default function in Blockland, but if it is then I don't think you should be overwriting it.

Ah, okay.

What if I did this?
Code: [Select]
package Pack
{

    function serverCmdKick(%client, %playername)
    {
        Parent::serverCmdKick(%client, findclientbyname(%playername));
    }

};

kicking using .delete(); is valid; if you put a string as a parameter, its shown to the player

eg %client.delete("Spamming"); will show the "You have been disconnected from the server" dialog box with "Spamming" underneath the first line.

and servercmdkick does exist.
your new code looks fine

are you sure serverCmdKick doesn't exist?

When I use the host kick
Code: [Select]
if(isHost(%client)) // Skip the crap below if host
{
serverCmdKick(%client, findclientbyname(%playername));
}

It kicks the player and puts in the chat
Player kicked Player (Id:55555)

it is a default function

you can probably scrap the permission checks and replace it with
Code: [Select]
if(%client.getBLID() != getNumKeyID()) and tell them that they aren't allowed to use it since otherwise unless isHost is a defined function it won't work

isHost() is a function I made to quickly check if a player is the host

isHost() is a function I made to quickly check if a player is the host
oh okay, just checking

you still only need 1 check to see if they're the host though

oh okay, just checking

you still only need 1 check to see if they're the host though
unless its a LAN server
but no one really cares about those

unless its a LAN server
but no one really cares about those
well we could have a 1000 player lan server
if we had 1000 players playing


Quote
you still only need 1 check to see if they're the host though
What do you mean I only need to check once?
I am only checking once.

well we could have a 1000 player lan server
if we had 1000 players playing
i dont think 32bit blockland can handle that