Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: Finch on Apr 17, 2015, 07:18 AM

Title: Setlevel
Post by: Finch on Apr 17, 2015, 07:18 AM
My setlevel command not working when i do/setlevel 0 7 its say level set to 7 when i do /admins level does not change this is command
else if ( cmd == "setlevel" )
   {
   if( stats[ player.ID ].Logged == false ) MessagePlayer( "Error - You don't have Login acess.", player);
   else if ( stats[ player.ID ].Level < 7 ) MessagePlayer( "Error - You don't have access to it.", player);
   else if ( !text ) yPrivMessage( "Syntax, / " + cmd + " <Nick/ID> <Level 3, 4 ,5> ", player );
   local plr = GetPlayer( GetTok( text, " ", 1 ) ), lvl = GetTok( text, " ", 2 );
   if ( !plr ) yPrivMessage( "Unknown Player..", player );
   else
    {
      if (!IsNum(lvl)) yPrivMessage("Level Must Be In Numbers..",player);
      else
      {
      yPrivMessage(" Admin " + player.Name + " Set Level To " + plr.Name + ", Level: " + lvl + ".",player);
      QuerySQL( sqliteDB,"UPDATE Accounts SET Level='" + lvl + "' WHERE Name='" + player.Name.tolower() + "'");
      }
   }
   }
Title: Re: Setlevel
Post by: DizzasTeR on Apr 17, 2015, 07:30 AM
First of all the query you use to update level will update YOUR level no matter whos id you give brcause you are using WHERE Name = player.Name and not plr.Name.

Second you have to update the array as well for the plr to have updated level.

stats[plr.ID].Level = lvl;