Small connecting message bug.
#1

I want to add a special connecting message for our scripters, but I am having a problem.
My server crashes when I connect with iRonan, and this one has a special message. Also happens with a competely random name.

Code:
Код:
    new pName[MAX_PLAYER_NAME];
    for (new i = GetMaxPlayers(), j; j < i; i++)
    {
        GetPlayerName(i, pName, sizeof (pName));
        if (!strcmp(pName, "iRonan", true))
        {
			SendClientMessage(playerid, COLOR_GREY, "{00FFFF}iRonan{FFFFFF} has connected: IG-DM Developer");
        }
        if (!strcmp(pName, "Mabee", true))
        {
            SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Mabee{FFFFFF} has connected: IG-DM Developer");
		}
        if (!strcmp(pName, "lag.cs", true))
        {
            SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Lag.cs{FFFFFF} has connected: IG-DM Tester");
		}
        if (!strcmp(pName, "chazrp", true))
        {
            SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Chazrp{FFFFFF} has connected: IG-DM Tester");
		}
        else
        {
			    new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
			    GetPlayerName(playerid, name, sizeof(name));
	            format(string, sizeof(string), "{00FFFF}%s{FFFFFF} has joined.", name);
    			SendClientMessageToAll(COLOR_GREY, string);
        }
    }
This is placed under OnPlayerConnect.

Whoever helps me, thanks. I'll hand you a REP.
Reply
#2

Try this, replace all

Код:
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof (pName));
if(!strcmp(pName, "iRonan", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}iRonan{FFFFFF} has connected: IG-DM Developer");
}
if(!strcmp(pName, "Mabee", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Mabee{FFFFFF} has connected: IG-DM Developer");
}
if(!strcmp(pName, "lag.cs", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Lag.cs{FFFFFF} has connected: IG-DM Tester");
}
if(!strcmp(pName, "chazrp", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Chazrp{FFFFFF} has connected: IG-DM Tester");
}
else
{
	new string[64];
	format(string, sizeof(string), "{00FFFF}%s{FFFFFF} has joined.", pName);
	SendClientMessageToAll(COLOR_GREY, string);
}
Reply
#3

Quote:
Originally Posted by David (Sabljak)
Посмотреть сообщение
Try this, replace all

Код:
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof (pName));
if(!strcmp(pName, "iRonan", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}iRonan{FFFFFF} has connected: IG-DM Developer");
}
if(!strcmp(pName, "Mabee", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Mabee{FFFFFF} has connected: IG-DM Developer");
}
if(!strcmp(pName, "lag.cs", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Lag.cs{FFFFFF} has connected: IG-DM Tester");
}
if(!strcmp(pName, "chazrp", true))
{
	SendClientMessage(playerid, COLOR_GREY, "{00FFFF}Chazrp{FFFFFF} has connected: IG-DM Tester");
}
else
{
	new string[64];
	format(string, sizeof(string), "{00FFFF}%s{FFFFFF} has joined.", pName);
	SendClientMessageToAll(COLOR_GREY, string);
}
IT works, but it sends 2 messages, not only "DeveloperName has connected: IG-DM Developer" but also says "DeveloperName has joined"
Reply
#4

Edit: what if you replace all of the if's (except first one) and put else if in replacement ?
Reply
#5

Quote:
Originally Posted by Wizzy951
Посмотреть сообщение
It's weird, but I think that you need to remove the "!" operators. So it will look like:
pawn Код:
if (strcmp(pName, "iRonan", true))
Accidently gave you a free rep but who cares.

It doesn't work, when I remove the !'s and connect, it shows all the functions. Chazrp, Lag.cs, Mabee and iRonan.
Reply
#6

Quote:
Originally Posted by [WA]iRonan
Посмотреть сообщение
IT works, but it sends 2 messages, not only "DeveloperName has connected: IG-DM Developer" but also says "DeveloperName has joined"
Then do this

if(!strcmp(pName, "iRonan", true))
{
SendClientMessage(playerid, COLOR_GREY, "{00FFFF}iRonan{FFFFFF} has connected: IG-DM Developer");
return 1;
}


...
Reply
#7

Quote:
Originally Posted by David (Sabljak)
Посмотреть сообщение
Then do this

if(!strcmp(pName, "iRonan", true))
{
SendClientMessage(playerid, COLOR_GREY, "{00FFFF}iRonan{FFFFFF} has connected: IG-DM Developer");
return 1;
}


...
Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)