Spawn Issues
#1

I would like to ask, What is the best method to spawn player the fastest way? I'm having delay for about 10 seconds when the player spawns, and it is longer for hosted server where 5 people spawns at the same time. I'll tell you how im spawning the player, can you tell me if it is customary to do so.
Untill spawn steps:
1) When player connects it checks for any bans & reseting his PlayerInfo & any other variables.
2) If player passes OnPlayerConnect, He will get register/login dialogs OnPlayerRequestClass.
3) Lets say this lag most apear after login, but this issue also apear for the register dialog (because im using the same stuff pretty much) so after login complete im loading his weapons & basic stats, then using SetSpawnInfo and Spawning the player.
4) Everything okay, and now for the real issue: OnPlayerSpawn will execute the SpawnChar stock which give the player his stats from y_ini file which loaded already. after clicking continue with password at the login dialog, it takes about 8 seconds to spawn and sometimes it crashes. I'm alone at local host and this is happening to me and im having quite serious Rig.
Also internet is not an issue. Now you guys maybe know anything that can make it faster? the reason im giving the player his stats onplayerspawn is because after he spawns he must gotopos old x,y,z.
Reply
#2

Show me the code after a player enters his password and pressing on the continue button in the dialog.
(It might be as well the loading process [if it's not written properly])
Reply
#3

Make a specific stock which loads the x,y,z and the needed information when a player spawns, and make another stock which isn't needed on spawn when a player successfully enters his password and logs in; I'll help you doing the stock if you can perhaps show me how you're loading the data.
Reply
#4

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Make a specific stock which loads the x,y,z and the needed information when a player spawns, and make another stock which isn't needed on spawn when a player successfully enters his password and logs in; I'll help you doing the stock if you can perhaps show me how you're loading the data.
Loading function (note that forum loses the indentation, its indentated in my pawno)
Код:
public LoadUser_PlayerData(playerid,name[],value[])
{
    INI_Int("Kills",PlayerInfo[playerid][pKills]);
    INI_Int("BizID",PlayerInfo[playerid][BizID]);
    INI_Int("InHouseID", PlayerInfo[playerid][pInHouse]);
    INI_Int("FactionID",PlayerInfo[playerid][pFaction]);
    INI_Int("FactionRank",PlayerInfo[playerid][pFacRank]);
    INI_Int("FactionDivision",PlayerInfo[playerid][pFacDiv]);
    INI_Int("FactionLeader",PlayerInfo[playerid][pFacLeader]);
    INI_Int("FactionDoorID",PlayerInfo[playerid][pDynamicFac]);
    INI_Int("HouseID", PlayerInfo[playerid][HouseID]);
    INI_Int("InBizID", PlayerInfo[playerid][pInBiz]);
    INI_Int("Level", PlayerInfo[playerid][pLevel]);
    INI_Int("AskMute", PlayerInfo[playerid][pASKMute]);
    INI_Int("OocMute", PlayerInfo[playerid][pOOCMute]);
    INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
    INI_String("Accent",PlayerInfo[playerid][pAccent], 16);
    INI_String("RegisterDate",PlayerInfo[playerid][pRegisterDate], 32);
    INI_Int("Money", PlayerInfo[playerid][pMoney]);
    INI_Int("MaskID", PlayerInfo[playerid][pMask]);
	INI_Int("Admin", PlayerInfo[playerid][pAdmin]);
	INI_Int("Ban", PlayerInfo[playerid][pBan]);
	INI_String("IP", PlayerInfo[playerid][pIP], 16);
	INI_Int("Interior", PlayerInfo[playerid][pInterior]);
	INI_Int("Hunger", PlayerInfo[playerid][pHunger]);
	INI_Int("VirtualWorld", PlayerInfo[playerid][pVW]);
    INI_Int("Skin", PlayerInfo[playerid][pSkin]);
    INI_Int("Gender", PlayerInfo[playerid][pGender]);
    INI_Int("Age", PlayerInfo[playerid][pAge]);
   	INI_Int("Wanted",PlayerInfo[playerid][pWanted]);
   	INI_Int("TotalDeliveries",PlayerInfo[playerid][pTotDel]);
	INI_String("WantedReason1",PlayerInfo[playerid][pW1], 24);
	INI_String("WantedReason2",PlayerInfo[playerid][pW2], 24);
	INI_String("WantedReason3",PlayerInfo[playerid][pW3], 24);
	INI_String("WantedReason4",PlayerInfo[playerid][pW4], 24);
	INI_String("WantedReason5",PlayerInfo[playerid][pW5], 24);
	INI_String("WantedReason6",PlayerInfo[playerid][pW6], 24);
	INI_Int("TotalWanted",PlayerInfo[playerid][pTotWanted]);
	INI_Int("Jail",PlayerInfo[playerid][pJail]);
	INI_Int("Bail",PlayerInfo[playerid][pBail]);
    INI_Float("Health", PlayerInfo[playerid][pHealth]);
    INI_Float("Armour", PlayerInfo[playerid][pArmour]);
	INI_Float("PositionX",PlayerInfo[playerid][posX]);
	INI_Float("PositionY",PlayerInfo[playerid][posY]);
	INI_Float("PositionZ",PlayerInfo[playerid][posZ]);
	INI_Float("PositionA",PlayerInfo[playerid][posA]);
	
	INI_Int("BoughtMask", InventoryInfo[playerid][pBoughtMask]);
	INI_Int("HealthKits", InventoryInfo[playerid][pHealthKits]);
	INI_Int("ArmourKits", InventoryInfo[playerid][pArmourKits]);
	INI_Int("Dice", InventoryInfo[playerid][pDice]);
	INI_Int("Condoms", InventoryInfo[playerid][pCondoms]);
	INI_Int("Ropes", InventoryInfo[playerid][pRopes]);
	INI_Int("PortableRadio", InventoryInfo[playerid][pPortableRadio]);
	INI_Int("Alarm", InventoryInfo[playerid][pAlarm]);
	INI_Int("VCSS", InventoryInfo[playerid][pVCSS]);
	INI_Int("Shivs", InventoryInfo[playerid][pShivs]);
	INI_Int("Bandages", InventoryInfo[playerid][pBandages]);
	INI_Int("Notepad", InventoryInfo[playerid][pNotepad]);
	INI_Int("Spraycan", InventoryInfo[playerid][pSpraycan]);
	INI_Int("Cellphone", InventoryInfo[playerid][pCellphone]);
        return 1;
}
This is the last stuff i'm executing after he enteres his password(OnPlayerRequestClass the spectate is true):
Код:
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
SetPVarInt(playerid, "LoggedIn", 1);
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][posX], PlayerInfo[playerid][posY], PlayerInfo[playerid][posZ], PlayerInfo[playerid][posA], 0, 0, 0, 0, 0, 0);
TogglePlayerSpectating(playerid, false);
Now he spawns and this is happening:
Код:
stock SpawnChar(playerid)
{
	if(GetPVarInt(playerid, "LoggedIn") == 1)
	{
		if(!PlayerInfo[playerid][pMask])
		{
			INI_Load("IDNum.ini");
			new UID = random(10000);
			PlayerInfo[playerid][pMask] = IDNum;
			new INI:iInfo = INI_Open("IDNum.ini");
			INI_SetTag(iInfo,"NextIDNumber");
			INI_WriteInt(iInfo,"pMask", IDNum+UID);
			INI_Close(iInfo);
		}
		SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
		SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
		SetPlayerScore(playerid, PlayerInfo[playerid][pLevel]);
		SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVW]);
		SetPlayerInterior(playerid, PlayerInfo[playerid][pInterior]);
		GivePlayerMoney(playerid, PlayerInfo[playerid][pMoney]);
		SetPlayerColor(playerid, COLOR_WHITE);
		SetCameraBehindPlayer(playerid);
		GivePlayerWeapon(playerid,wData[playerid][Weapon1],wData[playerid][Ammo1]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon2],wData[playerid][Ammo2]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon3],wData[playerid][Ammo3]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon4],wData[playerid][Ammo4]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon5],wData[playerid][Ammo5]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon6],wData[playerid][Ammo6]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon7],wData[playerid][Ammo7]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon8],wData[playerid][Ammo8]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon9],wData[playerid][Ammo9]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon10],wData[playerid][Ammo10]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon11],wData[playerid][Ammo11]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon12],wData[playerid][Ammo12]);
		GivePlayerWeapon(playerid,wData[playerid][Weapon13],wData[playerid][Ammo13]);
		TogglePlayerControllable(playerid, 1);
		SetTimerEx("UpdateHunger", 900000, true, "i", playerid);
		SetTimerEx("UpdateBar", 1000, true, "i", playerid);
		BarCheck[playerid] = SetTimerEx("CheckBars", 5000, true, "i", playerid);
		Attach3DTextLabelToPlayer(NameLabel[playerid], playerid, 0, 0, 0.3);
		SetTimerEx("FadeIn", 15, false, "id", playerid, 255);
		SetTimerEx("WelcomeMessages", 1800, false, "i", playerid);
	}
	return 1;
}
About the mask.. well there is no use for the MaskID its just that for now i would like to leave this like that.. should i remove it? and just use WearingMask[playerid] to find masked players? GivePlayerWeapon, Its from another loading, which is the weapons, here it just gives him all the weapons if its 0 then it wont give anything I'll wait for you to guide me on how it can be less laggy...
Reply
#5

Bump.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)