server lagg
#1

my server lagg even at localhost (chat and spawn)

i have tried to redice the lagg but idk how

i tried to make a global string, but that made the server lagg more
pawn Код:
//lie now
new global_string[128];

CMD:somecmd(playerid,params[])
{
    format(global_string......);
}

CMD:somecmd(playerid,params[])
{
    format(global_string......);
}

CMD:somecmd(playerid,params[])
{
    format(global_string......);
}

CMD:somecmd(playerid,params[])
{
    format(global_string......);
}

//like before

CMD:somecmd(playerid,params[])
{
    new string[128];
    format(string......);
}

CMD:somecmd(playerid,params[])
{
    new string[128];
    format(string......);
}

CMD:somecmd(playerid,params[])
{
    new string[128];
    format(string......);
}

CMD:somecmd(playerid,params[])
{
    new string[128];
    format(string......);
}
wich is best? any other idea to reduce lagg?
Reply
#2

You might be using too much timers... or too much stuff on OnPlayerUpdate... there are many things that could cause server lagging.
Reply
#3

TIMERS
pawn Код:
SetTimer("Anticheat", 1000, true);
SetTimer("ServerVaribles", 1000, true);
SetTimer("ServerWanted", 1000, true);
SetTimer("ServerMessages", 120000, true);
ONPLAYERUPDATE
pawn Код:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < sizeof(SpikeData); i++)
    {
        if(IsVehicleCloseSpike(playerid, GetPlayerVehicleID(playerid), 3.2))
        {
            new panels, doors, lights, tires;
            GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
            UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, 15);
        }
    }
    return true;
}
Reply
#4

Nothing is wrong with:
pawn Код:
CMD:somecmd(playerid,params[])
{
    new string[128];
    format(string......);
}
Anything at OnPlayerUpdate?

// Didn't saw your new post.
Reply
#5

Quote:
Originally Posted by Unknown123
Посмотреть сообщение
TIMERS
ONPLAYERUPDATE
pawn Код:
public OnPlayerUpdate(playerid)
{
    for(new i = 0; i < sizeof(SpikeData); i++)
    {
        if(IsVehicleCloseSpike(playerid, GetPlayerVehicleID(playerid), 3.2))
        {
            new panels, doors, lights, tires;
            GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
            UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, 15);
        }
    }
    return true;
}
Looks like thats your problem, your server is more or less doing an infinite loop. If i was you I'd find a better way of doing that. "IsVehicleCloseSpike" probably has a loop too (and range check maybe) so your embedding loops in a callback that gets called many times per second - per player..
Reply
#6

Quote:
Originally Posted by iggy1
Посмотреть сообщение
Looks like thats your problem, your server is more or less doing an infinite loop. If i was you I'd find a better way of doing that. "IsVehicleCloseSpike" probably has a loop too (and range check maybe) so your embedding loops in a callback that gets called many times per second - per player..
here is function
pawn Код:
stock IsVehicleCloseSpike(playerid, vehicleid, Float:range)
{
    new Float:vX, Float:vY, Float:vZ;
    GetVehiclePos(vehicleid, vX, vY, vZ);
    for(new i = 0; i < sizeof(SpikeData); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, range, SpikeData[i][SpikeX], SpikeData[i][SpikeY], SpikeData[i][SpikeZ])
        && IsPlayerInRangeOfPoint(playerid, range, vX, vY, vZ) && IsPlayerInAnyVehicle(playerid))
        {
            if(SpikeData[i][SpikeCreated] == 1)
            {
                return true;
            }
        }
    }
    return false;
}
so this create lagg? how can i do it then, i must pop tier if close spike
Reply
#7

Wow, 2 infinite loops in OnPlayerUpdate!
Well, that's the problem.
Do a timer of example 10-15 seconds.
And, this should be:
pawn Код:
for(new i = 0; i < sizeof(SpikeData); i++)
    {
        if(IsVehicleCloseSpike(i, GetPlayerVehicleID(playerid), 3.2))
        {
            new panels, doors, lights, tires;
            GetVehicleDamageStatus(GetPlayerVehicleID(i), panels, doors, lights, tires);
            UpdateVehicleDamageStatus(GetPlayerVehicleID(i), panels, doors, lights, 15);
        }
    }
You were doing a loop but still using playerid.
Reply
#8

Quote:
Originally Posted by [MWR]Blood
Посмотреть сообщение
Do a timer of example 10-15 seconds.
Yeah, that will create a realistic spikestrip ... 750ms timer or so should be good for this. OnPlayerUpdate gets called +25 times per second, That's roughly every 40 milliseconds.
Reply
#9

someone told me i can do it like this, is this a good way?

pawn Код:
//Onplayerupdate
for(new i = 0; i < sizeof(SpikeData); i++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3.2, SpikeData[i][SpikeX], SpikeData[i][SpikeY], SpikeData[i][SpikeZ])
        && IsPlayerInAnyVehicle(playerid))
        {
            if(SpikeData[i][SpikeCreated] == 1)
            {
                new panels, doors, lights, tires;
                GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
                UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, 15);
            }
        }
    }
Reply
#10

Nothing is good if you put it under OnPlayerUpdate.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)