[help] Server Crash without any errors :S
#1

Hello. On my script that is using mysql. Somtimes when i connect it crashes the server without any warnings on the log at all (not even saying "server shutting down...") and it doesnt say "server closed connection"...

This is the onpalyerconnect, and all the code attached to it.

Код:
public OnPlayerConnect(playerid)
{
	ExpTextdraw[playerid] = TextDrawCreate(302.000000,139.000000,"+1");
	TextDrawAlignment(ExpTextdraw[playerid],0);
	TextDrawBackgroundColor(ExpTextdraw[playerid],0xffffffff);
	TextDrawFont(ExpTextdraw[playerid],3);
	TextDrawLetterSize(ExpTextdraw[playerid],1.000000,2.399999);
	TextDrawColor(ExpTextdraw[playerid],0xff0000ff);
	TextDrawSetOutline(ExpTextdraw[playerid],1);
	TextDrawSetProportional(ExpTextdraw[playerid],1);
	TextDrawSetShadow(ExpTextdraw[playerid],5);

	TextDrawHideForPlayer(playerid,ExpTextdraw[playerid]);
  //----------==========Reset Variables==========----------
	Team[playerid] = 99;
	PlayerLogged[playerid] = 0;
	
	PlayerStats[playerid][pId] = 0;
	PlayerStats[playerid][pUser] = 0;
	PlayerStats[playerid][pPass] = 0;
	PlayerStats[playerid][pAdmin] = 0;
	PlayerStats[playerid][pKills] = 0;
	PlayerStats[playerid][pDeaths] = 0;
	PlayerStats[playerid][pMoney] = 0;
	
	//----------==========Welcome Message==========----------
	new playerName[MAX_PLAYER_NAME];
	new String[258];
	GetPlayerName(playerid, playerName, sizeof(playerName));
	SendClientMessage(playerid,COLOR_RED,"|_*---------------------------------------------------*_|");
	format(String,sizeof(String),"Welcome to San Andreas Warfare, %s",playerName);
	SendClientMessage(playerid,COLOR_GREEN,String);
	SendClientMessage(playerid,COLOR_RED,"|_*---------------------------------------------------*_|");
	return 1;
}
Код:
public OnPlayerRequestClass(playerid, classid)
{
	if(playerExist(playerid) == 0){
  ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please Register(Optional).", "Password:", "Register", "Cancel");
	}else{
	if(PlayerLogged[playerid] == 0){
		ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please Login.", "Password:", "Login", "Cancel");
	}
	}
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	
	//----------==========Text For Player With Classes==========----------
	setPlayerTeam(playerid, classid);
	new String[258];
	if(classid == 0){//US
  format(String, sizeof(String), "~b~United States Of ~r~America");
  GameTextForPlayer(playerid, String, 3000, 4);
	}else if(classid == 1){//British
 	format(String, sizeof(String), "~r~British Royal Marine");
  GameTextForPlayer(playerid, String, 3000, 4);
	}else if(classid == 2){//Chinese
 	format(String, sizeof(String), "~y~Chinese Army");
  GameTextForPlayer(playerid, String, 3000, 4);
	}else if(classid == 3){//Russian
 	format(String, sizeof(String), "~p~The ~r~Red ~p~Army (Russian)");
  GameTextForPlayer(playerid, String, 3000, 4);
	}
	
	return 1;
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
 	if(dialogid == 1){
	  if(response == 1){
	  PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
		Encrypt(inputtext);
		onPlayerRegister(playerid,inputtext);
		}
	}else if(dialogid == 2){
	  if(response == 1){
	  PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
		Encrypt(inputtext);
		onPlayerLogin(playerid,inputtext);
		}
	}else if(dialogid == 3){
	  if(response == 1){
	    if(listitem == 0){ //Shotgun
	    if(PlayerStats[playerid][pMoney] < 500) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($500)");
	    GivePlayerWeapon(playerid,25,250);
	    givePlayerMoney(playerid, -500);
	    SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought a Shotgun!");
	    }else if(listitem == 1){ //spas12
     	if(PlayerStats[playerid][pMoney] < 1000) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($1000)");
			GivePlayerWeapon(playerid,27,250);
			givePlayerMoney(playerid, -1000);
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought a Spas12!");
	    }else if(listitem == 2){ //ak47
     	if(PlayerStats[playerid][pMoney] < 3000) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($3000)");
			GivePlayerWeapon(playerid,30,250);
			givePlayerMoney(playerid, -3000);
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought a Ak47!");
	    }else if(listitem == 3){ //m4
     	if(PlayerStats[playerid][pMoney] < 3500) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($3500)");
			GivePlayerWeapon(playerid,31,250);
			givePlayerMoney(playerid, -3500);
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought a M4!");
	    }else if(listitem == 4){ //Uzi
	    if(PlayerStats[playerid][pMoney] < 2000) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($2000)");
			GivePlayerWeapon(playerid,28,250);
			givePlayerMoney(playerid, -2000);
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought a Uzi!");
	    }else if(listitem == 5){ //Sawn off
	    if(PlayerStats[playerid][pMoney] < 1500) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($1500)");
			GivePlayerWeapon(playerid,26,250);
			givePlayerMoney(playerid, -1500);
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought a Sawn off Shotgun!");
	    }else if(listitem == 6){ //Grenade
	    if(PlayerStats[playerid][pMoney] < 1000) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($1000)");
			GivePlayerWeapon(playerid,16,10);
			givePlayerMoney(playerid, -1000);
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought 10 Grenades!");
	    }else if(listitem == 7){ //Molotov
	    if(PlayerStats[playerid][pMoney] < 1500) return SendClientMessage(playerid,COLOR_LIGHTRED,"*** You can not afford this ($1500)");
			GivePlayerWeapon(playerid,18,10);
			givePlayerMoney(playerid, -1500);
			SendClientMessage(playerid,COLOR_LIGHTBLUE,"You have bought 10 Molotovs'!");
	    }
		}
	}
	return 1;
}
Код:
public setPlayerTeam(playerid,team){
	Team[playerid] = team;
	//----------==========Set Player Color==========----------
	if(team == 0){ // US
		SetPlayerColor(playerid,COLOR_GREEN);
	}else if(team == 1){ // British
		SetPlayerColor(playerid,COLOR_DBLUE);
	}else if(team == 2){ // Chinese
		SetPlayerColor(playerid,COLOR_YELLOW);
	}else if(team == 3){ // Russian
		SetPlayerColor(playerid,COLOR_RED);
	}
	
	return 1;
}
-----

I was going to upload to pastebin, but this is easier for people to view the code like this because they are in different sections...Also if you need any other sections of code, just tell me please..

-Thanks
Reply
#2

at first point u should do this:
pawn Код:
ExpTextdraw[playerid] = TextDrawCreate(302.000000,139.000000,"+1");
    TextDrawAlignment(ExpTextdraw[playerid],0);
    TextDrawBackgroundColor(ExpTextdraw[playerid],0xffffffff);
    TextDrawFont(ExpTextdraw[playerid],3);
    TextDrawLetterSize(ExpTextdraw[playerid],1.000000,2.399999);
    TextDrawColor(ExpTextdraw[playerid],0xff0000ff);
    TextDrawSetOutline(ExpTextdraw[playerid],1);
    TextDrawSetProportional(ExpTextdraw[playerid],1);
    TextDrawSetShadow(ExpTextdraw[playerid],5);
in ongamemodeinit or filterscriptinit!!!!!!!
Reply
#3

Quote:
Originally Posted by gamer_Z
at first point u should do this:
pawn Код:
ExpTextdraw[playerid] = TextDrawCreate(302.000000,139.000000,"+1");
    TextDrawAlignment(ExpTextdraw[playerid],0);
    TextDrawBackgroundColor(ExpTextdraw[playerid],0xffffffff);
    TextDrawFont(ExpTextdraw[playerid],3);
    TextDrawLetterSize(ExpTextdraw[playerid],1.000000,2.399999);
    TextDrawColor(ExpTextdraw[playerid],0xff0000ff);
    TextDrawSetOutline(ExpTextdraw[playerid],1);
    TextDrawSetProportional(ExpTextdraw[playerid],1);
    TextDrawSetShadow(ExpTextdraw[playerid],5);
in ongamemodeinit or filterscriptinit!!!!!!!
how can i use a ExpTextDraw[playerid] with OnGameModeinit? lol
Reply
#4

pawn Код:
public OnGameModeInit(){
    for(new playerid; playerid < MAX_PLAYERS; playerid++){
        ExpTextdraw[playerid] = TextDrawCreate(302.000000,139.000000,"+1");
        TextDrawAlignment(ExpTextdraw[playerid],0);
        TextDrawBackgroundColor(ExpTextdraw[playerid],0xffffffff);
        TextDrawFont(ExpTextdraw[playerid],3);
        TextDrawLetterSize(ExpTextdraw[playerid],1.000000,2.399999);
        TextDrawColor(ExpTextdraw[playerid],0xff0000ff);
        TextDrawSetOutline(ExpTextdraw[playerid],1);
        TextDrawSetProportional(ExpTextdraw[playerid],1);
        TextDrawSetShadow(ExpTextdraw[playerid],5);
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by gamer_Z
pawn Код:
public OnGameModeInit(){
    for(new playerid; playerid < MAX_PLAYERS; playerid++){
        ExpTextdraw[playerid] = TextDrawCreate(302.000000,139.000000,"+1");
        TextDrawAlignment(ExpTextdraw[playerid],0);
        TextDrawBackgroundColor(ExpTextdraw[playerid],0xffffffff);
        TextDrawFont(ExpTextdraw[playerid],3);
        TextDrawLetterSize(ExpTextdraw[playerid],1.000000,2.399999);
        TextDrawColor(ExpTextdraw[playerid],0xff0000ff);
        TextDrawSetOutline(ExpTextdraw[playerid],1);
        TextDrawSetProportional(ExpTextdraw[playerid],1);
        TextDrawSetShadow(ExpTextdraw[playerid],5);
    }
    return 1;
}
Mhmm, that is first time someone said how to do it like that :S everyone on forums said to have it as onplayerconnect...

Do you think this is what is causing the server to crash without warnings/errors or anything?
Reply
#6

textdraws should be CREATED for every player at startup for speed, and only SHOW or HIDE in onplayerconnect and disconnect and other things.
and if you create twice the TD maybe it will crash..
Reply
#7

It is still crashing here is the login function, is there any problems in there?

Код:
public onPlayerLogin(playerid, password[]){
	new playerName[MAX_PLAYER_NAME];
	new result[258];
	new sqlPlayerName[258];
	new pass[258];
	new sqlPass[258]; // official pass
	new sqlPassword[258]; // password enterd
	GetPlayerName(playerid,playerName,sizeof(playerName)); //Get Player Name
	samp_mysql_real_escape_string(playerName, sqlPlayerName); //String for samp_mysql
	format(result,sizeof(result),"SELECT * FROM accounts WHERE user='%s'",sqlPlayerName); // Format my query
	samp_mysql_query(result);
	samp_mysql_store_result();
	samp_mysql_get_field("pass",pass);
	samp_mysql_real_escape_string(pass, sqlPass); //String for pass
	samp_mysql_real_escape_string(password, sqlPassword); //String for pass enterd

	if(strcmp(sqlPassword,sqlPass,true) == 0){
 		PlayerLogged[playerid] = 1;
		SendClientMessage(playerid,COLOR_GREEN,"**You have successfully Logged in!!");
		//----------==========Load accoutn info==========----------
		new LoadingString[128];
		samp_mysql_get_field("ID",LoadingString); //ID
	 	PlayerStats[playerid][pId] = strval(LoadingString);
		samp_mysql_get_field("user",PlayerStats[playerid][pUser]); //Username
		samp_mysql_get_field("pass",PlayerStats[playerid][pPass]); //Password
		samp_mysql_get_field("admin", LoadingString); //Admin
		PlayerStats[playerid][pAdmin] = strval(LoadingString);
 		samp_mysql_get_field("kills", LoadingString); //Kills
		PlayerStats[playerid][pKills] = strval(LoadingString);
 		samp_mysql_get_field("deaths", LoadingString); //Deaths
		PlayerStats[playerid][pDeaths] = strval(LoadingString);
		samp_mysql_get_field("money", LoadingString); //Money
		PlayerStats[playerid][pMoney] = strval(LoadingString);
		samp_mysql_get_field("rank", LoadingString); //rank
		PlayerStats[playerid][pRank] = strval(LoadingString);
		samp_mysql_get_field("exp", LoadingString); //exp
		PlayerStats[playerid][pExp] = strval(LoadingString);
		return 1;
	}
	
	SendClientMessage(playerid,COLOR_RED,"**Sorry, that password is incorrect!!");

	return 1;
}
Reply
#8

Quote:
Originally Posted by HighDarren (DarrenReeder)
It is still crashing here is the login function, is there any problems in there?

Код:
public onPlayerLogin(playerid, password[]){
	new playerName[MAX_PLAYER_NAME];
	new result[258];
	new sqlPlayerName[258];
	new pass[258];
	new sqlPass[258]; // official pass
	new sqlPassword[258]; // password enterd
	GetPlayerName(playerid,playerName,sizeof(playerName)); //Get Player Name
	samp_mysql_real_escape_string(playerName, sqlPlayerName); //String for samp_mysql
	format(result,sizeof(result),"SELECT * FROM accounts WHERE user='%s'",sqlPlayerName); // Format my query
	samp_mysql_query(result);
	samp_mysql_store_result();
	samp_mysql_get_field("pass",pass);
	samp_mysql_real_escape_string(pass, sqlPass); //String for pass
	samp_mysql_real_escape_string(password, sqlPassword); //String for pass enterd

	if(strcmp(sqlPassword,sqlPass,true) == 0){
 		PlayerLogged[playerid] = 1;
		SendClientMessage(playerid,COLOR_GREEN,"**You have successfully Logged in!!");
		//----------==========Load accoutn info==========----------
		new LoadingString[128];
		samp_mysql_get_field("ID",LoadingString); //ID
	 	PlayerStats[playerid][pId] = strval(LoadingString);
		samp_mysql_get_field("user",PlayerStats[playerid][pUser]); //Username
		samp_mysql_get_field("pass",PlayerStats[playerid][pPass]); //Password
		samp_mysql_get_field("admin", LoadingString); //Admin
		PlayerStats[playerid][pAdmin] = strval(LoadingString);
 		samp_mysql_get_field("kills", LoadingString); //Kills
		PlayerStats[playerid][pKills] = strval(LoadingString);
 		samp_mysql_get_field("deaths", LoadingString); //Deaths
		PlayerStats[playerid][pDeaths] = strval(LoadingString);
		samp_mysql_get_field("money", LoadingString); //Money
		PlayerStats[playerid][pMoney] = strval(LoadingString);
		samp_mysql_get_field("rank", LoadingString); //rank
		PlayerStats[playerid][pRank] = strval(LoadingString);
		samp_mysql_get_field("exp", LoadingString); //exp
		PlayerStats[playerid][pExp] = strval(LoadingString);
		return 1;
	}
	
	SendClientMessage(playerid,COLOR_RED,"**Sorry, that password is incorrect!!");

	return 1;
}
I don't see anithing that's wrong here... does it happen on a specified moments?
Reply
#9

Quote:
Originally Posted by gamer_Z
textdraws should be CREATED for every player at startup for speed, and only SHOW or HIDE in onplayerconnect and disconnect and other things.
and if you create twice the TD maybe it will crash..
Two textdraws on screen and will be crashed?
Reply
#10

Quote:
Originally Posted by Picharelo
Quote:
Originally Posted by gamer_Z
textdraws should be CREATED for every player at startup for speed, and only SHOW or HIDE in onplayerconnect and disconnect and other things.
and if you create twice the TD maybe it will crash..
Two textdraws on screen and will be crashed?
no.. 1024 =D
but anyway.. why create a TD twice for the same playerid?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)