Wrong strval
#1

He only return, that my name has at least 3 words, but i have it, whats wrogn?
if(strcmp(cmd, "/email", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pLaptop] == 1)
{
if(PlayerInfo[playerid][pAccountMail] == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /email [accountname] [password]");
return 1;
}
new accountname = strval(tmp);
if(accountname < 3 || accountname > 10) { SendClientMessage(playerid, COLOR_GRAD2, " Your name MUST have 3 words and not ore than 10 !"); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /email [accountname] [password]");
return 1;
}
new accountpass = strval(tmp);
if(accountpass < 5 && accountpass > 15) { SendClientMessage(playerid, COLOR_GRAD2, " You password MUST have 5 words and not more than 15 !"); return 1; }
PlayerInfo[playerid][pAccountMailName] = accountname;
PlayerInfo[playerid][pAccountMailPass] = accountpass;
PlayerInfo[playerid][pAccountMail] = 1;
SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have created your E-mail Account.");
format(string, sizeof(string), "Account: %s, Password: %s",PlayerInfo[playerid][pAccountMailName], PlayerInfo[playerid][pAccountMailPass]);
SendClientMessage(playerid, COLOR_YELLOW, string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " You already have a an E-mail Account.");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, " You don't have a laptop.");
return 1;
}
}//not connected
return 1;
}
Reply
#2

strval gets a number out of a string, you wanted to use strlen which gets the length of a string

--> strval
--> strlen
Reply
#3

Yes, but i don't know how to do it, an example will do it. please
Reply
#4

Did you bothered to click that link he posted? The example is there.
Reply
#5

Yes, but with if(strlen < 3 || strlen > 10) dfont work
Reply
#6

Quote:
Originally Posted by Bl4ckDice
Yes, but with if(strlen < 3 || strlen > 10) dfont work
*facepalm*

namelength = strlen("Maniac");

if(namelength < 3 || namelength > 10)

is that enough or do i need to explain it more explicit?
Reply
#7

Pls more exactly, would be great. Because i have to save it.
Reply
#8

pawn Код:
if(strcmp(cmd, "/email", true) == 0)
  {
   if(IsPlayerConnected(playerid))
   {
     if(PlayerInfo[playerid][pLaptop] == 1)
     {
       if(PlayerInfo[playerid][pAccountMail] == 0)
       {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
         SendClientMessage(playerid, COLOR_WHITE, "USAGE: /email [accountname] [password]");
         return 1;
        }
        new accountname = strlen(tmp);
        if(accountname < 3 || accountname > 10) { SendClientMessage(playerid, COLOR_GRAD2, "  Your name MUST have 3 words and not ore than 10 !"); return 1; }
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
         SendClientMessage(playerid, COLOR_WHITE, "USAGE: /email [accountname] [password]");
         return 1;
        }
        new accountpass = strlen(tmp);
        if(accountpass < 5 && accountpass > 15) { SendClientMessage(playerid, COLOR_GRAD2, "  You password MUST have 5 words and not more than 15 !"); return 1; }
        PlayerInfo[playerid][pAccountMailName] = accountname;
        PlayerInfo[playerid][pAccountMailPass] = accountpass;
        PlayerInfo[playerid][pAccountMail] = 1;
        SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You have created your E-mail Account.");
        format(string, sizeof(string), "Account: %s, Password: %s",PlayerInfo[playerid][pAccountMailName], PlayerInfo[playerid][pAccountMailPass]);
        SendClientMessage(playerid, COLOR_YELLOW, string);
        return 1;
      }
      else
      {
        SendClientMessage(playerid, COLOR_GRAD2, " You already have a an E-mail Account.");
        return 1;
       }
     }
     else
     {
      SendClientMessage(playerid, COLOR_GRAD2, " You don't have a laptop.");
      return 1;
     }
   }//not connected
   return 1;
  }
this should work
new accountname = strlen(tmp);
if(accountname < 3 || accountname > 10) { SendClientMessage(playerid, COLOR_GRAD2, " Your name MUST have 3 words and not more than 10 !"); return 1; }

strlen counts the letters of tmp(the name) and saves it to account name
then u check if its smaller than 3letters or bigger than 10
^^

PS: u spelled more wrong u spelled it ore :P
Reply
#9

OK I Understand but 2 problems.
1.
He don't show me the Name and Password, at /email

2.
/emailc don#t Work, he say, incorrect Name

[pwn] if(strcmp(cmd, "/emailc", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pLaptop] == 1)
{
if(PlayerInfo[playerid][pAccountMail] == 1)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /emailc [accountname] [password]");
return 1;
}
new getaccountname = strval(tmp);
if(getaccountname != PlayerInfo[playerid][pAccountMailName]) { SendClientMessage(playerid, COLOR_GRAD2, " Incorrect Account Name."); return 1; }
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /emailc [accountname] [password]");
return 1;
}
new getpassword = strval(tmp);
if(getpassword != PlayerInfo[playerid][pAccountMailPass]) { SendClientMessage(playerid, COLOR_GRAD2, " Incorrect Password."); return 1; }
SendClientMessage(playerid, COLOR_YELLOW, "Connection to your account is now started...");
SetTimerEx("EmailConnect", 5000, false, "i", playerid);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "You don't have an E-mail Account.");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "You don't have a laptop.");
return 1;
}
}//not connected
return 1;
}[/pwn]
Reply
#10

Use pastebin dude and if you do post code then atleast use the pawn tags ([ pawn ] and [/ pawn ] with no spaces).
Reply
#11

Quote:
Originally Posted by Bl4ckDice
OK I Understand but 2 problems.
1.
He don't show me the Name and Password, at /email

2.
/emailc don#t Work, he say, incorrect Name

pawn Код:
if(strcmp(cmd, "/emailc", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pLaptop] == 1)
            {
              if(PlayerInfo[playerid][pAccountMail] == 1)
              {
                tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /emailc [accountname] [password]");
                        return 1;
                    }
                    new getaccountname = strval(tmp);
                    if(getaccountname != PlayerInfo[playerid][pAccountMailName]) { SendClientMessage(playerid, COLOR_GRAD2, "  Incorrect Account Name."); return 1; }
                    tmp = strtok(cmdtext, idx);
                    if(!strlen(tmp))
                    {
                        SendClientMessage(playerid, COLOR_WHITE, "USAGE: /emailc [accountname] [password]");
                        return 1;
                    }
                    new getpassword = strval(tmp);
                    if(getpassword != PlayerInfo[playerid][pAccountMailPass]) { SendClientMessage(playerid, COLOR_GRAD2, "  Incorrect Password."); return 1; }
                    SendClientMessage(playerid, COLOR_YELLOW, "Connection to your account is now started...");
                    SetTimerEx("EmailConnect", 5000, false, "i", playerid);
                    return 1;
                }
                else
                {
                  SendClientMessage(playerid, COLOR_GRAD2, "You don't have an E-mail Account.");
                  return 1;
            }
        }
        else
        {
          SendClientMessage(playerid, COLOR_GRAD2, "You don't have a laptop.");
          return 1;
        }
    }//not connected
    return 1;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)