OnPlayerConnect Problem... - Unknown123 - 06.03.2011
pawn Код:
public OnPlayerConnect(playerid)
{
if(IsPlayerBanned(playerid))
{
Kick(playerid); //I tried to kick him before he get that message, Dident work...
}
else
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerAdmin(i) || PlayerData[i][AdminLevel] > 1)
{
print("[DEBUG]: Joined");
format(string,sizeof string,"%s(%d) Has joined %s (IP: %s)", PlayerName(playerid), playerid, SERVER_NAME, PlayerIP(playerid));
SendClientMessageToAdmins(COLOR_GREY, string);
return 1;
}
else
{
print("[DEBUG]: Joined");
format(string,sizeof string,"%s(%d) Has joined %s", PlayerName(playerid), playerid, SERVER_NAME);
SendClientMessageToAll(COLOR_GREY, string);
return 1;
}
}
return 1;
}
return 1;
}
stock IsPlayerBanned(playerid)
{
new queue[128];
format(queue, sizeof(queue), "SELECT * FROM `PlayerBans` WHERE IP= '%s'", PlayerIP(playerid));
mysql_query(queue);
mysql_store_result();
if(mysql_num_rows())
{
mysql_free_result();
return 1;
}
mysql_free_result();
return 0;
}
/*
The problem is:
If a banned player try connect, then i get a message like this
" (1) Has joined <MyServer>"
But i want it to if a banned player try to connect, it should dont appear any text
*/
Re: OnPlayerConnect Problem... -
grand.Theft.Otto - 06.03.2011
I think its because you have a double code for when the player joins the server, it only needs one I'm sure
Re: OnPlayerConnect Problem... -
admantis - 06.03.2011
When the player is banned, RETURN a kick, not just kick him.
Re: OnPlayerConnect Problem... - Unknown123 - 06.03.2011
Quote:
Originally Posted by admantis
When the player is banned, RETURN a kick, not just kick him.
|
You mean like this? :S
pawn Код:
if(IsPlayerBanned(playerid))
{
return Kick(playerid);
}
Re: OnPlayerConnect Problem... -
Marricio - 06.03.2011
Yeah, he means that
Re: OnPlayerConnect Problem... -
admantis - 06.03.2011
Yes I do.
Re: OnPlayerConnect Problem... - Unknown123 - 06.03.2011
Quote:
Originally Posted by Marricio
Yeah, he means that
|
Ok, Then i have to tell him that it is not working, I did it like this...
pawn Код:
if(IsPlayerBanned(playerid))
{
return Kick(playerid);
}
else
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerAdmin(i) || PlayerData[i][AdminLevel] > 1)
{
print("Joined");
format(string,sizeof string,"%s(%d) Has joined %s (IP: %s)", PlayerName(playerid), playerid, SERVER_NAME, PlayerIP(playerid));
SendClientMessageToAdmins(COLOR_GREY, string);
return 1;
}
else
{
print("Joined");
format(string,sizeof string,"%s(%d) Has joined %s", PlayerName(playerid), playerid, SERVER_NAME);
SendClientMessageToAll(COLOR_GREY, string);
return 1;
}
}
return 1;
}
}
Looks like the "IsPlayerBanned" is not working =/
Re: OnPlayerConnect Problem... -
admantis - 06.03.2011
What is not working? It did no effect?
Re: OnPlayerConnect Problem... - Unknown123 - 06.03.2011
Quote:
Originally Posted by admantis
What is not working? It did no effect?
|
No effect...
Edit: I added a debug...
pawn Код:
public OnPlayerConnect(playerid)
{
//MySQL stuff here...
if(IsPlayerBanned(playerid))
{
return Kick(playerid);
}
else
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerAdmin(i) || PlayerData[i][AdminLevel] > 1)
{
printf("[DEBUG] %s Joined", PlayerName(i));
format(string,sizeof string,"%s(%d) Has joined %s (IP: %s)", PlayerName(playerid), playerid, SERVER_NAME, PlayerIP(playerid));
SendClientMessageToAdmins(COLOR_GREY, string);
return 1;
}
else
{
printf("[DEBUG] %s Joined", PlayerName(i));
format(string,sizeof string,"%s(%d) Has joined %s", PlayerName(playerid), playerid, SERVER_NAME);
SendClientMessageToAll(COLOR_GREY, string);
return 1;
}
}
return 1;
}
return 1;
}
This got printed:
Код:
A banned player connect:
[02:59:06] Incoming connection: 5.229.94.154:51132
[02:59:06] [join] Unknown123 has joined the server (0:5.229.94.154)
[02:59:06] [part] Unknown123 has left the server (0:2)
[02:59:06] [DEBUG] Joined
A player who is not banned connect:
[02:59:06] Incoming connection: 5.229.94.154:51132
[02:59:06] [join] Unknown123 has joined the server (0:5.229.94.154)
[02:59:06] [part] Unknown123 has left the server (0:2)
[02:59:06] [DEBUG] Unknown123 Joined
Re: OnPlayerConnect Problem... -
admantis - 06.03.2011
I just noticed you're also doing a useless loop.This should work.
pawn Код:
if(IsPlayerBanned(playerid))
{
return Kick(playerid);
}
else
{
for(new i;i<MAX_PLAYERS;i++)
{
if(IsPlayerAdmin(i) || PlayerData[i][AdminLevel] > 1)
{
if (!IsPlayerBanned(playerid))
{
print("Joined");
format(string,sizeof string,"%s(%d) Has joined %s (IP: %s)", PlayerName(playerid), playerid, SERVER_NAME, PlayerIP(playerid));
SendClientMessageToAdmins(COLOR_GREY, string);
return 1;
}
}
}
if (!IsPlayerBanned(playerid))
{
print("Joined");
format(string,sizeof string,"%s(%d) Has joined %s", PlayerName(playerid), playerid, SERVER_NAME);
SendClientMessageToAll(COLOR_GREY, string);
return 1;
}
}
return 1;
}