03.05.2010, 17:41
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.
-----
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
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


here is the login function, is there any problems in there?