Help Please , Epic Bug in my server
#1

okey i have my own server hosted on Serverffs, Every 20minutes it restart and serverffs send to me this Msg :

We have restarted your server (#30682 - SA-MP Server) because it was using 60% CPU (peaked at 64% CPU) and 5.8% RAM for a period of time.
Considering your server only has 75 Players, this usage is way too high and has a bad influence on other servers we are hosting.
You should either optimize your custom settings (maps, gamemodes, addons, etc.) or, if you don't know how to do so, reinstall your server and run it on it's default settings.


please help me >..... Thanks
Reply
#2

your gamemode is poorly scripted and inefficent
Reply
#3

Get new hosting. Others hosting dont do restarts.
Reply
#4

I think you used to much timers.. And maybe you used OnPlayerUpdate for to much things, like an anti-cheat system, if you use a timer for each 5 seconds its as good as OnPlayerUpdate, OnPlayerUpdate is 20 Times Per Second I think.. and that needs some CPU.
Reply
#5

how to make it per 5 seconds?
Reply
#6

Remove all the functions from OnPlayerUpdate. Remove Timers that checks very frequently.

Create a new callback (or whatever its called lol) and use SetTimer to run the function every 5 seconds.

pawn Код:
new FiveSecTimer; //On top of your script.

FiveSecTimer = SetTimer("FiveSecCheck", 5000, true); // in OnGameModeInit

KillTimer(FiveSecTimer); // in OnGameModeExit

forward FiveSecCheck();
public FiveSecCheck()
{
     //All your checks here, for playerid checks, make a loop.
     return 1;
}
Reply
#7

Quote:

public OnPlayerUpdate(playerid)
{
new weaponid = GetPlayerWeapon(playerid);
if(!IsPlayerInAnyVehicle(playerid) && weaponid == 44 || weaponid == 45) //desynced nv,infared
{
new Keys, ud, lr;
GetPlayerKeys(playerid, Keys, ud, lr);
if(Keys & KEY_FIRE) return 0;
}
if (GetPVarInt(playerid, "laser")) {
RemovePlayerAttachedObject(playerid, 0);
if ((IsPlayerInAnyVehicle(playerid)) || (IsPlayerInWater(playerid))) return 1;
switch (GetPlayerWeapon(playerid)) {
case 23: {
if (IsPlayerAiming(playerid)) {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP standing aiming
0.108249, 0.030232, 0.118051, 1.468254, 350.512573, 364.284240);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP crouched aiming
0.108249, 0.030232, 0.118051, 1.468254, 349.862579, 364.784240);
}
} else {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP standing not aiming
0.078248, 0.027239, 0.113051, -11.131746, 350.602722, 362.384216);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SP crouched not aiming
0.078248, 0.027239, 0.113051, -11.131746, 350.602722, 362.384216);
} } }
case 27: {
if (IsPlayerAiming(playerid)) {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS standing aiming
0.588246, -0.022766, 0.138052, -11.531745, 347.712585, 352.784271);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS crouched aiming
0.588246, -0.022766, 0.138052, 1.468254, 350.712585, 352.784271);
}
} else {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS standing not aiming
0.563249, -0.01976, 0.134051, -11.131746, 351.602722, 351.384216);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // SPAS crouched not aiming
0.563249, -0.01976, 0.134051, -11.131746, 351.602722, 351.384216);
} } }
case 30: {
if (IsPlayerAiming(playerid)) {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK standing aiming
0.628249, -0.027766, 0.078052, -6.621746, 352.552642, 355.084289);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK crouched aiming
0.628249, -0.027766, 0.078052, -1.621746, 356.202667, 355.084289);
}
} else {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK standing not aiming
0.663249, -0.02976, 0.080051, -11.131746, 358.302734, 353.384216);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // AK crouched not aiming
0.663249, -0.02976, 0.080051, -11.131746, 358.302734, 353.384216);
} } }
case 31: {
if (IsPlayerAiming(playerid)) {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 standing aiming
0.528249, -0.020266, 0.068052, -6.621746, 352.552642, 355.084289);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 crouched aiming
0.528249, -0.020266, 0.068052, -1.621746, 356.202667, 355.084289);
}
} else {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 standing not aiming
0.503249, -0.02376, 0.065051, -11.131746, 357.302734, 354.484222);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // M4 crouched not aiming
0.503249, -0.02376, 0.065051, -11.131746, 357.302734, 354.484222);
} } }
case 34: {
if (IsPlayerAiming(playerid)) {
return 1;
} else {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // Sniper standing not aiming
0.658248, -0.03276, 0.133051, -11.631746, 355.302673, 353.584259);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // Sniper crouched not aiming
0.658248, -0.03276, 0.133051, -11.631746, 355.302673, 353.584259);
} } }
case 29: {
if (IsPlayerAiming(playerid)) {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 standing aiming
0.298249, -0.02776, 0.158052, -11.631746, 359.302673, 357.584259);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 crouched aiming
0.298249, -0.02776, 0.158052, 8.368253, 358.302673, 352.584259);
}
} else {
if (GetPlayerSpecialAction(playerid) != SPECIAL_ACTION_DUCK) {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 standing not aiming
0.293249, -0.027759, 0.195051, -12.131746, 354.302734, 352.484222);
} else {
SetPlayerAttachedObject(playerid, 0, GetPVarInt(playerid, "color"), 6, // MP5 crouched not aiming
0.293249, -0.027759, 0.195051, -12.131746, 354.302734, 352.484222);
} } } } }
if(UsingSate[playerid] == 1)
{
new Keys, ud, lr;
GetPlayerKeys(playerid, Keys, ud, lr);
if(ud < 0) // up
{
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] != 1) { SetPlayerPos(playerid, newsposx[playerid], newsposy[playerid]+4, newsposz[playerid]); }
if(ZOOM[playerid] == 1) { SetPlayerPos(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]); }
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] == 2) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-475); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 3) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-450); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 4) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-420); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 5) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-400); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 1) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-250); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
}
if(ud > 0) // down
{
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] != 1) { SetPlayerPos(playerid, newsposx[playerid], newsposy[playerid]-4, newsposz[playerid]); }
if(ZOOM[playerid] == 1) { SetPlayerPos(playerid, newsposx[playerid], newsposy[playerid]-8, newsposz[playerid]); }
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] == 2) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-475); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 3) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-450); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 4) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-420); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 5) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-400); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 1) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-250); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
}
if(lr < 0) // left
{
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] != 1) { SetPlayerPos(playerid, newsposx[playerid]-4, newsposy[playerid], newsposz[playerid]); }
if(ZOOM[playerid] == 1) { SetPlayerPos(playerid, newsposx[playerid]-8, newsposy[playerid], newsposz[playerid]); }
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] == 2) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-475); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 3) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-450); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 4) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-420); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 5) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-400); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 1) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-250); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
}
if(lr > 0) // right
{
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] != 1) { SetPlayerPos(playerid, newsposx[playerid]+4, newsposy[playerid], newsposz[playerid]); }
if(ZOOM[playerid] == 1) { SetPlayerPos(playerid, newsposx[playerid]+8, newsposy[playerid], newsposz[playerid]); }
GetPlayerPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]);
if(ZOOM[playerid] == 2) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-475); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 3) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-450); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 4) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-420); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 5) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-400); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }
else if(ZOOM[playerid] == 1) { SetPlayerCameraPos(playerid, newsposx[playerid], newsposy[playerid], newsposz[playerid]-250); SetPlayerCameraLookAt(playerid, newsposx[playerid], newsposy[playerid]+8, newsposz[playerid]-500); }

}
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
for(new i = 0; i < sizeof(SpikeInfo); i++)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, SpikeInfo[i][sX], SpikeInfo[i][sY], SpikeInfo[i][sZ]))
{
if(SpikeInfo[i][sCreated] == 1)
{
new panels, doors, lights, tires;
new carid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(carid, panels, doors, lights, tires);
tires = encode_tires(1, 1, 1, 1);
UpdateVehicleDamageStatus(carid, panels, doors, lights, tires);
GameTextForPlayer(playerid,"~r~Spiked",4000,3);
return 0;
}
}
}
}
new iCurWeap = GetPlayerWeapon(playerid); // Return the player's current weapon
if(iCurWeap != iCurrentWeapon[playerid]) // If he changed weapons since the last update
{
OnPlayerChangeWeapon(playerid, iCurrentWeapon[playerid], iCurWeap);
iCurrentWeapon[playerid] = iCurWeap; //Update the weapon variable
}
return 1;
}

i have Laser system should i delete it too/ ? tell me what i should do in this onplayerupdate
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)