Server lag? +REP -
Youssef221 - 25.01.2015
Hello, so the server was lagging a bit, then the lag increases, then the server hbeing frozen, i mean i see all players like paused, when i do /q I see that i am still ingame, and when i try to get inside again, it says Server closed the connection, and after I saw my CPU Usage i found out that it is 10.3%, and in less than a min it increased to 13.7%, why is this happening?
Is this the reason, if yes, then how can I fix it?:
pawn Код:
public OnPlayerUpdate(playerid)
{
new hacker[MAX_PLAYER_NAME];
GetPlayerName(playerid, hacker, MAX_PLAYER_NAME);
if(GetPlayerWeapon(playerid) == 38 || GetPlayerWeapon(playerid) == 35 || GetPlayerWeapon(playerid) == 36 || GetPlayerWeapon(playerid) == 37)
{
if(PlayerInfo[playerid][pAdmin] == 0)
{
new antimsg[128];
format(antimsg, sizeof(antimsg), "%s (%d) Has Been Kicked By Anti-Cheat (AC) | Reason: Weapon Hacks.", hacker, playerid);
SendClientMessageToAll(0x00FFFFFF, antimsg);
SendClientMessage(playerid, 0xFF0000AA, "You Have Been Kicked By Anti-Cheat (AC) | Reason: Weapon Hacks.");
SetTimerEx("TimeKicker", 500, false, "d", playerid);
}
}
new Float:Armour;
GetPlayerArmour(playerid, Armour);
if(Armour > 0.0)
{
if(Info[playerid][VIPLevel] < 3)
{
new antimsg[128];
format(antimsg, sizeof(antimsg), "%s (%d) Has Been Kicked By The Anti-Cheat (AC) | Reason: Armour Hacks.", hacker, playerid);
SendClientMessageToAll(0x00FFFFFF, antimsg);
SendClientMessage(playerid, 0xFF0000AA, "You Have Been Kicked By The Anti-Cheat (AC) | Reason: Armour Hacks.");
SetTimerEx("TimeKicker", 500, false, "d", playerid);
}
}
new str[256];
format(str,sizeof(str),"~r~Kills: ~w~%d ~g~Deaths: ~w~%d",PlayerInfo[playerid][pKills],PlayerInfo[playerid][pDeaths]);
TextDrawSetString(Text:Stats[playerid],str);
if(PlayerInfo[playerid][pKills]<10)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Newbie Shooter");
}
else if(PlayerInfo[playerid][pKills]>=10 && PlayerInfo[playerid][pKills]<75)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Killer Shooter");
}
else if(PlayerInfo[playerid][pKills]>=75 && PlayerInfo[playerid][pKills]<150)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Master Shooter");
}
else if(PlayerInfo[playerid][pKills]>=150 && PlayerInfo[playerid][pKills]<300)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Pro Shooter");
}
else if(PlayerInfo[playerid][pKills]>=300 && PlayerInfo[playerid][pKills]<450)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Striker Shooter");
}
else if(PlayerInfo[playerid][pKills]>=450 && PlayerInfo[playerid][pKills]< 675)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Freekill Shooter");
}
else if(PlayerInfo[playerid][pKills]>=675 && PlayerInfo[playerid][pKills]< 1000)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Psycho Shooter");
}
else if(PlayerInfo[playerid][pKills]>=1000 && PlayerInfo[playerid][pKills]< 1500)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Fatal Shooter");
}
else if(PlayerInfo[playerid][pKills]>=1500 && PlayerInfo[playerid][pKills]< 2250)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Havoc Shooter");
}
else if(PlayerInfo[playerid][pKills]>=2250 && PlayerInfo[playerid][pKills]< 3375)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Extreme Shooter");
}
else if(PlayerInfo[playerid][pKills]>=3375 && PlayerInfo[playerid][pKills]< 5100)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Wild Shooter");
}
else if(PlayerInfo[playerid][pKills]>=5100 && PlayerInfo[playerid][pKills]< 7650)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Hazardous Shooter");
}
else if(PlayerInfo[playerid][pKills]>=7650 && PlayerInfo[playerid][pKills]< 11475)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~IGI Shooter"); /*Scripted By Sufyan*/
}
else if(PlayerInfo[playerid][pKills]>=11475 && PlayerInfo[playerid][pKills]< 17500)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Tactical Shooter");
}
else if(PlayerInfo[playerid][pKills]>=17500 && PlayerInfo[playerid][pKills]< 26250)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Dedicated Shooter");
}
else if(PlayerInfo[playerid][pKills]>=26250 && PlayerInfo[playerid][pKills]< 39375)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Insane Shooter");
}
else if(PlayerInfo[playerid][pKills]>=39375 && PlayerInfo[playerid][pKills]< 60000)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~The Real Shooter");
}
else if(PlayerInfo[playerid][pKills]>=60000 && PlayerInfo[playerid][pKills]< 100000)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Professional Shooter");
}
else if(PlayerInfo[playerid][pKills]> 100000)
{
TextDrawSetString(Text:R_1[playerid],"~r~RANK:~w~Rockstar Shooter");
}
if(GetPlayerAnimationIndex(playerid) != 0)
{
if(Info[playerid][VIPLevel] >= 1)
{
new string[128];
format(string, sizeof(string), "{F3FF02}%s", GetVIPName(playerid));
SetPlayerChatBubble(playerid,string,0xFF0000FF, 100.0, 10000); // creates the string
}
}
new uzone[MAX_ZONE_NAME];
GetPlayer2DZone(playerid, uzone, MAX_ZONE_NAME);
PlayerTextDrawSetString(playerid,Textdraw444[playerid],uzone);
new respectf[128];
format(respectf, sizeof(respectf), "Respect: ~w~%d", Info[playerid][Respect]);
PlayerTextDrawSetString(playerid,Textdraw000[playerid],respectf);
new adf[128];
format(adf, sizeof(adf), "Adrenaline Pills: ~w~%d", LPinfo[playerid][Adre]);
PlayerTextDrawSetString(playerid,Textdraw111[playerid],adf);
new tdf[128];
format(tdf, sizeof(tdf), "Grams Of Drugs: ~w~%d", LPinfo[playerid][Drugs]);
PlayerTextDrawSetString(playerid,Textdraw222[playerid],tdf);
new raf[128];
format(raf, sizeof(raf), "Ratio: ~w~%0.2f", Float:PlayerInfo[playerid][pKills]/Float:PlayerInfo[playerid][pDeaths]);
PlayerTextDrawSetString(playerid,Textdraw333[playerid],raf);
return 1;
}
Please help..
Re: Server lag? +REP -
CrazyChoco - 25.01.2015
Never.Use.On.PlayerUpdate. It's inefficient
Re: Server lag? +REP -
Youssef221 - 25.01.2015
Then what's the solution of all these codes :/
Re: Server lag? +REP -
HydraHumza - 25.01.2015
why don't u make stock of rank why u put all rank state rank doesn't need to update just make a stock
Re: Server lag? +REP -
Ryz - 25.01.2015
use timers instead onplayerupdate
Re: Server lag? +REP -
Youssef221 - 25.01.2015
@Humza what do you mean..
@Ryz okay i will see..
Re: Server lag? +REP -
arlindi - 25.01.2015
Put in stock and createe it with timer
Re: Server lag? +REP -
Youssef221 - 25.01.2015
Thanks everyone you all +REPED
Re: Server lag? +REP -
HydraHumza - 25.01.2015
Quote:
Originally Posted by Youssef221
Thanks everyone you all +REPED
|
THANKS
Re: Server lag? +REP -
PowerPC603 - 25.01.2015
Also that RANK stuff, where you set the new text for your textdraw doesn't belong in a timer as well.
Create a small function that you can call whenever the kills increase.
And add that code there as well, to update your textdraw.
Whenever you detect a kill, just call this function once and it should:
- add 1 to your kills variable
- update the textdraw
It has no use to keep updating a textdraw with the same text over and over again when nobody is killing someone.
Doing this under OnPlayerUpdate will update that textdraw 30 times per second.
I don't think anyone can kill 30 people per second, so it doesn't belong there in the first place.