error 047: array sizes do not match,
#1

Hello guys, so i've been adding features to WSF....

after i have finished updating i have to compile and when i did i got this gift:
PHP код:
C:\Users\Admin\Desktop\[GameMode]World Stunt Freeroam v0.5\gamemodes\WSF.pwn(388) : error 047: array sizes do not match, or destination array is too small 
Here's the code:
PHP код:
         format(stringsizeof(string), "%s"GetName(playerid));
388>>    duelinfo[playerid][playername] = string
tried to fix it using samp wikia but didn't got a resolution.
Reply
#2

pawn Код:
format(duelinfo[playerid][playername], MAX_PLAYER_NAME + 1, "%s", GetName(playerid));
Reply
#3

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
format(duelinfo[playerid][playername], MAX_PLAYER_NAME + 1, "%s", GetName(playerid));
Thanks Mr.SickAttack
Reply
#4

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
pawn Код:
format(duelinfo[playerid][playername], MAX_PLAYER_NAME + 1, "%s", GetName(playerid));
strcpy is better to copy strings than using format.
pawn Код:
strcat((duelinfo[playerid][playername][0] = '\0', duelinfo[playerid][playername]), GetName(playerid), MAX_PLAYER_NAME + 1);
Reply
#5

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
strcpy is better to copy strings than using format.
pawn Код:
strcat((duelinfo[playerid][playername][0] = '\0', duelinfo[playerid][playername]), GetName(playerid), MAX_PLAYER_NAME + 1);
Since this is not a roleplay server and if you're aiming for performance. It's better to use GetPlayerName directly with the array as an argument.

Or even better, store the player's name in an array or a variable when they connect and just use that array or variable.
Reply
#6

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
Since this is not a roleplay server and if you're aiming for performance. It's better to use GetPlayerName directly with the array as an argument.

Or even better, store the player's name in an array or a variable when they connect and just use that array or variable.
What's is with type of a gamemode and performance anyway? When it comes to programming or scripting, I'd always try to write better codes. Of course, it's better to store player name on an array upon their connection. What I've stated here is that it's better to use strcat/strcpy to copy strings.
Reply
#7

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
What's is with type of a gamemode and performance anyway? When it comes to programming or scripting, I'd always try to write better codes. Of course, it's better to store player name on an array upon their connection. What I've stated here is that it's better to use strcat/strcpy to copy strings.
You should have suggested using GetPlayerName dirrectly or saving the player's name in an array upon connecting then.

I only mentioned roleplay and stated if you care about performance rather than just wanting something to work because roleplay servers often remove underscores or whatever, and that makes using GetPlayerName directly not an option as no-one would want to place code to remove the underscore everytime they want to retrieve a player's name.
Reply
#8

I'm just saying that you should have suggested saving the player's name upon connecting if you always try to write better code.

I know about strcpy, but everyone has their own way of doing things, thread author uses format; therefore, I showed him how to do it with format.

It's his deal whether he wants to write better code or not. But it's not like the performance difference would actually make any noticeable difference. This is something he or anyone else shouldn't be really worried about.
Reply
#9

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
I'm just saying that you should have suggested saving the player's name upon connecting if you always try to write better code.

I know about strcpy, but everyone has their own way of doing things, thread author uses format; therefore, I showed him how to do it with format.

It's his deal whether he wants to write better code or not. But it's not like the performance difference would actually make any noticeable difference. This is something he or anyone else shouldn't be really worried about.
You're still not getting it. My first reply was never about player names as the OP's problem was solved already. I suggested strcpy since that could be a better practice in copying strings than using format.

If we're talking about the player name - Even that array which is used to store player name on duelinfo can be unnecessary. Because if an array is chosen to have the player's name upon connection, it can be simply returned to get the player's name wherever necessary since such an array would require change only while changing names.

I'm just concluding once again that my first post wasn't about player name, it was a suggestion to use strcpy for copying strings. You may have used format since the OP used it, though it was never meant to state that you didn't know about strcpy.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)