DRW Posted December 5, 2017 Share Posted December 5, 2017 So, I want to let some players enter the server despite it being full. So if there's 48/48 players, set it to 49 max players so the player with a specific serial can enter. Is it possible? I know I can use setMaxPlayers and the "onPlayerConnect" event, but it seems like onPlayerConnect gets cancelled before the max player count updates. Is there any way or workaround to that? Link to comment
Moderators IIYAMA Posted December 5, 2017 Moderators Share Posted December 5, 2017 How about you set it at 49 players and add in the description that it is for 48 players only? The only way to do this, is by using a second server which will redirect you to the main server. Link to comment
DREFTHUN Posted December 5, 2017 Share Posted December 5, 2017 (edited) MaxPlayers = 48 allowedSerials = { [""]=true, } function playerJoinKick() serial = getPlayerSerial(source) if not allowedSerials[serial] and getPlayerCount() >= MaxPlayers then kickPlayer(source, "Console", "You tried joining in a reserved slot!") end end addEventHandler("onPlayerJoin", root, playerJoinKick) setTimer(function() if getPlayerCount() >= MaxPlayers then setMaxPlayers(getPlayerCount() + 1) else setMaxPlayers(MaxPlayers) end end,50,0) Try this. Edited December 5, 2017 by DREFTHUN Added setTimer Link to comment
DRW Posted December 5, 2017 Author Share Posted December 5, 2017 2 minutes ago, DREFTHUN said: MaxPlayers = 48 allowedSerials = { [""]=true, } function playerJoinKick() serial = getPlayerSerial(source) if not allowedSerials[serial] and getPlayerCount() >= MaxPlayers then kickPlayer(source, "Console", "You tried joining in a reserved slot!") end end addEventHandler("onPlayerJoin", root, playerJoinKick) Try this. Yeah, I'll try that, although using onPlayerConnect and cancelEvent() will do the trick better. Thank you. Link to comment
DREFTHUN Posted December 5, 2017 Share Posted December 5, 2017 Just now, MadnessReloaded said: Yeah, I'll try that, although using onPlayerConnect and cancelEvent() will do the trick better. Thank you. It won't do the trick better. The method I wrote down is easier then almost anything else. And check out the edited script too. 2 Link to comment
DNL291 Posted December 5, 2017 Share Posted December 5, 2017 (edited) onPlayerConnect + cancelEvent () is more appropriate and it will not kick the player from server. Edited December 5, 2017 by DNL291 2 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now