05.03.2013, 11:03
I keep having heavy CPU usage when players are logged in, using DOF2 saving system, my OnPlayerUpdate isn't so heavy...timers neither...if you'd like any part of the code, let me know.
plugins streamer sscanf |
We can't help you much unless you post the code, check your timers, add some debug to your code.
|
I keep having heavy CPU usage when players are logged in, using DOF2 saving system, my OnPlayerUpdate isn't so heavy...timers neither...if you'd like any part of the code, let me know.
|
public OnPlayerUpdate(playerid)
{
if(!BoomboxStream[playerid])
{
foreach(new i : Player)
{
if(Boombox[i])
{
if(IsPlayerInRangeOfPoint(playerid, 30, bpos[i][0], bpos[i][1], bpos[i][2]))
{
PlayAudioStreamForPlayer(playerid, BoomboxURL[i], bpos[i][0], bpos[i][1], bpos[i][2], 30, 1);
BoomboxPlayer[playerid] = i;
BoomboxStream[playerid] = 1;
SendClientMessage(playerid, COLOR_GREY, " You are listening to music coming out of a nearby boombox.");
}
}
}
}
else
{
new i = BoomboxPlayer[playerid];
if(!IsPlayerInRangeOfPoint(playerid, 30, bpos[i][0], bpos[i][1], bpos[i][2]))
{
BoomboxStream[playerid] = 0;
BoomboxPlayer[playerid] = -1;
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, COLOR_GREY, " You have went far away from the boombox.");
}
}
new Float:hp;
GetPlayerHealth(playerid,hp);
if(hp <= 30) SetPlayerDrunkLevel(playerid,1000);
if(hp == 100) SetPlayerDrunkLevel(playerid,0);
if(IsPlayerInAnyVehicle(playerid))
{
GetVehicleHealth(GetPlayerVehicleID(playerid), vhp);
if(vhp < vhealth[playerid] || vhp > vhealth[playerid])
{
if(vhp < vhealth[playerid]) OnVehicleLoseHealth(playerid,GetPlayerVehicleID(playerid),floatround(vhealth[playerid]-vhp));
vhealth[playerid] = vhp;
}
if(vhp == vhealth[playerid]) GetVehicleVelocity(GetPlayerVehicleID(playerid),velX[playerid],velY[playerid],velZ[playerid]);
}
if(SeatBelt[playerid] != 1)
{
if(GetPVarInt(playerid,"FallFromVeh") == 1)
{
new Float:vX, Float:vY, Float:vZ;
GetPlayerVelocity(playerid,vX,vY,vZ);
if(vZ == 0)
{
new Float:php;
ClearAnimations(playerid);
GetPlayerHealth(playerid, php);
SetPlayerHealth(playerid, php-30);
if(php-30 <= 0 || php <= 0)
{
SetPlayerDrunkLevel(playerid,0);
SetPVarInt(playerid,"FallFromVeh",0);
return 1;
}
SetPlayerDrunkLevel(playerid,10000);
SetTimerEx("Refix",5000,0,"i",playerid);
SetTimerEx("Animation",500,0,"i",playerid);
TogglePlayerControllable(playerid,0);
ApplyAnimation(playerid, "PARACHUTE", "FALL_skyDive_DIE",4,0,0,0,1,0);
SetPVarInt(playerid,"FallFromVeh",0);
}
}
}
if(GetPlayerMoney(playerid) != PCash[playerid]) {
SetPlayerMoney(playerid,PCash[playerid]);
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Speedlimit[playerid])
{
new a, b, c;
GetPlayerKeys(playerid, a, b ,c);
if(a == 8 && GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) > Speedlimit[playerid])
{
new newspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) - Speedlimit[playerid];
ModifyVehicleSpeed(GetPlayerVehicleID(playerid), -newspeed);
}
}
if(PayDayAuth[playerid] == 1)
{
PayDayAuth[playerid] = 0;
PayDay(playerid);
}
return 1;
}
PlayersHungerTimer[playerid] = SetTimerEx("HungerRemoval", 1800000, 1,"i", playerid);
PlayersHungerHealTimer[playerid] = SetTimerEx("HungerHealthAdditionRemoval", 60000, 1, "i", playerid);
PlayersHungerBarTimer[playerid] = SetTimerEx("HungerBar", 100, 1, "i", playerid);
forward HungerHealthAdditionRemoval(playerid);
public HungerHealthAdditionRemoval(playerid)
{
new Float:health;
if(PlayerInfo[playerid][pHunger] == 100 && GetPlayerHealth(playerid,health) < 89)
{
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health+10);
GameTextForPlayer(playerid, "~G~+10 ~w~health", 3000, 3);
}
if(PlayerInfo[playerid][pHunger] == 0)
{
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health-5);
GameTextForPlayer(playerid, "~r~-5 ~w~health", 3000, 3);
}
}
forward HungerBar(playerid);
public HungerBar(playerid)
{
new Float:health;
GetPlayerHealth(playerid, health);
if(health > 100)
{
SetPlayerHealth(playerid, 100);
}
if(PlayerInfo[playerid][pHunger] > 100)
{
new Float:hungerfix = 100.0;
SetPlayerProgressBarValue(playerid, PlayerBar:hunger[playerid], hungerfix);
UpdatePlayerProgressBar(playerid, PlayerBar:hunger[playerid]);
PlayerInfo[playerid][pHunger] = hungerfix;
}
SetPlayerProgressBarValue(playerid, PlayerBar:hunger[playerid], PlayerInfo[playerid][pHunger]);
UpdatePlayerProgressBar(playerid, PlayerBar:hunger[playerid]);
}
forward HungerRemoval(playerid);
public HungerRemoval(playerid)
{
new Float:hungerremoval = 10.0;
GameTextForPlayer(playerid, "~r~Lost 10 hunger points~g~", 5000, 3);
PlayerInfo[playerid][pHunger] -= hungerremoval;
SetPlayerProgressBarValue(playerid, PlayerBar:hunger[playerid], PlayerInfo[playerid][pHunger]);
UpdatePlayerProgressBar(playerid, PlayerBar:hunger[playerid]);
}
SetTimer("UpdateSpeedoMeter", 250, 1);
synctimer = SetTimer("SyncUp", 60000, 1);
SetTimer("SaveAccounts", 300000, 1); //5 mins every account saved
unjailtimer = SetTimer("SetPlayerUnjail", 1000, 1);
celltimer = SetTimer("CellPhoneTimer", 1001, 1);
SetTimer("CustomPickups", 1002, 1);
SetTimer("AntiTeleport", 1003, 1);
SetTimer("CheckGas", 300000, 1);
SetTimer("OtherTimer", 1004, 1);
SetTimer("Production", 300000, 1);
SetTimer("Plantation", 60000, 1);
public SaveAccounts()
{
OnPropSave();
foreach( new i : Player)
{
OnPlayerDataSave(i);
}
}
public SyncUp()
{
SyncTime();
}
public SyncTime()
{
new tmphour;
new tmpminute;
new tmpsecond;
gettime(tmphour, tmpminute, tmpsecond);
FixHour(tmphour);
tmphour = shifthour;
if ((tmphour > ghour) || (tmphour == 0 && ghour == 23))
{
ghour = tmphour;
foreach(Player, i)
{
PayDayAuth[i] = 1;
}
if (realtime)
{
SetWorldTime(tmphour);
}
new RandomWeth;
RandomWeth = random(3);
switch(RandomWeth)
{
case 0:
{
DefaultWeather = 0;
SetWeather(DefaultWeather);
}
case 1:
{
DefaultWeather = 11;
SetWeather(DefaultWeather);
}
case 2:
{
DefaultWeather = 7;
SetWeather(DefaultWeather);
}
}
}
}
forward UpdateSpeedoMeter();
public UpdateSpeedoMeter()
{
new string[32];
foreach(new i : Player)
{
if(IsPlayerInAnyVehicle(i))
{
new vehicle;
vehicle = GetPlayerVehicleID(i);
if(Gas[vehicle] >= 90)
{
format(string, sizeof(string), "FUEL : ~g~%d%",Gas[vehicle]);
}
if(Gas[vehicle] >= 60 && Gas[vehicle] < 89)
{
format(string, sizeof(string), "FUEL : ~g~%d%",Gas[vehicle]);
}
if(Gas[vehicle] >= 30 && Gas[vehicle] < 59)
{
format(string, sizeof(string), "FUEL : ~y~%d%",Gas[vehicle]);
}
if(Gas[vehicle] >= 0 && Gas[vehicle] < 29)
{
format(string, sizeof(string), "FUEL : ~r~%d%",Gas[vehicle]);
}
if(Gas[vehicle] == 0)
{
format(string, sizeof(string), "FUEL : ~r~%d%",Gas[vehicle]);
}
TextDrawSetString(fueltext[i], string);
TextDrawShowForPlayer(i, fueltext[i]);
}
else
{
TextDrawHideForPlayer(i, fueltext[i]);
}
}
}
Maybe they don't, but you might have to! There is a profiler plugin, but it will only tell you so much.
|
native floatadd 218112 native floatsub 649009 native strmid 101277 normal operator<=(Float:,Float: ) 107996 normal operator>=(Float:,Float: ) 1414954 native floatcmp 2053090 native floatmul 432263 native strval 129999 |
And I believe you don't really want to debug 50k lines script.
OnPlayerUpdate: pawn Код:
pawn Код:
|