strlen(inputtext) - 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)
+--- Thread: strlen(inputtext) (
/showthread.php?tid=578234)
strlen(inputtext) -
SukMathcuck - 17.06.2015
Hello! I have a big problem, I'm setting something easy, and is giving error ..
Код:
C:\Users\2\Desktop\gamemode\gamemodes\2.pwn(23907) : error 047: array sizes do not match, or destination array is too small
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Error.
is something standard, and I can not change, I've tried to put anyway ..
PHP код:
PlayerInfo[playerid][pKey] = tmppass;
///
PlayerInfo[playerid][pKey] = strlen(inputtext);
PHP код:
if (strlen(inputtext))
{
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
Encrypt(tmppass);
PlayerInfo[playerid][pKey] = tmppass; //error
SendClientMessage(playerid, -1, "<!> Password changed successfully.");
}
PHP код:
public Encrypt(string[])
{
for(new x=0; x < strlen(string); x++)
{
string[x] += (3^x) * (x % 15);
if(string[x] > (0xff))
{
string[x] -= 256;
}
}
return 1;
}
Re: strlen(inputtext) -
J0sh... - 17.06.2015
PHP код:
format(PlayerInfo[playerid][pKey], sizeof(PlayerInfo[playerid][pKey], "%s", temppass);
Not tested.
Re: strlen(inputtext) -
Azula - 17.06.2015
PHP код:
format( PlayerInfo[playerid][pKey], 128, "%s", tmppass);
edit : late
Re: strlen(inputtext) -
AndySedeyn - 17.06.2015
You forgot a bracket at the end of the sizeof function, Jamester.
PHP код:
format(PlayerInfo[playerid][pKey], sizeof(PlayerInfo[playerid][pKey]), "%s", temppass);
Nevertheless, strlen does not return the string. It returns the length of a string as an integer value. The function 'strlen' literally stands for : 'StringLength'.
https://sampwiki.blast.hk/wiki/Strlen
Re: strlen(inputtext) -
Misiur - 17.06.2015
Sizeof will be equal to 1 for 2d arrays unless using Zeex's compiler. Also, do not use format in case you have a single value to copy (single %s, %d, or %f)
For strings:
In case you don't have it:
pawn Код:
#define strcpy(%0,%1) strcat((%0[0] = EOS, %0),%1)
Then use it like
pawn Код:
strcpy(PlayerInfo[playerid][pKey], temppass, 128);
For ints:
https://sampwiki.blast.hk/wiki/Valstr
For floats:
https://sampwiki.blast.hk/wiki/Floatstr
Re: strlen(inputtext) -
SukMathcuck - 17.06.2015
I did so, it becomes simple, what do you think? will use numbers and letters .. up!
PHP код:
if (strlen(inputtext))
{
strcpy(PlayerInfo[playerid][pKey], inputtext, 128);
}
please..