Raised This Month: $ Target: $400
 0% 

GXLZPGX's ID System v1.00


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 03-31-2012 , 14:34   GXLZPGX's ID System v1.00
Reply With Quote #1

ID System v1.00

What is this?

As coders, you might have ran into a few problems in the past with the current ID system, which works, but to an extent.

Ex. You have 3 players in a server. Each player assigned a specific ID based on when they joined.

Player 1: ID 1
Player 2: ID 2
Player 3: ID 3

Now let's say Player 2 disconnects, and you're left with the original first and third player. Their ID's will stay the same, but there will only be 2 players, so:

Player 1: ID 1
Player 2: ID 3

See the problem? Now, with this new system, I'm not sure exactly what YOU might use it for, but for me, it was necessary when flipping through the players in order.

Ex: Round 1, player 1 received 150 HP. Round 2, player 2 received 150 HP, etc.

Well if I'm flipping through their ID's, and I get to ID 2 (when player #2 disconnected and there IS no player in that slot, it creates ID problems, which are unneeded)

Why not just skip that ID if the player doesn't exist?

Basically, I want a fair system. With the current system, if a new player joins, they would take the second slot, even though the first and third person were the original two. Which would basically give Player 3, which is ID 2 (now that they've taken the ID 2 because it's available), 150 HP, though they haven't waited as long as ID 3 has.

How EXACTLY does it work?

This system fixes the problem by reassigning ID's (not literally). It creates a new variable to hold new ID's.

Example of the system:

Player 1: ID 1
Player 2: ID 2
Player 3: ID 3

Player 2 disconnects, ID's are now:

Player 1: ID 1
Player 3: ID 2

Converting player 3 to player 2 (technically, because we are switching his ID)

Player 2 reconnects:

Player 1: ID 1
Player 3: ID 2 (Technically player 2 now)
Player 2: ID 3 (Now officially player 3)

I apologize if any of this is confusing.

Code Preview

PHP Code:
/* Bullet Proof ID System by Shadow (aka GXLZPGX) */

#include <amxmodx>

#define PLUGIN    "Bullet Proof ID System"
#define AUTHOR    "Shadow"
#define VERSION    "1.0.0"

new cPlayers;
new 
aID;
new 
eID[33];
new 
pID[33];

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
//deathmsg
    
register_messageget_user_msgid"DeathMsg" ) , "pDeathMsg" );
    
    
//check id
    
register_clcmd"say /id""pCheckID" )
}

public 
pCheckID(id)
{
    new 
menu menu_create("\r[ID List] \wPlayers""menu_handler");
    
    new 
iPlayers[32], iNumtempid;
    new 
szName[32], szTempid[10];
    
    
get_players(iPlayersiNum);
    
    for( new 
0iNumi++ )
    {
        
tempid iPlayers[i];
        
        
get_user_nametempidszNamecharsmax(szName) );
        
num_to_strtempidszTempidcharsmax(szTempid) );
        
        new 
szMenuItem[64];
        
formatexszMenuItemcharsmax(szMenuItem), "%s \rID: %i"szNameeID[tempid] )
        
        
menu_additemmenuszMenuItemeID[tempid], );
    }
    
    
menu_display(idmenu0);
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;
    }
    
    new 
data[6], szName[64];
    new 
accesscallback;
    
menu_item_getinfo(menuitemaccessdata,charsmax(data), szName,charsmax(szName), callback);
    
    new 
tempid str_to_num(data);
    
    if( 
is_user_alive(tempid) )
    {
        
pCheckID(id)
    }
    
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED;
}

public 
client_putinserver(id)
{
    
aID++;
    
pID[aID] = id
    eID
[id] = aID;
    
cPlayers++;
}

public 
client_disconnect(id)
{
    
set_task0.1"pNewIDs" )
    
cPlayers--;
}

public 
pNewIDs()
{
    new 
iPlayer[32], iNumnID;
    
get_playersiPlayeriNum )
    
    
aID 0;
    
    for( new 
0iNumi++ )
    {
        
nID iPlayer[i];
        
        
aID++
        
pID[aID] = nID;
        
eID[nID] = aID;
    }

Attached Files
File Type: sma Get Plugin or Get Source (IDSystem.sma - 818 views - 1.8 KB)
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.

Last edited by GXLZPGX; 03-31-2012 at 15:26.
GXLZPGX is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode