SA-MP Forums Archive
[SOLVED] Problem With Login Command - 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: [SOLVED] Problem With Login Command (/showthread.php?tid=71516)



[SOLVED] Problem With Login Command - Alec24 - 01.04.2009

It was fine until I tried to add an :

Код:
if(ReqClass[playerid] == 1)
pawn Код:
if(strcmp(cmd, "/login", true) == 0)
  {
    if(Logged[playerid] == 1)
    {
    if(ReqClass[playerid] == 1)
    {
      SendClientMessage(playerid, COLOUR_RED, "You Are Already Logged In!");
      return 1;
    }
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
      SendClientMessage(playerid, COLOUR_YELLOW, "USAGE: /login [password]");
    }
    else
    {
      if (dini_Exists(udb_encode(PlayerName)))
      {
        tmp2 = dini_Get(udb_encode(PlayerName), "password");
        if (udb_hash(tmp) != strval(tmp2))
        {
          SendClientMessage(playerid, COLOUR_RED, "Wrong/Invalid Password!");
        }
        else
        {
          Logged[playerid] = 1;
          Money[playerid] = dini_Int(udb_encode(PlayerName), "Money");
          AdminLevel[playerid] = dini_Int(udb_encode(PlayerName), "AdminLevel");
         
            TruckType[playerid] = dini_Int(udb_encode(PlayerName), "TruckType");
            JobsDone[playerid] = dini_Int(udb_encode(PlayerName), "JobsDone");
            JobLevel[playerid] = dini_Int(udb_encode(PlayerName), "JobLevel");
         
          format(string, sizeof(string), "%s, You Are Now Logged In. You Are Admin Level %d And Have $%d", PlayerName, AdminLevel[playerid], Money[playerid]);
          SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
          new Stats[128];
          format(Stats, sizeof(Stats), "[STATS] Job Level: %d | Best Truck ID: %d | Jobs Finished: %d", JobLevel[playerid], TruckType[playerid], JobsDone[playerid]);
          SendClientMessage(playerid, COLOUR_GREEN, Stats);
         
          GivePlayerMoney(playerid, Money[playerid]);
         
          TruckerSkin[playerid] = dini_Int(udb_encode(PlayerName), "Skin");
          SetPlayerSkin(playerid,TruckerSkin[playerid]);
        }
      }
      else
      {
        format(string, sizeof(string), "You Are Not Registered. Type /register [password] To Create An Account!", PlayerName);
        SendClientMessage(playerid, COLOUR_RED, string);
      }
     
            }
      else
      {
        SendClientMessage(playerid, COLOUR_RED, "You Must Login After The Class Selection!");
      }
    }
    return 1;
  }
I just want it so if reqclass=1 then you cannot login...


Re: Problem With Login Command - FUNExtreme - 01.04.2009

Check like this.

pawn Код:
if(reqblah == 0)
{
   SendClientblah(...
}
if(logged == 1)
{
  ....
}
//rest



Re: Problem With Login Command - Think - 01.04.2009

you miss one bracket at the beginning?

pawn Код:
if(Logged[playerid] == 1)
    {
        if(ReqClass[playerid] == 1)
        {
          SendClientMessage(playerid, COLOUR_RED, "You Are Already Logged In!");
          return 1;
        }
    }



Re: Problem With Login Command - FUNExtreme - 01.04.2009

Quote:
Originally Posted by Pandabeer1337
you miss one bracket at the beginning?

pawn Код:
if(Logged[playerid] == 1)
    {
        if(ReqClass[playerid] == 1)
        {
          SendClientMessage(playerid, COLOUR_RED, "You Are Already Logged In!");
          return 1;
        }
    }
Wont help him. Read his post and look at the code again.
Btw I allready told him what to do.


Re: Problem With Login Command - Alec24 - 01.04.2009

It displays the correct message but it will still continue to login:

Код:
if(strcmp(cmd, "/login", true) == 0)
  {
    if(ReqClass[playerid] == 1)
		{
   	SendClientMessage(playerid, COLOUR_RED, "You Can Only Login After The Class Selection!");
		}
		if(Logged[playerid] == 1)
		{
		 SendClientMessage(playerid, COLOUR_RED, "You Are Already Logged In!");
		 return 1;
		}

    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp))
    {
      SendClientMessage(playerid, COLOUR_YELLOW, "USAGE: /login [password]");
    }
    else
    {
      if (dini_Exists(udb_encode(PlayerName)))
      {
        tmp2 = dini_Get(udb_encode(PlayerName), "password");
        if (udb_hash(tmp) != strval(tmp2))
        {
          SendClientMessage(playerid, COLOUR_RED, "Wrong/Invalid Password!");
        }
        else
        {
          Logged[playerid] = 1;
          Money[playerid] = dini_Int(udb_encode(PlayerName), "Money");
          AdminLevel[playerid] = dini_Int(udb_encode(PlayerName), "AdminLevel");
          
	        TruckType[playerid] = dini_Int(udb_encode(PlayerName), "TruckType");
	        JobsDone[playerid] = dini_Int(udb_encode(PlayerName), "JobsDone");
	        JobLevel[playerid] = dini_Int(udb_encode(PlayerName), "JobLevel");
          
          format(string, sizeof(string), "%s, You Are Now Logged In. You Are Admin Level %d And Have $%d", PlayerName, AdminLevel[playerid], Money[playerid]);
          SendClientMessage(playerid, COLOUR_LIGHTBLUE, string);
          new Stats[128];
          format(Stats, sizeof(Stats), "[STATS] Job Level: %d | Best Truck ID: %d | Jobs Finished: %d", JobLevel[playerid], TruckType[playerid], JobsDone[playerid]);
          SendClientMessage(playerid, COLOUR_GREEN, Stats);
          
          GivePlayerMoney(playerid, Money[playerid]);
          
          TruckerSkin[playerid] = dini_Int(udb_encode(PlayerName), "Skin");
          SetPlayerSkin(playerid,TruckerSkin[playerid]);
        }
      }
      else
      {
        format(string, sizeof(string), "You Are Not Registered. Type /register [password] To Create An Account!", PlayerName);
        SendClientMessage(playerid, COLOUR_RED, string);
      }
    }
    return 1;
  }
How do I stop the command from logging in if reqclass=1


Re: Problem With Login Command - Think - 01.04.2009

try this one (fixed indent a bit )

click meh


Re: Problem With Login Command - FUNExtreme - 01.04.2009

To stop the code add return 0; where needed


Re: Problem With Login Command - Think - 01.04.2009

Quote:
Originally Posted by FUNExtreme
To stop the code add return 0; where needed
that'll return SERVER: Unknown command


Re: Problem With Login Command - FUNExtreme - 01.04.2009

Nop


Re: Problem With Login Command - Alec24 - 01.04.2009

Pandabeer1337, When i first tried your code there were alot of errors but after I added an extra bracket just before the last return 1; it seemed to fix it but I will have to test it tommorow.