[dudb] Check if variable is higher or lower
#1

Okay,

Lets say a users file looks like this:

Quote:

Password=18961696
Skin=253
Health=59
level=1

Now, i have a command that a user has to be level 2 or up, if they aren't level >2, it says you haven't achieved a high enough level to use this command.

How can I do this?
Reply
#2

Why don't you store the users variables into an array when he logs in?
That's so much easier.
Reply
#3

Quote:
Originally Posted by //exora
Why don't you store the users variables into an array when he logs in?
That's so much easier.
Okay, how can I do this then..?
Reply
#4

http://forum.sa-mp.com/index.php?topic=4798.0 <thats how
Reply
#5

Quote:
Originally Posted by GTA967
Thats not what im looking for, that just shows how to make a register and login system, i already have that.

Read the topic plz.
Reply
#6

pawn Код:
new variable[MAX_PLAYERS];
//on connect
if (dini_Exists(udb_encode(PlayerName(playerid)))) {// i suppose u have the playername func...
        new tmp[256];
        tmp = dini_Get(udb_encode(PlayerName(playerid)), "level");
        variable[playerid] = strval(tmp);
}
//in a command
if(level[playerid] < /*mininal level*/1)...
also i think the lvl is saved in onplayerdisconnect? :P
have fun
Reply
#7

Quote:
Originally Posted by gamer_Z
pawn Код:
new variable[MAX_PLAYERS];
//on connect
if (dini_Exists(udb_encode(PlayerName(playerid)))) {// i suppose u have the playername func...
        new tmp[256];
        tmp = dini_Get(udb_encode(PlayerName(playerid)), "level");
        variable[playerid] = strval(tmp);
}
//in a command
if(level[playerid] < /*mininal level*/1)...
also i think the lvl is saved in onplayerdisconnect? :P
have fun
nice, it works, this is my command:

pawn Код:
if(strcmp(cmdtext, "/ad", true)==0)
  {
  if(level[playerid] < 1)
  {
  SendClientMessage(playerid, COLOR_RED, "You are an admin!");
  }
  else
  {
    SendClientMessage(playerid, COLOR_RED, "You are not authorized to use this command!");
  }
  return 1;
  }
But now, players can use an admins name, and not login and still use the command!

How do I check if
Код:
logged[playerid] = 1;
if it is 0, then you can't use the command, if it is 1 and your an admin, you can use the command.
Reply
#8

if(logged[playerid] == 0)return SendClientMessage(playerid,color,"You Must first login!");
ex
pawn Код:
if(strcmp(cmdtext, "/ad", true)==0)
  {
  if(logged[playerid] == 0)return SendClientMessage(playerid,color,"You Must first login!");
  if(level[playerid] < 1)return SendClientMessage(playerid, COLOR_RED, "You are an admin!, You are not authorized to use this command!");
  //here what you cmd will do
  return 1;
  }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)