PDA

View Full Version : Small connecting message bug.


[WA]iRonan
08/12/2013, 04:15 PM
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.

David (Sabljak)
08/12/2013, 04:19 PM
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);
}

[WA]iRonan
08/12/2013, 04:28 PM
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"

Wizzy951
08/12/2013, 04:29 PM
Edit: what if you replace all of the if's (except first one) and put else if in replacement ?

[WA]iRonan
08/12/2013, 04:34 PM
It's weird, but I think that you need to remove the "!" operators. So it will look like:

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.

David (Sabljak)
08/12/2013, 04:48 PM
iRonan;2811301']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;
}


...

[WA]iRonan
08/12/2013, 04:50 PM
Then do this

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


...

Thank you. :)