SA-MP Forums Archive
the mode is full of lags. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: the mode is full of lags. (/showthread.php?tid=268513)



the mode is full of lags. - matanm - 12.07.2011

i opend a thread 3 days ago, and no one helped me.
let me explain what is the problem:
i've a RolePlay mode that my friend build, he built it from 0.
now, when i log in the server and i'm alone, there are no lags, the server works perfect, but
when there are more then 1 player, the mode is full of lags, when you write there is a delay of 10 seconds, you can't see another player where he really goes, it's stupid....but the server ping is on 30-40.
it is a linux server, and it's not a problem with the host, on other gamemode it's work good.
there is only 6 timers on the mode, and in the public onplayerupdate there is only the /stats thing....
please help me, i don't know what is the problem...


Re: the mode is full of lags. - Snipa - 12.07.2011

Show the OnPlayerText, OnPlayerUpdate callbacks. Also, what is the speed of the server?

BTW, I'm not buying your story of "Built from 0". Are you using GF?


Re: the mode is full of lags. - matanm - 12.07.2011

it's dont me that build the mode, it's my friend. and what do you mean "what is the speed of the server?"the ping is on 30-40, when i run other mode, the server works good, we were 7 people and the game worked very fast.

and there are the publics :
Quote:

public OnPlayerText(playerid, text[])
{
new x[256];
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid,plname,sizeof(plname));
//new name[MAX_PLAYER_NAME];
//NewName(name);
new Float: X;
new Float: Y;
new Float: Z;
GetPlayerPos(playerid,X,Y,Z);
if(PlayerInfo[playerid][OnCall] == 1)
{
format(x,sizeof(x),"[CellPhone] %s says: %s",plname,text);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(PlayerInfo[playerid][OnCall] == 1)
{
if(CallFrom[playerid][i] == 1 || CallFrom[i][playerid] == 1)
{
format(x,sizeof(x),"[Phone]: %s",text);
SendClientMessage(i,COLOR_WHITE,x);
}
else if(IsPlayerInRangeOfPoint(i,7.0,X,Y,Z))
{
SendClientMessage(i,COLOR_WHITE,x);
}
}
}
}
else
{
format(x,sizeof(x),"%s says: %s",plname,text);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerInRangeOfPoint(i,7.0,X,Y,Z))
{
SendClientMessage(i,COLOR_WHITE,x);
}
}
}
return 0;
}


Quote:

public OnPlayerUpdate(playerid)
{
new string3[64];
new playername3[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername3, sizeof(playername3));
format(string3, sizeof(string3), "LARP/Users/%s.ini", playername3);
dini_IntSet(string3,"Arrested",PlayerInfo[playerid][Arrested]);
dini_IntSet(string3,"ArrestedTime",PlayerInfo[playerid][ArrestedTime]);
dini_IntSet(string3,"Skin",PlayerInfo[playerid][Skin]);
dini_IntSet(string3,"Loan",PlayerInfo[playerid][Loan]);
dini_IntSet(string3,"AdminLevel",PlayerInfo[playerid][AdminLevel]);
dini_IntSet(string3,"Mask",PlayerInfo[playerid][Mask]);
dini_IntSet(string3,"Age",PlayerInfo[playerid][Age]);
dini_IntSet(string3,"Logged",PlayerInfo[playerid][Logged]);
dini_Set(string3,"Origin",POrigin);
dini_IntSet(string3,"Frozen",PlayerInfo[playerid][Freeze]);
dini_IntSet(string3,"Materials",PlayerInfo[playerid][Mats]);
dini_IntSet(string3,"HitmanOfferToKill",PlayerInfo[playerid][HitmanOffer]);
dini_IntSet(string3,"HitmanMoney",PlayerInfo[playerid][HitmanMoney]);
dini_IntSet(string3,"Drugs",PlayerInfo[playerid][Drugs]);
dini_IntSet(string3,"Played",PlayerInfo[playerid][Played]);
dini_IntSet(string3,"Gender",PlayerInfo[playerid][Gender]);
dini_IntSet(string3,"Level",PlayerInfo[playerid][Level]);
dini_FloatSet(string3,"PX",PlayerInfo[playerid][PX1]);
dini_FloatSet(string3,"PY",PlayerInfo[playerid][PY1]);
dini_FloatSet(string3,"PZ",PlayerInfo[playerid][PZ1]);
dini_IntSet(string3,"Team",PlayerInfo[playerid][Team]);
dini_IntSet(string3,"Organization",PlayerInfo[playerid][Organization]);
dini_IntSet(string3,"Registered",PlayerInfo[playerid][Reg]);
dini_IntSet(string3,"Faction",PlayerInfo[playerid][Faction]);
dini_IntSet(string3,"Rank",PlayerInfo[playerid][Rank]);
dini_IntSet(string3,"Bank",PlayerInfo[playerid][Bank]);
dini_IntSet(string3,"City",PlayerInfo[playerid][City]);
PlayerInfo[playerid][Cash] = GetPlayerMoney(playerid);
dini_IntSet(string3,"Cash",PlayerInfo[playerid][Cash]);
dini_IntSet(string3,"Job",PlayerInfo[playerid][Job]);
dini_IntSet(string3,"GPS",PlayerInfo[playerid][GPS]);
dini_IntSet(string3,"Bank",PlayerInfo[playerid][Bank]);
dini_IntSet(string3,"PayDay",PlayerInfo[playerid][PayDay]);
dini_IntSet(string3,"PayDayNeed",PlayerInfo[playerid][PayDayNeed]);
dini_IntSet(string3,"Cash",PlayerInfo[playerid][Cash]);
dini_IntSet(string3,"PayCheck",PlayerInfo[playerid][PayCheck]);
dini_IntSet(string3,"Gang",PlayerInfo[playerid][Gang]);
dini_IntSet(string3,"Banned",PlayerInfo[playerid][Banned]);
dini_IntSet(string3,"Locked",PlayerInfo[playerid][Locked]);
dini_IntSet(string3,"VehicleLic",PlayerInfo[playerid][VehicleLic]);
dini_IntSet(string3,"BikeLic",PlayerInfo[playerid][BikeLic]);
dini_IntSet(string3,"PhoneNumber",PlayerInfo[playerid][Phnumber]);
dini_IntSet(string3,"BusLic",PlayerInfo[playerid][BusLic]);
dini_IntSet(string3,"TruckLic",PlayerInfo[playerid][TruckLic]);
dini_IntSet(string3,"Bag",PlayerInfo[playerid][Bag]);
dini_IntSet(string3,"AdminDuty",PlayerInfo[playerid][AdminDuty]);
dini_FloatSet(string3,"Health",PlayerInfo[playerid][Health]);
dini_FloatSet(string3,"Armour",PlayerInfo[playerid][Armour]);
dini_FloatSet(string3,"BagMoney",PlayerInfo[playerid][BagMoney]);
dini_IntSet(string3,"BoatLic",PlayerInfo[playerid][BoatLic]);
dini_IntSet(string3,"PlainLic",PlayerInfo[playerid][PlainLic]);
dini_IntSet(string3,"WeaponLic",PlayerInfo[playerid][WeaponLic]);
dini_IntSet(string3,"Watch",PlayerInfo[playerid][Watch]);
dini_IntSet(string3,"Lighter",PlayerInfo[playerid][Lighter]);
dini_IntSet(string3,"Cigarette",PlayerInfo[playerid][Cigarette]);
dini_IntSet(string3,"PhoneBook",PlayerInfo[playerid][PhoneBook]);
return 1;
}




Re: the mode is full of lags. - Calgon - 12.07.2011

The most obvious problem is that your code saves every single player in OnPlayerUpdate. You should know that OnPlayerUpdate is called very frequently per second - and the amount of file operations you're forcing it to process is just stupid.

Paste the code from OnPlayerUpdate to OnPlayerDisconnect (or you can create a timer and rename the function) and delete your OnPlayerUpdate function.


Re: the mode is full of lags. - Ricop522 - 13.07.2011

pawn Код:
public OnPlayerUpdate(playerid)
{
    return 1;
}
public OnGameModeInit() {
    SetTimer("updateAccount", 1000);
}

forward updateAccount(); public updateAccount()
{
    new i = 0;
    for( ; i < MAX_PLAYERS; ++i ) OnPlayerUpdateEx(i);
    return 1;
}

public OnPlayerUpdateEx(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new string3[64];
        new playername3[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername3, sizeof(playername3));
        format(string3, sizeof(string3), "LARP/Users/%s.ini", playername3);
        dini_IntSet(string3,"Arrested",PlayerInfo[playerid][Arrested]);
        dini_IntSet(string3,"ArrestedTime",PlayerInfo[playerid][ArrestedTime]);
        dini_IntSet(string3,"Skin",PlayerInfo[playerid][Skin]);
        dini_IntSet(string3,"Loan",PlayerInfo[playerid][Loan]);
        dini_IntSet(string3,"AdminLevel",PlayerInfo[playerid][AdminLevel]);
        dini_IntSet(string3,"Mask",PlayerInfo[playerid][Mask]);
        dini_IntSet(string3,"Age",PlayerInfo[playerid][Age]);
        dini_IntSet(string3,"Logged",PlayerInfo[playerid][Logged]);
        dini_Set(string3,"Origin",POrigin);
        dini_IntSet(string3,"Frozen",PlayerInfo[playerid][Freeze]);
        dini_IntSet(string3,"Materials",PlayerInfo[playerid][Mats]);
        dini_IntSet(string3,"HitmanOfferToKill",PlayerInfo[playerid][HitmanOffer]);
        dini_IntSet(string3,"HitmanMoney",PlayerInfo[playerid][HitmanMoney]);
        dini_IntSet(string3,"Drugs",PlayerInfo[playerid][Drugs]);
        dini_IntSet(string3,"Played",PlayerInfo[playerid][Played]);
        dini_IntSet(string3,"Gender",PlayerInfo[playerid][Gender]);
        dini_IntSet(string3,"Level",PlayerInfo[playerid][Level]);
        dini_FloatSet(string3,"PX",PlayerInfo[playerid][PX1]);
        dini_FloatSet(string3,"PY",PlayerInfo[playerid][PY1]);
        dini_FloatSet(string3,"PZ",PlayerInfo[playerid][PZ1]);
        dini_IntSet(string3,"Team",PlayerInfo[playerid][Team]);
        dini_IntSet(string3,"Organization",PlayerInfo[playerid][Organization]);
        dini_IntSet(string3,"Registered",PlayerInfo[playerid][Reg]);
        dini_IntSet(string3,"Faction",PlayerInfo[playerid][Faction]);
        dini_IntSet(string3,"Rank",PlayerInfo[playerid][Rank]);
        dini_IntSet(string3,"Bank",PlayerInfo[playerid][Bank]);
        dini_IntSet(string3,"City",PlayerInfo[playerid][City]);
        PlayerInfo[playerid][Cash] = GetPlayerMoney(playerid);
        dini_IntSet(string3,"Cash",PlayerInfo[playerid][Cash]);
        dini_IntSet(string3,"Job",PlayerInfo[playerid][Job]);
        dini_IntSet(string3,"GPS",PlayerInfo[playerid][GPS]);
        dini_IntSet(string3,"Bank",PlayerInfo[playerid][Bank]);
        dini_IntSet(string3,"PayDay",PlayerInfo[playerid][PayDay]);
        dini_IntSet(string3,"PayDayNeed",PlayerInfo[playerid][PayDayNeed]);
        dini_IntSet(string3,"Cash",PlayerInfo[playerid][Cash]);
        dini_IntSet(string3,"PayCheck",PlayerInfo[playerid][PayCheck]);
        dini_IntSet(string3,"Gang",PlayerInfo[playerid][Gang]);
        dini_IntSet(string3,"Banned",PlayerInfo[playerid][Banned]);
        dini_IntSet(string3,"Locked",PlayerInfo[playerid][Locked]);
        dini_IntSet(string3,"VehicleLic",PlayerInfo[playerid][VehicleLic]);
        dini_IntSet(string3,"BikeLic",PlayerInfo[playerid][BikeLic]);
        dini_IntSet(string3,"PhoneNumber",PlayerInfo[playerid][Phnumber]);
        dini_IntSet(string3,"BusLic",PlayerInfo[playerid][BusLic]);
        dini_IntSet(string3,"TruckLic",PlayerInfo[playerid][TruckLic]);
        dini_IntSet(string3,"Bag",PlayerInfo[playerid][Bag]);
        dini_IntSet(string3,"AdminDuty",PlayerInfo[playerid][AdminDuty]);
        dini_FloatSet(string3,"Health",PlayerInfo[playerid][Health]);
        dini_FloatSet(string3,"Armour",PlayerInfo[playerid][Armour]);
        dini_FloatSet(string3,"BagMoney",PlayerInfo[playerid][BagMoney]);
        dini_IntSet(string3,"BoatLic",PlayerInfo[playerid][BoatLic]);
        dini_IntSet(string3,"PlainLic",PlayerInfo[playerid][PlainLic]);
        dini_IntSet(string3,"WeaponLic",PlayerInfo[playerid][WeaponLic]);
        dini_IntSet(string3,"Watch",PlayerInfo[playerid][Watch]);
        dini_IntSet(string3,"Lighter",PlayerInfo[playerid][Lighter]);
        dini_IntSet(string3,"Cigarette",PlayerInfo[playerid][Cigarette]);
        dini_IntSet(string3,"PhoneBook",PlayerInfo[playerid][PhoneBook]);
        return 1;
    }
    return 1;
}
[/pawn]

Here we goo !


Re: the mode is full of lags. - Calgon - 13.07.2011

You don't need a timer that runs EVERY second... Especially with code that probably won't work.


Re: the mode is full of lags. - Backwardsman97 - 13.07.2011

Just save whenever the player leaves and keep track of his/her stats while they are playing through variables.