2 Quick questions.
#1

Hello.
Код:
	if(strcmp(cmd, "/ah", true) == 0)
	{
	  if (dini_Int(file, "AdminLevel") >= 1) {
			  SendClientMessage(playerid, BLUE, "[[  List of admin commands  ]]");
			  SendClientMessage(playerid, COLOR, "[[Level 1 admin: /kick ]]");
			  SendClientMessage(playerid, COLOR, "[[Level 2 admin: /ban /ip ]]");
			  SendClientMessage(playerid, COLOR, "[[Level 3 admin: /givegun /setcash /sethealth /setarmour /setscore ]]");
			  SendClientMessage(playerid, COLOR, "[[Level 4 admin: /noneatm ]]");
			  SendClientMessage(playerid, COLOR, "[[Level 5 admin: /GMX ]]");
	}
	else
	    SendClientMessage(playerid, COLOR, "You our not autherized to use this command.");
		}
Here is a command I just attempted to make. It works fine and does display the text. although after all the next it will say SERVER UNKNOWN TEXT. The command works it just always says unknown text for some reason. Any pointers would be great



Also if you cannot answer this its fine.

Код:
  	if(strcmp(cmd, "/login", true) == 0)
	{
	  new PlayerName[24];
	  tmp = strtok(cmdtext, idx);
	  if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /login [password]");
		new name[MAX_PLAYER_NAME];
		if(IsLogged[playerid] == 1)
		{
			SendClientMessage(playerid, COLOR, "You already are logged in!");
			return 1;
		}
		else
		{
			GetPlayerName(playerid, name, sizeof(name));
			format(file,sizeof(file),"%s.ini",name);
			if(fexist(file))
			{
		  	tmp2 = dini_Get(file, "Password");
			 	if(udb_hash(tmp) != strval(tmp2))
				{
				  SendClientMessage(playerid, COLOR, "Login Failed!");
	 			  GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
	 			  printf("%s has failed to login", name);
				}
				else
				{
				 	IsLogged[playerid] = 1;
				 	SetPlayerMoney(playerid, dini_Int(file, "Cash"));
					PlayerInfo[playerid][AdminLevel] = dini_Int(file, "AdminLevel");
					SendClientMessage(playerid, COLOR, "[System]: Account Logged into!");
				}
			}
		}
		return 1;
	}
Thats my /login it works and all although it saves in "Script files". How could I make it save in a folder in script files Named "Accounts"?

Thanks all.
Reply
#2

1. Add return 1; at the end of the command.

pawn Код:
if(strcmp(cmd, "/ah", true) == 0)
    {
      if (dini_Int(file, "AdminLevel") >= 1) {
              SendClientMessage(playerid, BLUE, "[[  List of admin commands  ]]");
              SendClientMessage(playerid, COLOR, "[[Level 1 admin: /kick ]]");
              SendClientMessage(playerid, COLOR, "[[Level 2 admin: /ban /ip ]]");
              SendClientMessage(playerid, COLOR, "[[Level 3 admin: /givegun /setcash /sethealth /setarmour /setscore ]]");
              SendClientMessage(playerid, COLOR, "[[Level 4 admin: /noneatm ]]");
              SendClientMessage(playerid, COLOR, "[[Level 5 admin: /GMX ]]");
      }
      else
        SendClientMessage(playerid, COLOR, "You our not autherized to use this command.");
        return 1;
    }
2.

pawn Код:
format(file,sizeof(file),"Accounts/%s.ini",name);
Reply
#3

Wow thank you so much for the quick reply.

Both of your methods worked .

One more question though, what is Return 1; and Return 0; used for? Why would a return cause it?

Just out of curiosity, hehe trying to learn as much as possible.
Reply
#4

Quote:
Originally Posted by whereschris
One more question though, what is Return 1; and Return 0; used for? Why would a return cause it?
It returns the callback.

pawn Код:
if(this == that)
{
  print("This will be printed if this == that.");
  return 1;
}
print("This will not be printed if this == that.");
return 1;
pawn Код:
if(this == that)
{
  print("This will be printed if this == that.");
}
print("This will be printed aswell no matter what.");
return 1;
pawn Код:
if(this)
{
  print("Neither of those below will be printed if this is true.");
  return 1;
}
if(this == that)
{
  print("This will be printed if this == that.");
  return 1;
}
print("This will not be printed if this == that.");
return 1;
Reply
#5

Thanks, that pretty much explained it for me.

I'm still surprised on how fast the reply's were..

Thank you both.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)