the mode is full of lags.
#1

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...
Reply
#2

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?
Reply
#3

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;
}

Reply
#4

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.
Reply
#5

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 !
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)