SetMaxPlayer In World

Started by Street Killer, May 11, 2015, 02:52 PM

Previous topic - Next topic

Street Killer

I Need Some Help About SetMaxPlayer In Worlds... How To Set MaxPlayers In Different World??
Like World 1 MaxPlayers 50 World 2 MaxPlayers 35... :'(

Stormeus

This should be trivial to script using tables really.

.

#2
Yours truly 8)

// Yay, pretty hard-coded values. Don't you just luv them <3
local g__WorldCounters  = [0, 0, 0, 0, 0, 0, 0, 0]; // 8 -> World counters
local g__WorldLimits    = [7, 5, 3, 8, 9, 5, 2, 4]; // 8 -> World limiters

// Changing player worlds should go strictly through this wrapper from now on
function SetPlayerWorld(player, world)
{
    // Let's make sure we don't end up in space
    if (world >= g__WorldCounters.len())
    {
        print("World doesn't exist n00b!");
    }
    // Is there room for one more?
    else if (g__WorldCounters[world] >= g__WorldLimits[world])
    {
        print("World is full you n00b!");
    }
    // Deez nuts!
    else
    {
        --g__WorldCounters[player.World]; // Take the old one out
        // NOTE: We haven't checked the boundaries of the existing world!!!
        ++g__WorldCounters[world]; // Add the new one in

        player.World = world; // Finally, we're out of that dump!
       
        return true; // Let the neighbours know we're coming
    }
    // By not returning anything, Squirrel defaults to null
    //  which can be equivalent to false anyway.
}
.

Street Killer

Thnks @Stormeus Sir!! And @S.L.C !! :-)

FarisDon

What is actually related with player.world will anyone describe it?

DizzasTeR

#5
Quote from: FarisDon on May 11, 2015, 04:24 PMWhat is actually related with player.world will anyone describe it?


Just another really useful feature if you want to handle some actions for specific players at at the same place where two events happen for other actions as well.

For instance if i want to have a fight at Mansion but there is a Minigame going at mansion, i can easily set the world of players who want to fight to world 2 and we won't see the guys in world 1.

.

@Doom_Killer Don't! Just don't! You know better why.
.

Street Killer

Sorry For Late Reply S.L.C How To Count Them In A List I Set The Limit MaxPlayers 10... I Want To Count MaxPlayers
Like:- (0/10) And One Player Join Them He Say (1/10)...

jayant

else if ( cmd == "players" )
{
               
local plr, buffer = "", MAX_PLAYERS = GetMaxPlayers();
for( local i=0; i < MAX_PLAYERS; ++i )
{
    plr = FindPlayer( i );
if ( plr ) buffer = buffer + " " + plr.Name + "[" + plr.ID + "]";
    }
if ( buffer != "" ) Message(  "Online Players: " + strip(buffer) );
Message( "Total players: " + " - " + GetPlayers() + "/ " + GetMaxPlayers() );
}

This command counts player in World 1.
You can make a counter onScriptLoad() and use it in your script...Wait for good examples.

.

#9
Quote from: Street Killer on May 12, 2015, 09:14 AMSorry For Late Reply S.L.C How To Count Them In A List I Set The Limit MaxPlayers 10... I Want To Count MaxPlayers
Like:- (0/10) And One Player Join Them He Say (1/10)...

This should do the job:
print( "Number of players in world 2 " + g__WorldCounters[2] );
print( "Allowed players in world 2" + g__WorldLimits[2] );

print("Current " + g__WorldCounters[2] + " / Allowed " + g__WorldLimits[2]);
.

Street Killer

@S.L.C I Had To Try This But It's Not Working!! He Say (0/10) Only... Nothing InCrease... I'm Using Seby's Custem Menu

.

Is there anyone in that world? Have you used the function I gave you above to change the worlds? Make sure you have this in your onPlayerJoin() function:
function onPlayerJoin(player)
{
    // Other code...
    ++g__WorldCounters[player.World];
    // Other code...
}
.

Street Killer

Thnks @S.L.C Now It's Working Fine :)