09.10.2017, 20:14
The server will run fine for about an hour and then the ram usage spikes up to 450mb+ which casues high ping and random DCs. I've temporarily removed these plugins until I can figure out how to use them properly. Any insight on how the code can be improved will be greatly helpful. I have only been using the plugins for a few days, so I'm still learning them.
After a hour or so, players will start randomly disconnecting from the server. I'm pretty confident this is due to my hosts RAM restrictions (Which is reasonable.)
Here's all relevant code. I know it's quite a bit - I've categorized it the best I can.
After a hour or so, players will start randomly disconnecting from the server. I'm pretty confident this is due to my hosts RAM restrictions (Which is reasonable.)
Here's all relevant code. I know it's quite a bit - I've categorized it the best I can.
pawn Код:
////////////////////////////Top of script//////////////////////
//#include <colandreas>
//#include <Hunting>
/////////////////////////////The callbacks that came with Hunting:://////////////////////////
/*public OnPlayerTakeHuntDrop(playerid,mobid,drop)
{
if(drop)
{
new weapon = GetPlayerWeapon(playerid);
for(new i=0; i < sizeof(cows); i++)
{
if(IsPlayerHarvesting[playerid] == true) return SCM(pid,COLOR_GREY, "ERROR: You're already harvesting meat.");
if(mobid == cows[i])
{
if(weapon == 4 || weapon == 8)
{
SCM(pid,COLOR_GREEN, "You're now cutting the meat from the cow. Please wait...");
IsPlayerHarvesting[playerid] = true;
TogglePlayerControllable(playerid, false);
ApplyAnimation(playerid,"BOMBER","BOM_PLANT_LOOP",4.0,1,0,0,0,-1);
TIMER_HARVEST[playerid] = SetTimerEx("HarvestTimer", 4000, false, "i", playerid);
}
else return SCM(pid,COLOR_GREY, "You need a knife or katana to cut meat.");
return 1;
}
if(mobid == deers[i])
{
if(weapon == 4 || weapon == 8)
{
SCM(pid,COLOR_GREEN, "You're now cutting the meat from the deer. Please wait...");
IsPlayerHarvesting[playerid] = true;
TogglePlayerControllable(playerid, false);
ApplyAnimation(playerid,"BOMBER","BOM_PLANT_LOOP",4.0,1,0,0,0,-1);
TIMER_HARVEST[playerid] = SetTimerEx("HarvestTimer", 4000, false, "i", playerid);
}
else return SCM(pid,COLOR_GREY, "You need a knife or katana to cut meat.");
}
}
}
return 0;
}
///////////////////////////////This is the stock used to spawn the animals into the server. (I'm assuming the issue is here)////////////////////////////
/*stock SpawnAnimals()
{
// | 1 = Original HG | 2 = fort carson | 3 = Forest | 4 = Apocalypse
new zone_animals[3];
for(new i=0; i < sizeof(cows); i++)
{
Hunting::Destroy(cows[i]);
}
for(new i=0; i < sizeof(deers); i++)
{
Hunting::Destroy(deers[i]);
}
for(new i=0; i < sizeof(zone_animals); i++)
{
DestroyDynamicArea(zone_animals[i]);
}
switch(GameMap)
{
case 1: // hunger games arena
{
zone_animals[1] = CreateDynamicCircle(-1642.4524,-2183.5132,200.0);
new Float:x, Float:y, Float:z;
for(new i=0; i < 6; i++)
{
GetRandomPointInCircle(-1642.4524,-2183.5132, 180.0, x, y);
CA_FindZ_For2DCoord(x, y, z);
cows[i] = Hunting::Create(HUNTING_TYPE_COW,x,y,z,55.0,30,.moving_area=zone_animals[1]);
deers[i] = Hunting::Create(HUNTING_TYPE_DEER,x,y,z,55.0,30,.moving_area=zone_animals[1]);
}
}
case 4: // apocalypse
{
zone_animals[2] = CreateDynamicCircle(1143.3879,-1347.5315,230.0);
new Float:x, Float:y, Float:z;
for(new i=0; i < 6; i++)
{
GetRandomPointInCircle(1143.3879,-1347.5315, 220.0, x, y);
CA_FindZ_For2DCoord(x, y, z);
cows[i] = Hunting::Create(HUNTING_TYPE_COW,x,y,z,55.0,30,.moving_area=zone_animals[1]);
deers[i] = Hunting::Create(HUNTING_TYPE_DEER,x,y,z,55.0,30,.moving_area=zone_animals[1]);
}
}
}
return 1;
}*/
///////////////////////This is the timer that is used under OnPlayerTakeHuntDrop.///////////////////
/*forward HarvestTimer(playerid);
public HarvestTimer(playerid)
{
new rand = random(10);
switch(rand)
{
case 0..8:
{
SCM(pid,COLOR_GREEN, "You've harvested: 1 Raw Meat from the animal.");
PLAYER_RAWBEEF[playerid] += 1;
}
default:
{
SCM(pid,COLOR_GREEN, "You've harvested: 2 Raw Meat from the animal.");
PLAYER_RAWBEEF[playerid] += 2;
}
}
TogglePlayerControllable(playerid, true);
IsPlayerHarvesting[playerid] = false;
new Float:x, Float:y, Float:z;
for(new i=0; i < sizeof(cows); i++)
{
Hunting::GetPos(cows[i], x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
{
if(Hunting::IsDead(cows[i]))
{
Hunting::Respawn(cows[i]);
}
}
}
for(new i=0; i < sizeof(deers); i++)
{
Hunting::GetPos(deers[i], x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
{
if(Hunting::IsDead(deers[i]))
{
Hunting::Respawn(deers[i]);
}
}
}
switch(Energy[playerid])
{
case 1..20:
{
Energy[playerid] = 0;
SetPlayerProgressBarValue(playerid, EnergyBar[playerid], Energy[playerid]);
}
case 21..100:
{
Energy[playerid] -= 20;
SetPlayerProgressBarValue(playerid, EnergyBar[playerid], Energy[playerid]);
}
}
KillTimer(TIMER_HARVEST[playerid]);
return 1;
}*/