SA-MP Forums Archive
Small connecting message bug. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Small connecting message bug. (/showthread.php?tid=480033)



Small connecting message bug. - [WA]iRonan - 08.12.2013

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.


Re: Small connecting message bug. - David (Sabljak) - 08.12.2013

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);
}



Re: Small connecting message bug. - [WA]iRonan - 08.12.2013

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"


Re: Small connecting message bug. - Wizzy951 - 08.12.2013

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


Re: Small connecting message bug. - [WA]iRonan - 08.12.2013

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.


Re: Small connecting message bug. - David (Sabljak) - 08.12.2013

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;
}


...


Re: Small connecting message bug. - [WA]iRonan - 08.12.2013

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.