I can`t save player name to enum
#1

Please help me to looking for wrong
ENUM:
Код:
enum rInfo
{
	bool:IsCreated,
	Owner[MAX_PLAYER_NAME],
	RoomID,
	World,
	Name[22],
	Weapon1,
	Weapon2,
	Map

}
CODE
Код:
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
RoomInfo[i][Owner]=pName;
And then I want to show for player.But owner is blank:
Код:
new pDialog[2100],format1[40];
format(format1, sizeof(format1), "[ID%d]\t%s\t%s\n",RoomInfo[i][RoomID],RoomInfo[i][Name],RoomInfo[i][Owner]);
strcat(pDialog, format1, sizeof(format1));
Reply
#2

Why didn't you put i instead of playerid in GetPlayerName?
Reply
#3

You can directly store it into the array:

Код:
GetPlayerName(playerid, RoomInfo[i][Owner], MAX_PLAYER_NAME);
Furthermore the strcat line at the end is not quite correct.
You append to the pDialog array, however pass the size of the format1 array (pDialog is 2100 cells, format1 is 40 so the strcat only writes to the 40th index of pDialog).
It needs to be:

Код:
strcat(pDialog, format1, sizeof(pDialog));
Or just leave away the last argument as it does that automatically.


Quote:
Originally Posted by Mike861
Посмотреть сообщение
Why didn't you put i instead of playerid in GetPlayerName?
i is the index for the RoomInfo array, not a playerid.
Reply
#4

Note: with arrays you can't just equal one to another that only works with integars and floats you will have to use strcat or a use define function to do it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)