onplayerupdate
#1

hey,i forwarded OnPlayerUpdate(playerid); then i did public OnPlayerUpdate like this :
Код:
		public OnPlayerUpdate(playerid)
		{
		format(file, sizeof(file), USERS_FILE, PlayerName(playerid));
		
		if(PlayerInfo[playerid][Logged] == 1)
		{
    #if KEYS == 1
		dini_IntSet(file, "Key1", PlayerInfo[playerid][Key1]);
		dini_IntSet(file, "Key2", PlayerInfo[playerid][Key2]);
		dini_IntSet(file, "Key3", PlayerInfo[playerid][Key3]);
		#endif
    #if BOOKS == 1
		dini_IntSet(file, "MathBook", PlayerInfo[playerid][MathBook]);
		dini_IntSet(file, "EngBook", PlayerInfo[playerid][EngBook]);
		dini_IntSet(file, "BioBook", PlayerInfo[playerid][BioBook]);
		#endif
		#if FACTIONS == 1
		dini_IntSet(file, "Faction", PlayerInfo[playerid][Faction]);
		dini_IntSet(file, "fLeader", PlayerInfo[playerid][fLeader]);
		#endif
		#if SKIN == 1
		dini_IntSet(file, "Skin", GetPlayerSkin(playerid));
		#endif
		#if CASH == 1
		dini_IntSet(file, "Cash", GetPlayerMoney(playerid));
		#endif
		#if SCORE == 1
		dini_IntSet(file, "Score", GetPlayerScore(playerid));
		#endif
		#if POSITION == 1
		GetPlayerPos(playerid, PlayerInfo[playerid][x], PlayerInfo[playerid][y], PlayerInfo[playerid][z]);
		GetPlayerFacingAngle(playerid, PlayerInfo[playerid][a]);
		dini_FloatSet(file, "X", PlayerInfo[playerid][x]);
		dini_FloatSet(file, "Y", PlayerInfo[playerid][y]);
		dini_FloatSet(file, "Z", PlayerInfo[playerid][z]);
		dini_FloatSet(file, "A", PlayerInfo[playerid][a]);
		dini_IntSet(file, "Int", GetPlayerInterior(playerid));
		#endif
		#if WEAPONS == 1
		GetPlayerWeaponData(playerid, 0, PlayerInfo[playerid][Wep1], PlayerInfo[playerid][Ammo1]);
		GetPlayerWeaponData(playerid, 1, PlayerInfo[playerid][Wep2], PlayerInfo[playerid][Ammo2]);
		GetPlayerWeaponData(playerid, 2, PlayerInfo[playerid][Wep3], PlayerInfo[playerid][Ammo3]);
		GetPlayerWeaponData(playerid, 3, PlayerInfo[playerid][Wep4], PlayerInfo[playerid][Ammo4]);
		GetPlayerWeaponData(playerid, 4, PlayerInfo[playerid][Wep5], PlayerInfo[playerid][Ammo5]);
		GetPlayerWeaponData(playerid, 5, PlayerInfo[playerid][Wep6], PlayerInfo[playerid][Ammo6]);
		GetPlayerWeaponData(playerid, 6, PlayerInfo[playerid][Wep7], PlayerInfo[playerid][Ammo7]);
		GetPlayerWeaponData(playerid, 7, PlayerInfo[playerid][Wep8], PlayerInfo[playerid][Ammo8]);
		dini_IntSet(file, "Wep1", PlayerInfo[playerid][Wep1]);
		dini_IntSet(file, "Wep2", PlayerInfo[playerid][Wep2]);
		dini_IntSet(file, "Wep3", PlayerInfo[playerid][Wep3]);
		dini_IntSet(file, "Wep4", PlayerInfo[playerid][Wep4]);
		dini_IntSet(file, "Wep5", PlayerInfo[playerid][Wep5]);
		dini_IntSet(file, "Wep6", PlayerInfo[playerid][Wep6]);
		dini_IntSet(file, "Wep7", PlayerInfo[playerid][Wep7]);
		dini_IntSet(file, "Ammo1", PlayerInfo[playerid][Ammo1]);
		dini_IntSet(file, "Ammo2", PlayerInfo[playerid][Ammo2]);
		dini_IntSet(file, "Ammo3", PlayerInfo[playerid][Ammo3]);
		dini_IntSet(file, "Ammo4", PlayerInfo[playerid][Ammo4]);
		dini_IntSet(file, "Ammo5", PlayerInfo[playerid][Ammo5]);
		dini_IntSet(file, "Ammo6", PlayerInfo[playerid][Ammo6]);
		dini_IntSet(file, "Ammo7", PlayerInfo[playerid][Ammo7]);
		#endif
		#if HEALTH == 1
		new Float:health;
		dini_FloatSet(file, "Health", GetPlayerHealth(playerid, health));
		#endif
		#if ARMOUR == 1
		new Float:armour;
		dini_FloatSet(file, "Armour", GetPlayerArmour(playerid, armour));
		#endif
		#if DRUNK_LEVEL == 1
		dini_IntSet(file, "DrunkLevel", GetPlayerDrunkLevel(playerid));
		#endif
		#if FIGHT_STYLE == 1
		dini_IntSet(file, "FightStyle", GetPlayerFightingStyle(playerid));
		#endif
		#if VIRTUAL_WORLD == 1
		dini_IntSet(file, "VirtualWorld", GetPlayerVirtualWorld(playerid));
		#endif
		#if PLAYER_TIME == 1
		GetPlayerTime(playerid, PlayerInfo[playerid][Hour], PlayerInfo[playerid][Min]);
		dini_IntSet(file, "pTime_Hour", PlayerInfo[playerid][Hour]);
		dini_IntSet(file, "pTime_Min", PlayerInfo[playerid][Min]);
		#endif
		#if WANTED_LEVEL == 1
		dini_IntSet(file, "WantedLevel", GetPlayerWantedLevel(playerid));
		#endif
		#if TEAM == 1
		dini_IntSet(file, "Team", GetPlayerTeam(playerid));
		#endif
		#if CLOCK == 1
		dini_IntSet(file, "Clock", 1);
		#elseif CLOCK == 0
		dini_IntSet(file, "Clock", 0);
		#endif
		}
	return 0;
}
if i removed and relogged,it didnt lag again,help with it?thanks
Reply
#2

BUMP!
Reply
#3

OnPlayerUpdate is already from sa-mp, I think you want to create something different and run a timer, OnPlayerUpdate calls like 40 times a second so it's best to not put any code in it.
Reply
#4

Too many slow code on OnPlayerUpdate - use timer for all this file functions!
Reply
#5

i changed it to OnPlayerUpdateX and it worked,thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)