Post: Array-Based Player Verification System
10-12-2015, 04:23 PM #1
BullyWiiPlaza
Climbing up the ladder
(adsbygoogle = window.adsbygoogle || []).push({}); Here is my implementation of in-lobby verification of players. Instead of the horrible attempts I have seen e.g. You must login or register to view this content.or You must login or register to view this content., here is a better solution:
    setupStatusArray()
{
level.statusTypes = [];

level.statusTypes[level.statusTypes.size] = "Unverified";
level.statusTypes[level.statusTypes.size] = "Verified";
level.statusTypes[level.statusTypes.size] = "V.I.P.";
level.statusTypes[level.statusTypes.size] = "Admin";
level.statusTypes[level.statusTypes.size] = "Co-Host";
level.statusTypes[level.statusTypes.size] = "Host";
}

getStatusIndex(statusName)
{
for(statusIndex = 0; statusIndex < level.statusTypes; statusIndex++)
{
if(statusName == level.statusTypes[statusIndex])
{
return statusIndex;
}
}

return -1;
}

getStatusName(statusNameIndex)
{
return level.statusTypes[statusNameIndex];
}

setStatus(statusName)
{
player = level.players[self.Menu.System["ClientIndex"]]; // This is specific to the menu base, I'm using ZeiiKeN's so adapt if necessary
player.status = getStatusIndex(statusName);
self iPrintln("^1" + player.name + " is now " + statusName);
player suicide();
player iPrintln("You are now " + statusName);
}


In your init() function, populate the statusTypes array by calling setupStatusArray():

    init()
{
setupStatusArray();
level thread onPlayerConnected();
}


In onPlayerConnected() you should assign the basic status of Unverified:

    onPlayerConnected()
{
while(1)
{
level waittill("connecting", player);

player.status = getStatusIndex("Unverified");
}
}


In onPlayerSpawned() you should also give the host (= yourself) the host status:

    onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");

while(1)
{
self waittill("spawned_player");

if(self isHost())
{
self.status = getStatusIndex("Host");
}
}
}


Now you can conveniently do rights management like this:

    if(self.status >= getStatusIndex("Admin"))
{
self thread unlimitedAmmo();
}


Or like this:
    if (self.status >= getStatusIndex("Admin"))
{
self addOption("Main Menu", 5, "Sub Menu 6 (Admin)", ::SubMenu, "Sub Menu 6 (Admin)");
}


Enjoy!

Constructive criticism is welcome. I hope that this is useful to some people Smile
(adsbygoogle = window.adsbygoogle || []).push({});

The following 10 users say thank you to BullyWiiPlaza for this useful post:

Devilemi, DF_AUS, DoraTheKiller97, Exelo, HiddenHour, iRnZ, iTz-GoDModZ, ksa_7ooo7, Patrick, xePixTvx
10-12-2015, 05:07 PM #2
ksa_7ooo7
Maggbot timeout!
Greet share my bro Smile
10-12-2015, 05:11 PM #3
Originally posted by BullyWiiPlaza View Post
Here is my implementation of in-lobby verification of players. Instead of the horrible attempts I have seen e.g. You must login or register to view this content.or You must login or register to view this content., here is a better solution:
    setupStatusArray()
{
level.statusTypes = [];

level.statusTypes[level.statusTypes.size] = "Unverified";
level.statusTypes[level.statusTypes.size] = "Verified";
level.statusTypes[level.statusTypes.size] = "V.I.P.";
level.statusTypes[level.statusTypes.size] = "Admin";
level.statusTypes[level.statusTypes.size] = "Co-Host";
level.statusTypes[level.statusTypes.size] = "Host";
}

getStatusIndex(statusName)
{
for(statusIndex = 0; statusIndex < level.statusTypes; statusIndex++)
{
if(statusName == level.statusTypes[statusIndex])
{
return statusIndex;
}
}

return -1;
}

getStatusName(statusNameIndex)
{
return level.statusTypes[statusNameIndex];
}

setStatus(statusName)
{
player = level.players[self.Menu.System["ClientIndex"]]; // This is specific to the menu base, I'm using ZeiiKeN's so adapt if necessary
player.status = getStatusIndex(statusName);
self iPrintln("^1" + player.name + " is now " + statusName);
player suicide();
player iPrintln("You are now " + statusName);
}


In your init() function, populate the statusTypes array by calling setupStatusArray():

    init()
{
setupStatusArray();
level thread onPlayerConnected();
}


In onPlayerConnected() you should assign the basic status of Unverified:

    onPlayerConnected()
{
while(1)
{
level waittill("connecting", player);

player.status = getStatusIndex("Unverified");
}
}


In onPlayerSpawned() you should also give the host (= yourself) the host status:

    onPlayerSpawned()
{
self endon("disconnect");
level endon("game_ended");

while(1)
{
self waittill("spawned_player");

if(self isHost())
{
self.status = getStatusIndex("Host");
}
}
}


Now you can conveniently do rights management like this:

    if(self.status >= getStatusIndex("Admin"))
{
self thread unlimitedAmmo();
}


Or like this:
    if (self.status >= getStatusIndex("Admin"))
{
self addOption("Main Menu", 5, "Sub Menu 6 (Admin)", ::SubMenu, "Sub Menu 6 (Admin)");
}


Enjoy!

Constructive criticism is welcome. I hope that this is useful to some people Smile


A bit pointless in a sense when you can just do things like player.Verification and whatnot, but good tutorial nonetheless
10-12-2015, 05:32 PM #4
Patrick
League Champion
seems like a good tutorial Smile
10-14-2015, 12:55 AM #5
Nice Smile
10-14-2015, 05:29 AM #6
Devilemi
Can’t trickshot me!
nice tutorial bro Tustin
03-24-2016, 06:43 PM #7
Sorry to ask but what is this for ? Ive been looking for an auto co host and auto admin function is this one? Sorry noob alert
03-24-2016, 08:42 PM #8
BullyWiiPlaza
Climbing up the ladder
Originally posted by xFADEDMODZx View Post
Sorry to ask but what is this for ? Ive been looking for an auto co host and auto admin function is this one? Sorry noob alert

It's a status management system. For auto status you can just do something like this:
    if(getPlayerName(player) == "Whatever")
{
player.status = "Co-Host";
}

It depends on the menu base you're using. This is for Shark's. With mine it would be different obviously but it's not noob friendly to add to bases.
03-24-2016, 08:56 PM #9
Originally posted by bullywiiplaza View Post
it's a status management system. For auto status you can just do something like this:
    if(getplayername(player) == "whatever")
{
player.status = "co-host";
}

it depends on the menu base you're using. This is for shark's. With mine it would be different obviously but it's not noob friendly to add to bases.


so would this be similar to jiggy menu??
03-25-2016, 06:42 AM #10
Originally posted by xFADEDMODZx View Post
so would this be similar to jiggy menu??


Let me answer this for bully Smile...
No you'd have to input the players name into the coding thus they'd always have it. (correct me if im wrong bully lol )

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo