Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: :P on Apr 22, 2016, 11:52 AM

Title: db prob and function
Post by: :P on Apr 22, 2016, 11:52 AM
when i use setlevel cmd for setting level its say done but not updated in db and getlevel and getleveltag not working not geting i  used it in playerchat it says null cxooooo thats null coming on leveltag place
function GetLevel(player)
{
local Level =  GetSQLColumnData( QuerySQL( sqliteDB, "SELECT Level FROM Accounts WHERE Name='" + player.Name.tolower() + "'" ), 0 );
if ( Level ) return Level;
else return 0;
}
function GetLevelTag(player)
{
local Level = GetLevel(player);
if( Level == 1 ) return "Member";
if( Level == 5 ) return "Moderator";
if( Level == 6 ) return "Admin";
if( Level == 7 ) return "Management";
if( Level == 8 ) return "Developer";
}
onplayerchat
function onPlayerChat( player, text )
   {
   local col = TeamidToRGB( player.Team ), colHex = format("#%02X%02X%02X", col.r, col.g, col.b);
 EchoMessage( ICOL_LBLUE + "[" + player.ID + "] " + player.Name + "> " + ICOL_BLUE + " " + text + " " );
 Message(GetLevelTag(player) + ": [" + colHex + "]" + player.Name + ": " + WHITE + " " + text );
 if ( text )
 {
  if ( text.slice( 0, 1 ) == "!" )
  {
   local i = NumTok( text, " " ), xp = null;

   if ( i == 1 ) onPlayerCommand2( player, GetTok( text.slice( 1 ), " ", 1 ), xp );
   else onPlayerCommand2( player, GetTok( text.slice( 1 ), " ", 1 ), GetTok( text.slice( 1 ), " ", 2, i ) );
}
}

  }
Title: Re: db prob and function
Post by: KAKAN on Apr 22, 2016, 12:06 PM
Use this function:
function GetLevelTag(player)
{
local Level = GetLevel(player);
switch( Level.tointeger() )
{
case 1: return "Member";
case 5: return "Moderator";
case 6: return "Admin";
case 7: return "Management";
case 8: return "Developer";
default: return "Puto!";
}
}
Title: Re: db prob and function
Post by: :P on Apr 22, 2016, 02:55 PM
its showing puto on any level
its means its doesent geting level from db so what i do for this
Title: Re: db prob and function
Post by: :P on Apr 22, 2016, 03:21 PM
thanks Kakan your function working and other prob is due wrong query i solved it thanks