SA-MP Forums Archive
A problem when connect to the server. - 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: A problem when connect to the server. (/showthread.php?tid=512001)



A problem when connect to the server. - Gennum. - 08.05.2014

hello .
I have noticed that there's a new version [0.3z]
and I wanted to update my mode to this verison but when I have updated it I found a problem in the connection to game. just wanted to let you know I didn't touch the mode for something like a half year!.
When I'm connecting to the server after I ran the samp_server, I get server closed the connection.

Joining the game...
and then Server closed the connection...

Код:
public OnPlayerConnect(playerid)
{
print("POLO 1");
//if(IsPlayerNPC(playerid)) return SpawnPlayer(playerid);
if(!IsPlayerNPC(playerid))
{
	if(strfind(PlayerName[playerid],"_",true) == -1) return SendClientMessage(playerid,color_error, "ERROR: Your name must be in the format Firstname_Lastname."),Kick(playerid);
}
new string[512], n[MAX_PLAYER_NAME];
SetPlayerColor(playerid,0xC9C9C900);
GetPlayerName(playerid,n,sizeof(n));
format(string, sizeof(string), "** %s has joined the server. ", n);
SendNormalMessage(30,playerid,color_text,string);
format(string, sizeof(string), "%s(%d) has joined the server",n,playerid);
WriteLog("Connects",string);
SetPlayerWeather(playerid,10);
new playername[MAX_PLAYER_NAME],IP[32];
GetPlayerIp(playerid,IP,32);
GetPlayerSpaceName(playerid,playername,MAX_PLAYER_NAME);
format(PlayerName[playerid],MAX_PLAYER_NAME,"%s",playername);
firstlog[playerid] = false;
logged[playerid] = false;
Query("SELECT `ID` FROM `%s` WHERE `Name`='%s' AND `Active`='1' OR `IP`='%s' AND `Active`='1'", BanT, playername,IP);
new num = mysql_num_rows();
print("POLO 2");
if(num >= 1 && num <= 50)
{
	new Result[30],i;
	mysql_fetch_row(Result);
	i = strval(Result);
    SendClientMessage(playerid,color_red,"[SERVER]: You are banned from our server.");
    set(string,"* Reason: %s.",mysql_Get(BanT,i,"Reason"));
    SendClientMessage(playerid,color_red,string);
    set(string,"* Date: %s.",mysql_Get(BanT,i,"Time"));
    SendClientMessage(playerid,color_red,string);
    Kick(playerid);
    return 1;
}
print("POLO 3");
Query("SELECT `ID` FROM `%s` WHERE `Name`='%s'", UserT, playername);
if(mysql_num_rows())
{
	new Result[30];
	mysql_fetch_row(Result);
	TID[playerid] = strval(Result);
	return 1;
}
print("POLO 4");
return 1;
}



Re: A problem when connect to the server. - Konstantinos - 08.05.2014

You kick the player for not having underscore to his name and if the player is banned. You need to use a timer to kick the player so he'll be able to see the messages/dialogs etc.

An example (The last one at the bottom of the page) is on the wiki: https://sampwiki.blast.hk/wiki/Kick


Re: A problem when connect to the server. - Gennum. - 08.05.2014

I did a timer like you said but it's not the problem, I still get server closed the connection in the connect..


Re: A problem when connect to the server. - Konstantinos - 08.05.2014

That wasn't my point. I told you not to use directly the Kick function because the player will not get any message before getting kicked. After fixing that, you'll get the message of why you got kicked.


Re: A problem when connect to the server. - Gennum. - 08.05.2014

Okay I got it , but I get a disconnected without any reason and in past it's didnot happen to me,
maybe there's something that I should add because the new version of samp ?


Re: A problem when connect to the server. - BroZeus - 08.05.2014

if(strfind(PlayerName[playerid],"_",true) == -1) return SendClientMessage(playerid,color_error, "ERROR: Your name must be in the format Firstname_Lastname."),Kick(playerid);
change this line to
pawn Код:
if(strfind(PlayerName[playerid],"_",true) == -1)
{
SendClientMessage(playerid,color_error, "ERROR: Your name must be in the format Firstname_Lastname.");
SetTimerEx("DelayedKick", 1000, false, "d", playerid);
return 1;
}



Re: A problem when connect to the server. - Gennum. - 08.05.2014

Oh that's was the problem !
Man even when I enter the game with a correct name FDFDF_DFDF it's give a kick.
Can you help me with that's "new" problem :P