How can i reduce the cpu usage. -
Ironboy. - 09.02.2012
Hello!
I'm using volt-host for my server.In that the CPU usage is more.How can i reduce it?
Server location is France.
Please answer.
Re: How can i reduce the cpu usage. - Guest9328472398472 - 09.02.2012
"OnPlayerUpdate"
I use to have that problem, and when a scripter of mines told me about it and fixed it for me...(when I WAS with volt) the CPU went down..
Re: How can i reduce the cpu usage. -
Ironboy. - 09.02.2012
This is my OnPlayerUpdate function
pawn Код:
public OnPlayerUpdate(playerid){
if(!IsPlayerConnected(playerid)) return 0;
// No weapons in interiors
if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
SetPlayerArmedWeapon(playerid,0); // fists
return 0;} // no syncing until they change their weapon
if(usingCrane[playerid][0] == 1)
{
new Keys,ud,lr;
GetPlayerKeys(playerid,Keys,ud,lr);
if(lr < 0)
{
new Float:fa;
GetPlayerFacingAngle(playerid, fa);
fa+=1.0;
if(fa >= 360.0) fa-=360.0;
SetPlayerFacingAngle(playerid, fa);
cranes[usingCrane[playerid][1]][CRANE_ANGLE] = fa;
SetObjectRot(cranes[usingCrane[playerid][1]][CRANE_TOP], 0, 0, cranes[usingCrane[playerid][1]][CRANE_ANGLE]);
new Float:x, Float:y;
GetXYInFrontOfPlayer(playerid, x, y, 41);
SetPlayerCameraLookAt(playerid, x, y, (cranes[usingCrane[playerid][1]][CRANE_POS_Z]+12.539));
}
else if(lr > 0)
{
new Float:fa;
GetPlayerFacingAngle(playerid, fa);
fa-=1.0;
if(fa <= 0.0) fa+=360.0;
SetPlayerFacingAngle(playerid, fa);
cranes[usingCrane[playerid][1]][CRANE_ANGLE] = fa;
SetObjectRot(cranes[usingCrane[playerid][1]][CRANE_TOP], 0, 0, cranes[usingCrane[playerid][1]][CRANE_ANGLE]);
new Float:x, Float:y;
GetXYInFrontOfPlayer(playerid, x, y, 41);
SetPlayerCameraLookAt(playerid, x, y, (cranes[usingCrane[playerid][1]][CRANE_POS_Z]+12.539));
}
}
return 1;}
When you fixed Onplayerupdate, that time your problem solved?
Re: How can i reduce the cpu usage. - Guest9328472398472 - 09.02.2012
Yes, it was timers under that function causing problems...
Re: How can i reduce the cpu usage. -
Ironboy. - 09.02.2012
But for me there is no timers under OnPlayerUpdate....
Re: How can i reduce the cpu usage. -
Babul - 09.02.2012
first, remove this:
pawn Код:
if(!IsPlayerConnected(playerid)) return 0;
a player not connected, will not update, ergo: no need for a connection check - a player not connected, cannot call th callback.
the weapon syncing (removing) can be done better in the OnPlayerKeyStateChange (when the player DOES switch a weapon)..
Re: How can i reduce the cpu usage. -
Ironboy. - 09.02.2012
Ok i should remove only this?
pawn Код:
if(!IsPlayerConnected(playerid)) return 0;
Re: How can i reduce the cpu usage. -
Babul - 09.02.2012
you can remove it without caring for. it will NEVER be called, so, yes.
Re: How can i reduce the cpu usage. -
Ironboy. - 09.02.2012
Ok thx. +rep