strlen(inputtext)
#1

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(tmppassinputtext0strlen(inputtext), 255);
            
Encrypt(tmppass);
            
PlayerInfo[playerid][pKey] = tmppass//error
            
SendClientMessage(playerid, -1"<!> Password changed successfully.");
        } 
PHP код:
public Encrypt(string[])
{
    for(new 
x=0strlen(string); x++)
      {
          
string[x] += (3^x) * (15);
          if(
string[x] > (0xff))
          {
              
string[x] -= 256;
          }
      }
    return 
1;

Reply
#2

PHP код:
format(PlayerInfo[playerid][pKey], sizeof(PlayerInfo[playerid][pKey], "%s"temppass); 
Not tested.
Reply
#3

PHP код:
format(  PlayerInfo[playerid][pKey], 128"%s"tmppass); 
edit : late
Reply
#4

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
Reply
#5

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
Reply
#6

I did so, it becomes simple, what do you think? will use numbers and letters .. up!

PHP код:
        if (strlen(inputtext))
        {
            
strcpy(PlayerInfo[playerid][pKey], inputtext128);
        } 
please..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)