PDA

View Full Version : strcmp problem


3417512908
15/07/2018, 04:12 AM
I want to check if player is created a room:
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid,playername,MAX_PLAYER_NAME) ;

if(strcmp(RoomInfo[i][Owner],playername)!=0)
{
Dialog(playerid,999,DIALOG_STYLE_MSGBOX,"{ff0000}警告","{ff0000}你已经创建了一个房间","Okay","");
break;
}
//not work :(

On create
GetPlayerName(playerid, RoomInfo[i][Owner], MAX_PLAYER_NAME);
enum
enum rInfo
{
bool:IsCreated,
Owner[MAX_PLAYER_NAME],
RoomID,
World,
Name[22],
Weapon1,
Weapon2,
Map,
Players

}

3417512908
15/07/2018, 04:14 AM
Players still can create another room.Even if they created one.:(

coool
15/07/2018, 06:18 AM
strcmp will return '0', if the strings are equal. In the above case:
if(strcmp(RoomInfo[i][Owner],playername)==0)//player name and 'RoomInfo[i][Owner]' match
Maybe I can be wrong because I don't understand the dialog.

SytonicX
15/07/2018, 11:51 AM
Don't use " != 0 " because it might not get it as a compiler sometimes, I might sound as a retard but it happens a lot of times with me specially while using other programming languages as C++ etc.
Use " == 0 " or " == 1 " and I believe if you used the following it might work smoothly.

if(strcmp(RoomInfo[i][Owner],playername)==0)