UID alias

Started by KingOfVC, Sep 10, 2015, 03:33 PM

Previous topic - Next topic

KingOfVC

function onScriptLoad()
{
   db <- ConnectSQL("Alias.db")
   QuerySQL( db, "CREATE TABLE IF NOT EXISTS UIDAlias ( Name VARCHAR(25), UID VARCHAR(255) )" );

}

function onPlayerJoin(player)
{
MacAddAlias(player)
}

function onPlayerCommand(player,cmd,text)
{
if ( cmd == "alias" )
{
if ( !text ) MessagePlayer("Error: /alias <player>",player)
else
{
local plr = FindPlayer(text)
if ( !plr ) MessagePlayer("Error: Invalid player.",player)
else
{
local q = QuerySQL( db, "SELECT * FROM UIDAlias WHERE UID='" + plr.UID + "'" );
if ( GetSQLColumnData( q,0 ) == plr.UID )
{
MessagePlayer("Player: [ " plr.Name +" ] Alias [ " + GetSQLColumnData(q,1) + " ]",player)
}
}
}
}
}

function MacAddAlias(player)
{
local q = QuerySQL( db, "SELECT * FROM UIDAlias WHERE UID='" + player.UID + "'" );
if ( GetSQLColumnData( q,0 ) == player.UID )
{
if ( GetSQLColumnData( q,1 ).find(player.Name) == null )
{
local Fk = GetSQLColumnData( q,1 )
local mose = Fk + ", " + player.Name
QuerySQL(db, "UPDATE UIDAlias SET Name='" + mose + "' WHERE UID= '" + player.UID + "'");
}
}
else
{
QuerySQL(db,"INSERT INTO UIDAlias VALUES('" + player.UID + "', '" + player.Name + "')");
}
}

jayant

@KingOfVC - Check some lines please..Or people will start spamming for errors :) Nice work.

KAKAN

oh no