Wrong strval -
Justsmile - 08.09.2009
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;
}
Re: Wrong strval -
Nero_3D - 09.09.2009
strval gets a number out of a string, you wanted to use strlen which gets the length of a string
-->
strval
-->
strlen
Re: Wrong strval -
Justsmile - 09.09.2009
Yes, but i don't know how to do it, an example will do it. please
Re: Wrong strval - Zeex - 09.09.2009
Did you bothered to click that link he posted? The example is there.
Re: Wrong strval -
Justsmile - 09.09.2009
Yes, but with if(strlen < 3 || strlen > 10) dfont work
Re: Wrong strval -
saiberfun - 09.09.2009
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?
Re: Wrong strval -
Justsmile - 09.09.2009
Pls more exactly, would be great. Because i have to save it.
Re: Wrong strval -
saiberfun - 09.09.2009
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
Re: Wrong strval -
Justsmile - 09.09.2009
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]
Re: Wrong strval -
Donny_k - 09.09.2009
Use pastebin dude and if you do post code then atleast use the pawn tags ([ pawn ] and [/ pawn ] with no spaces).
Re: Wrong strval -
Justsmile - 09.09.2009
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; }
|