25.11.2009, 14:27
This is OnPlayerSpawn: (it doesn't fit in 1 replay
)
)pawn Код:
public OnPlayerSpawn(playerid)
{ if(pdebug == 1){printf("[DEBUG] OnPlayerSpawn(%d)", playerid);}
// Spectate shit:
if(PlayerMaySpectate[playerid] == 1)
{
if(PlayersOnline > 1)
{
new found = 0;
for(new i = 0; i < MAX_SLOTS; i++)
{
if(found == 0)
{
if(IsPlayerConnected(i))
{
if(PlayerAvailableToSpectate[i] == 1)
{
if(IsPlayerSpawned[i] == 1) // Is the spectateid player spawned?
{
found = 1;
new string[36];
format(string, sizeof(string),"Player: %s [%d]", PlayerName[i], i);
GameTextForPlayer(playerid, string, 3000, 4);
TogglePlayerSpectating(playerid, true);
KillTimer(CountdownTimer[playerid]);
CheckPlayerSpectating(playerid, i);
CountdownTimer[playerid] = SetTimerEx("CheckPlayerSpectating", 1000, true, "dd", playerid, i);
TextDrawShowForPlayer(playerid, CountdownTextdraw[playerid]);
SetPlayerInterior(playerid, GetPlayerInterior(i));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(i));
PlayerMaySpectate[playerid] = 0;
PlayerAvailableToSpectate[playerid] = 0;
GettingSpectatedID[i] = playerid;
if(IsPlayerInAnyVehicle(i) == 1) // Is the spectateid player in a vehicle?
{
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(i));
SpectateType[playerid] = 1;
}
else // Is the spectateid player on foot?
{
PlayerSpectatePlayer(playerid, i);
SpectateType[playerid] = 2;
}
return 1;
}
}
}
}
}
if(found == 0) // Nobody was spawned or 'AvailableToSpectate'.
{
IsPlayerSpawned[playerid] = 1;
PlayerAvailableToSpectate[playerid] = 1;
PlayerMaySpectate[playerid] = 1;
GettingSpectatedID[playerid] = INVALID_PLAYER_ID;
// Player get's spawned...
}
}
else // There are not enough players to spectate.
{
IsPlayerSpawned[playerid] = 1;
PlayerAvailableToSpectate[playerid] = 1;
PlayerMaySpectate[playerid] = 1;
GettingSpectatedID[playerid] = INVALID_PLAYER_ID;
// Player get's spawned...
}
}
else // Player already did a spectate last time.
{
IsPlayerSpawned[playerid] = 1;
PlayerAvailableToSpectate[playerid] = 1;
PlayerMaySpectate[playerid] = 1;
GettingSpectatedID[playerid] = INVALID_PLAYER_ID;
// Player get's spawned...
}
// Normal stuff:
SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
SetPlayerArmour(playerid, PlayerInfo[playerid][pArmour]);
StopSoundForPlayer(playerid);
gTeam[playerid] = PlayerInfo[playerid][pTeam]; // Set the player in a team.
SetPlayerSpawn(playerid); // Set the player's spawn place.
SetPlayerWeapons(playerid); // Set the player's spawn weapons.
SetPlayerTeamColor(playerid); // Set the player's spawn color.
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
// To sync mission checkpoints.
if(CheckpointBusyX != 0.0 && CheckpointBusyY != 0.0 && CheckpointBusyZ != 0.0){SetPlayerCheckpoint(playerid, CheckpointBusyX, CheckpointBusyY, CheckpointBusyZ, CheckpointBusyS);}
// To sync mission vehicles.
if(SearchedVehicle != 0){SetVehicleParamsForPlayer(SearchedVehicle, playerid, 1, 0);}
if(PlayerLoggedIn[playerid] == 0){GameTextForPlayer(playerid, "~w~Welcome,~n~In order to play you need to create an account, type ~n~~r~/register (password)~w~ to register.", 20000, 4);}
return 1;
}

