Getting a string - dini -
Battlezone - 25.03.2014
First of all, i have put this at the beginning of the GM
pawn Код:
enum pInfo
{
Team,
Skin,
soldier[8],
}
new PlayerInfo[MAX_PLAYERS][pInfo];
Remark :
*I want to keep soldier info as a string.
*If the player is soldier the string will be "Soldier" and if he's not the string will be "" )
As am getting the string from the player account file, i made this On Player Connect:
pawn Код:
PlayerInfo[playerid][soldier] = dini_Get(file, "Soldier");
But i get this error:
Код:
C:\Users\SEIF\Desktop\samp03z_svr_R1_win32\gamemodes\WarZ.pwn(576) : 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.
I tried increasing the soldier[9] to soldier[15] (and more) but still the same problem.
Any help?
SOLVED:
pawn Код:
strcpy(PlayerInfo[playerid][soldier], dini_Get(file, "Soldier"), 8);
pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
Re: Getting a string - dini -
Konstantinos - 25.03.2014
suicider? Shouldn't it be
soldier?
pawn Код:
strcpy(PlayerInfo[playerid][soldier], dini_Get(file, "Soldier"), 8);
pawn Код:
#define strcpy(%0,%1,%2) strcat((%0[0] = '\0', %0), %1, %2)
Re: Getting a string - dini -
Battlezone - 25.03.2014
It is a typing error ,I pasted the wrong code, edited*
Any help?
EDIT: can you explain that code, please?
Re: Getting a string - dini -
Konstantinos - 25.03.2014
Sure. We copy a string to another: the string saved in "Soldier" from dini to the variable PlayerInfo[playerid][soldier]. The 8 is the max length.
Keep it in mind as: strcpy(copy_to[], copy_from[], max_lenght);
In other words, it's like doing:
pawn Код:
format(PlayerInfo[playerid][soldier], 8, dini_Get(file, "Soldier"));
// OR:
format(PlayerInfo[playerid][soldier], 8, "%s", dini_Get(file, "Soldier"));
but in a slower way (yes, format is slower than strcat, memcpy or strmid for copying strings).
Re: Getting a string - dini -
Battlezone - 25.03.2014
Thanks
+1 rep
problem solved.