/setlevel /headsetlevel /devsetlevel

Started by umar4911, Oct 29, 2017, 11:00 AM

Previous topic - Next topic

D4rkR420R

Quote from: Mohamed on Nov 29, 2017, 06:40 PMHere It Is @KuRiMi,

else if ( cmd == "setlevel" )
{
if( pstats[ player.ID ].Logged == false ) MessagePlayer( "[#ff0000][INFO][#ffffff] You Need Login or Register First.", player );
else if ( pstats[ player.ID ].Level < 10 ) MessagePlayer( "[#FF0000][INFO][#ffffff] You Are Not Authorized To use This Command", player );
else if ( !text ) MessagePlayer( "[#00BBFF][INFO][#ffffff] /setlevel <Nick/id> <Level>", player );
else
{
local plr = GetPlayer( GetTok( text, " ", 1 ) );
local plrl = GetSQLColumnData(q, 3);
if ( plrl >= 10 ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] You cannot set the level of the Developer.", player );
if ( !plr ) MessagePlayer( "[#ff0000][ERROR][#ffffff] Unknown Player..", player );
else
{
local lvl = GetTok( text, " ", 2);
if (!IsNum(lvl)) MessagePlayer("[#ff0000][ERROR][#ffffff] Level Must Be In Numbers..",player);
else
{
Message("[#fff123]Administrator[#ffffff] " + player.Name + " Set Level To " + plr.Name + ", Level: " + lvl + ".");
QuerySQL( sqliteDB,"UPDATE Accounts SET Level='" + lvl + "' WHERE Name='" + plr.Name + "'");
pstats[ player.ID ].Level = lvl.tointeger();
}
}
}
}

But When I'm Level 9 I Can Set My Level To 10 :/

:c Look at this.
local plrl = GetSQLColumnData(q, 3);Their is no variable storing a userdata. Therefore, you were mising this piece of code.
local q = QuerySQL(DB , "SELECT * FROM Accounts WHERE Name ='" + GetTok( arguments, " ", 1 ) + "'" );
if(!q) MessagePlayer("[#FFDD33]Usage Error:[#FFFFFF] Invalid Player", player);
else {

Here's the fixed version.
else if ( cmd == "setlevel" || cmd == "darlevel")
{
if(status[player.ID].Level < 8) MessagePlayer("[#FFDD33]Information:[#FFFFFF] Unauthorized Access.", player);
if ( !arguments ) MessagePlayer("[#FFDD33]Command Error:[#FFFFFF] Use /"+cmd+" [Nick/ID] [Level]", player );
else if ( NumTok( arguments, " " ) < 2 ) MessagePlayer("[#FFDD33]Command Error:[#FFFFFF] Use /"+cmd+" [Nick/ID] [Level]", player );
else
{
local q = QuerySQL(DB , "SELECT * FROM Accounts WHERE Name ='" + GetTok( arguments, " ", 1 ) + "'" );
if(!q) MessagePlayer("[#FFDD33]Usage Error:[#FFFFFF] Invalid Player", player);
else
{
local plr = GetSQLColumnData(q, 0);
local plrl = GetSQLColumnData(q, 3);
if ( plrl > 7 ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] You cannot set the level of head servers.", player );
else
{
local lvl = GetTok( arguments, " ", 2);
if (!IsNum(lvl)) MessagePlayer("[#FFDD33]Usage Error:[#FFFFFF] Level must be only in numbers.",player);
else
{
MessagePlayer("[#FFDD33]Administator Command:[#FFFFFF] Admin[" + player.Name + "] set level of player :" + plr + " to: " + lvl + ".",player);
QuerySQL(DB , "UPDATE Accounts SET Level='" + lvl + "' WHERE Name = '" + plr + "'" );
}
}
}
}
}

Mohamed Boubekri

@KuRiMi, I Have Tested It But I'm Join With Level 9
But i Do /setlevel We3 10 // Lol i Can Set My Level To Higher Level // Same Problem
Problem Not Fixed Yet :(
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

D4rkR420R

Quote from: Mohamed on Nov 29, 2017, 06:56 PM@KuRiMi, I Have Tested It But I'm Join With Level 9
But i Do /setlevel We3 10 // Lol i Can Set My Level To Higher Level // Same Problem
Problem Not Fixed Yet :(

Your in-game nick is We3da? I think the major issue is that you didn't add a if statement if that player's level is higher than the number you imputed. So, make another variable that locates the player's level on the account database.

Mohamed Boubekri

@KuRiMi, I'm Have Command /setlevel Fine Its Work But its For Level 10.
i Want To Add /msetlevel For Level 9
But if Me Level 9 Can Set Level TO Level 10
I'm Want If the Player Do /msetlevel He Just Can Set Level To 9 // Can't Set Level OF Devolper
About That's Command Its Work i Joined With Level 9 And i Joiined With oither Name test
Yas i Can't Set Level of Devolper But i Can Set my level To 10 // that's My probelm.
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

D4rkR420R

Quote from: Mohamed on Nov 29, 2017, 09:04 PM@KuRiMi, I'm Have Command /setlevel Fine Its Work But its For Level 10.
i Want To Add /msetlevel For Level 9
But if Me Level 9 Can Set Level TO Level 10
I'm Want If the Player Do /msetlevel He Just Can Set Level To 9 // Can't Set Level OF Devolper
About That's Command Its Work i Joined With Level 9 And i Joiined With oither Name test
Yas i Can't Set Level of Devolper But i Can Set my level To 10 // that's My probelm.

Make sure plr1 is directing to the correct column. Otherwise, it's reading the code incorrectly and allow the level 9 user to prevent going more than 9.

Mohamed Boubekri

| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

D4rkR420R

Quote from: Mohamed on Nov 30, 2017, 07:28 AM@KuRiMi, Example ? :P

Their's no example in this case; you have to look for the answer by finding the answer in which you use a method known as "debugging".

!

#22
Use this level 9 and 10 admins will be able to use this command but level 9 admin wil not be able to assign higher levels while level 10 admin can assign any level to anyone.

if ( cmd == "setlevel" )
{
   if( pstats[ player.ID ].Logged == false ) MessagePlayer( "[#ff0000][INFO][#ffffff] You Need Login or Register First.", player );
   else if ( pstats[ player.ID ].Level < 9 ) MessagePlayer( "[#FF0000][INFO][#ffffff] You Are Not Authorized To use This Command", player );
   else if ( !text ) MessagePlayer( "[#00BBFF][INFO][#ffffff] /setlevel <Nick/id> <Level>", player );
   else
   {
      local
         plr = GetPlayer( GetTok( text, " ", 1 ) ),
         lvl = GetTok( text, " ", 2);
      if ( !plr ) MessagePlayer( "[#ff0000][ERROR][#ffffff] Unknown Player..", player );
      else if ( pstats[ player.ID ].Level == 9 && pstats[ plr.ID ].Level >= pstats[ player.ID ].Level ) MessagePlayer( "[#FFDD33]Usage Error:[#FFFFFF] You cannot set the level of higher level admin.", player );
      else if ( !lvl ) MessagePlayer("[#ff0000][ERROR][#ffffff] Put level", player);
      else if ( !IsNum( lvl ) ) MessagePlayer("[#ff0000][ERROR][#ffffff] Level Must Be In Numbers.", player);
      else
      {
         pstats[ plr.ID ].Level = lvl.tointeger();
         QuerySQL( sqliteDB,"UPDATE Accounts SET Level='"+lvl+"' WHERE lower(Name) LIKE '"+plr.Name+"'");
         Message("[#fff123]Administrator[#ffffff] "+player.Name+" set level of "+plr.Name+" to: "+lvl+".");
      }
   }
}

Quote from: KuRiMi on Nov 30, 2017, 06:03 AMMake sure plr1 is directing to the correct column. Otherwise, it's reading the code incorrectly and allow the level 9 user to prevent going more than 9.
In his case there's no need to assign and get level of plr using database since he is setting level only for online players why to waste time by getting data from database when pstats class has a level stored in it.

Discord: zeus#5155

Mohamed Boubekri

@! Niiiiiiiiiiiiiiiiiiiiiiiiice Working Thanksssss u Very Muchhhhhhhhh :D :D :D
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].