ID:1704460
 
(See the best response by Kaiochao.)
Code:
mob/Login()
if(playerlimit==14)
alert("This server already has 14 players. Find another, or start your own.")
del src
else
usr.icon='player.dmi'
usr.icon_state="base"
usr.loc=locate(11,4,1)
world<<"<font color=olive><b>[usr] has joined the game."
playerlimit+=1

mob/Logout()
playerlimit-=1
del src


Problem description:
Just curious if this would work okay for the time being as a makeshift player limit code for my island survival prototype I'm hashing together real quickly.

I won't need anything advanced. Just something I'm doing for the month of October to make a horror related project.

Tips, comments appreciated.

Best response
You're using usr where src is more appropriate.
usr.icon = ...
usr.icon_state = ...
usr.loc = ...

// can/should be written
icon = ...
icon_state = ...
loc = ...

// or
src.icon = ...
src.icon_state = ...
src.loc = ...


Your variable is called "playerlimit" but it's really just "the number of players in the game", or "player count". The actual "player limit" is apparently 14.
var player_limit = 14
var player_count = 0

mob
Login()
if(player_count == player_limit)
// etc.
player_count++

Logout()
// etc.
player_count--


You can set the player's icon and icon state at compile time.
mob
icon = 'player.dmi'
icon_state = "base"


If your player is deleted but the player didn't log out, your player_count will be inaccurate. This can lead to the player limit appearing lower than it should be, because you're counting players that don't exist.