Help With OnPlayerUpdate
#1

Hello

Server keep restarting im host from volt-host and when im support ticket volt-host said to me this text and tell me if u have any thing OnPlayerUpdate tell him or fix it



Код:
If your server is being restarted due to high CPU. Check to see whether its just 
"spikes" or its consistently high CPU all the time. Check if the amount of players 
makes a difference and subtle things such as this then review your script for inefficient 
code or things like loops that never end or code under OnPlayerUpdate that
 puts a tremendous strain on the CPU. There are alot of factors in which your server must be 
restarted but it is necessary as your server can hang and can cause problems for other servers
 on the node.

What the problem here ?

pawn Код:
public OnPlayerUpdate(playerid)
{
    if(!IsPlayerConnected(playerid))
    if(SInfo[playerid][pAdmin] >= 1)
    if(GetPlayerWeapon(playerid) == WEAPON_MINIGUN) //Checking if he has a Minigun
    {
        ResetPlayerWeapons(playerid);
        new name[MAX_PLAYER_NAME], string[254];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "{00FF22}Rachel: %s Has Been BANNED from the Server - Cheats Detected", name);
        SendClientMessageToAll(GREEN, string);
        Ban(playerid);
    }
    return 1;
}
sorry for my bad english
Reply
#2

nothing wrong with the OPU, its so small, any server could handle those few lines with 5000 players. it seems that your script is looping/lagging somewhere else.
to spot the function causing trouble, have a look at the plugins-section, and grab the profiler plugin. once installed, let it profile the gamemode for some minutes (not at the public server please, the plugin eats a lot of RAM depending on your gamemode).
oh, when you got results: its not the callback being called most often, its the one which needs the most CPU time per call.
btw: to check if a player HOLDS a minigun, sholdnt be the problem, why dont you move that check to OnPlayerKeyStateChange? a minigun is harmless as long it aint fired, so just when a player wants to shoot with it, ban him. this will save your script a lot of work (100 players*25 fps=2500 loops per second..)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)