DRW Posted December 5, 2017 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? Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
Moderators IIYAMA Posted December 5, 2017 Moderators 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. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
DREFTHUN Posted December 5, 2017 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
DRW Posted December 5, 2017 Author 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. Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
DREFTHUN Posted December 5, 2017 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
DNL291 Posted December 5, 2017 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 Please do not PM me with scripting related question nor support, use the forums instead.
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