OnPlayerSpawn
#1

Hello, im wondering that sometimes when a player spawn its take 2 seconds to respond I think that because of many functions , how to imporove something like that:
Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerInterior(playerid,0);
	//Killing Spree
	Streaks[playerid] = 0;
	//End KS
	//SPARules
    TextDrawHideForPlayer(playerid,text45);
    TextDrawHideForPlayer(playerid,text46);
    TextDrawHideForPlayer(playerid,text28);
    TextDrawHideForPlayer(playerid,text34);
    TextDrawHideForPlayer(playerid,text29);
	//End
    if(Spawned[playerid] == 0)
    {
    Spawned[playerid] = 1;
//  ShowPlayerDialog(playerid, Radio_MSG, DIALOG_STYLE_MSGBOX, "SPA Radio Question:", "Would you turn off the music?\n{F81414}Yes to Stop music\n{FFAF00}No To keep listing!", "Yes", "No");
  	ShowPlayerDialog(playerid, Radio_Channels, DIALOG_STYLE_LIST, "Select a Station","{00F2FF}Stunt Paradise Radio\n{FF0000}Arabic Channel Music\n{00FF1E}Arabic Channel Music 2\n{0026FF}English Music 2\n{B7FF00}USA News And Music\n{F3FF02}Jordon Hala FM\n{F300FF}Arabic Hot Music\n{C9FFAB}Israel FM\n{C3C3C3}Sweden FM\n{FFF1AF}Egypt FM\n{FFFF00}Input a URL!\n{FFFFFF}Turn Off Radio I wont listen Music!","Ok", "Cancel");
    }
	//AntiSpawn Kill 6/12/13
    if(DMZone[playerid] >= 0)
    {
    SetPlayerHealth(playerid, 100000);
    SetTimerEx("AntiSpawnkill",4000,0,"i",playerid);
	}
	new rand;
	rand = random(sizeof(RandomPlayerSpawns));
	ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid,27,30000);
    GivePlayerWeapon(playerid,23,30000);
    GivePlayerWeapon(playerid,31,30000);
    GivePlayerWeapon(playerid,32,30000);
    GivePlayerWeapon(playerid,6,1);
    PlayerInfo[playerid][SpawnAngle] = 0.0; //so when you leave and another player comes, the camera will start from start
    PlayerInfo[playerid][SpawnDance] = true; //to not execute to much timers
    //KillTimer( PlayerInfo[playerid][SpawnTimer] ); //to kill it, since its useless now
    PlayerPlaySound(playerid, 1186, 0.0, 0.0, 0.0); // (blank sound) to shut the music up
    SetCameraBehindPlayer(playerid); //to prevent some bugs
    PlayCrimeReportForPlayer(playerid, playerid, 3);
	PlayerPlaySound(playerid, 1098,-119.9460,23.1096,12.2238);
    if(DMZone[playerid] == 0)
    {
   	SetPlayerWeather(playerid,18);
	SetPlayerPos(playerid, RandomPlayerSpawns[rand][0], RandomPlayerSpawns[rand][1], RandomPlayerSpawns[rand][2]);
	SetPlayerVirtualWorld(playerid,0);
	SetPlayerWeather(playerid,PlayerWeatherOnSpawns[rand][0]);
	SetPlayerTime(playerid,PlayerWeatherOnSpawns[rand][1],0);
	}
    if(DMZone[playerid] == 1)
    {
 	rand = random(sizeof(RandomPlayerSpawnsSniper));
    ResetPlayerWeapons(playerid);
	SetPlayerPos(playerid, RandomPlayerSpawnsSniper[rand][0], RandomPlayerSpawnsSniper[rand][1], RandomPlayerSpawnsSniper[rand][2]);
//	SendClientMessage(playerid, RED,"* Server: {FFFFFF}For leave dm type {F3FF02}/LeaveDm");
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
	SetPlayerInterior(playerid, 0);
	GivePlayerWeapon(playerid, 34, 1000);
	SetPlayerVirtualWorld(playerid,105);
	}
    if(DMZone[playerid] == 2)
    {
    rand = random(sizeof(RandomPlayerSpawnsarea69));
	SetPlayerPos(playerid, RandomPlayerSpawnsarea69[rand][0], RandomPlayerSpawnsarea69[rand][1], RandomPlayerSpawnsarea69[rand][2]);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
	GivePlayerWeapon(playerid, 32, 100);
    GivePlayerWeapon(playerid, 28, 100);
    GivePlayerWeapon(playerid, 27, 100);
    GivePlayerWeapon(playerid, 23, 100);
    SetPlayerVirtualWorld(playerid,110);//Area69
	}
    if(DMZone[playerid] == 3)
    {
    rand = random(sizeof(RandomPlayerSpawnsMinigun));
	SetPlayerPos(playerid, RandomPlayerSpawnsMinigun[rand][0], RandomPlayerSpawnsMinigun[rand][1], RandomPlayerSpawnsMinigun[rand][2]);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    ResetPlayerWeapons(playerid);
   	GivePlayerWeapon(playerid, 38, 100000);
   	SetPlayerVirtualWorld(playerid,103);
	}
    if(DMZone[playerid] == 4)
    {
    rand = random(sizeof(RandomPlayerSpawnsCtd));
	SetPlayerPos(playerid, RandomPlayerSpawnsCtd[rand][0], RandomPlayerSpawnsCtd[rand][1], RandomPlayerSpawnsCtd[rand][2]);
	SetPlayerInterior(playerid, 5);
    ResetPlayerWeapons(playerid);
	GivePlayerWeapon(playerid, 16, 10);
	GivePlayerWeapon(playerid, 31, 1000);
	GivePlayerWeapon(playerid, 32, 1000);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
	SetPlayerVirtualWorld(playerid,102);
	}
    if(DMZone[playerid] == 5)
    {
    rand = random(sizeof(RandomPlayerSpawnsbf));
    MapLoading(playerid);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    SetPlayerFacingAngle(playerid,176.60);
    SetPlayerPos(playerid, RandomPlayerSpawnsbf[rand][0], RandomPlayerSpawnsbf[rand][1], RandomPlayerSpawnsbf[rand][2]);
    SetPlayerArmour(playerid,50);
    ResetPlayerWeapons(playerid);
   	GivePlayerWeapon(playerid,36,5000000);
    GivePlayerWeapon(playerid,39,5000000);
    GivePlayerWeapon(playerid,28,5000000);
    GivePlayerWeapon(playerid,30,5000000);
    SetPlayerVirtualWorld(playerid,111);
	}
    if(DMZone[playerid] == 6)
    {
    rand = random(sizeof(RandomPlayerSpawnsWar));
    MapLoading(playerid);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    SetPlayerFacingAngle(playerid,176.60);
	SetPlayerPos(playerid, RandomPlayerSpawnsWar[rand][0], RandomPlayerSpawnsWar[rand][1], RandomPlayerSpawnsWar[rand][2]);
    ResetPlayerWeapons(playerid);
	GivePlayerWeapon(playerid, 31, 800000);
	GivePlayerWeapon(playerid, 25, 800000);
	GivePlayerWeapon(playerid, 23, 800000);
	GivePlayerWeapon(playerid, 34, 800000);
	GivePlayerWeapon(playerid, 16, 1);
	SetPlayerVirtualWorld(playerid,100);
	}
    if(DMZone[playerid] == 7)
    {
    rand = random(sizeof(RandomPlayerSpawnsFlame));
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid,37,9999999);
   	SetPlayerPos(playerid, RandomPlayerSpawnsFlame[rand][0], RandomPlayerSpawnsFlame[rand][1], RandomPlayerSpawnsFlame[rand][2]);
   	SetPlayerVirtualWorld(playerid,101);
	}
    if(DMZone[playerid] == 8)
    {
    rand = random(sizeof(RandomPlayerSpawnsMinigun2));
    MapLoading(playerid);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    ResetPlayerWeapons(playerid);
   	GivePlayerWeapon(playerid, 38, 100000);
   	SetPlayerPos(playerid, RandomPlayerSpawnsMinigun2[rand][0], RandomPlayerSpawnsMinigun2[rand][1], RandomPlayerSpawnsMinigun2[rand][2]);
   	SetPlayerVirtualWorld(playerid,104);
	}
    if(DMZone[playerid] == 9)
    {
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid,25,5000000);
    GivePlayerWeapon(playerid,30,5000000);
    GivePlayerWeapon(playerid,24,5000000);
    SetPlayerSkin(playerid, 285);
    SetPlayerColor(playerid, YELLOW);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    SetPlayerPos(playerid,-2178.14, -263.84, 36.51);
    SetPlayerVirtualWorld(playerid,108);
    }
    if(DMZone[playerid] == 10)
    {
    ResetPlayerWeapons(playerid);
    GivePlayerWeapon(playerid,4,5000000);
    GivePlayerWeapon(playerid,30,5000000);
    GivePlayerWeapon(playerid,34,5000000);
    GivePlayerWeapon(playerid,27,5000000);
    SetPlayerSkin(playerid, 73);
    SetPlayerColor(playerid, GREEN);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    SetPlayerPos(playerid, -2142.16, -131.50, 36.51);
    SetPlayerVirtualWorld(playerid,108);
    }
    if(DMZone[playerid] == 11)
    {
    MapLoading(playerid);
    SetPlayerColor(playerid, BLUE);
    ResetPlayerWeapons(playerid);
    SetPlayerColor(playerid, BLUE);
   	SetPlayerPos(playerid,-1031.81,658.91,13.31); //Zombieplayerpos
   	GivePlayerWeapon(playerid,44,0); //zombiegun
   	GivePlayerWeapon(playerid,25,50); //zombiegun
   	GivePlayerWeapon(playerid,23,40); //zombiegun
   	GivePlayerWeapon(playerid,34,24); //zombiegun
   	GivePlayerWeapon(playerid,30,100); //ZombieGun
   	GivePlayerWeapon(playerid,9,5); //HumanGun
   	SetPlayerSkin(playerid,162); //ZombieSkin
   	SetPlayerWeather(playerid,19);
    DMZone[playerid] = 11;
    SetPlayerFacingAngle(playerid,180.00);
    SetPlayerTeam(playerid,10);
    SetPlayerVirtualWorld(playerid,104);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    }
    if(DMZone[playerid] == 12)
    {
    MapLoading(playerid);
    SetPlayerColor(playerid, GREEN);
    ResetPlayerWeapons(playerid);
   	SetPlayerPos(playerid,-875.32,659.59,14.75); //HunmanPs
    SetPlayerSkin(playerid,285); //HumanSkin
    GivePlayerWeapon(playerid,28,50); //HumanGun
   	GivePlayerWeapon(playerid,6,2); //HumanGun
   	GivePlayerWeapon(playerid,24,100); //HumanGun
   	GivePlayerWeapon(playerid,33,50); //HumanGun
   	GivePlayerWeapon(playerid,9,5); //HumanGun
   	GivePlayerWeapon(playerid,34,50); //HumanGun
   	SetPlayerWeather(playerid,19);
    SetPlayerFacingAngle(playerid,91.66);
    SetPlayerVirtualWorld(playerid,104);
    SetPlayerTeam(playerid,11);
    GameTextForPlayer(playerid, "~G~~W~deathmatch~N~~W~type ~r~/leavedm ~W~to exit", 5000, 5);
    }
	return 1;
    }
Reply
#2

If you kill player it will take more time to spawn.
Just SpawnPlayer(playerid); and it will spawn faster than killing player.
Reply
#3

Quote:
Originally Posted by Avi Raj
Посмотреть сообщение
If you kill player it will take more time to spawn.
Just SpawnPlayer(playerid); and it will spawn faster than killing player.
SpawnPlayer(playerid); wont work if player in dm what to do can i do like if(.....) else if.... or case 1 2 3...?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)