SA-MP Forums Archive
2 Quick questions. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: 2 Quick questions. (/showthread.php?tid=120577)



2 Quick questions. - whereschris - 11.01.2010

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.


Re: 2 Quick questions. - MadeMan - 11.01.2010

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);



Re: 2 Quick questions. - whereschris - 11.01.2010

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.


Re: 2 Quick questions. - Finn - 11.01.2010

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;



Re: 2 Quick questions. - whereschris - 11.01.2010

Thanks, that pretty much explained it for me.

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

Thank you both.