25.06.2013, 07:37
pawn Код:
forward OnTdmStart(TdmID);
public OnTdmStart(TdmID)
{
ClearKillList(); // Clears the kill-list.
DestroyAllVehicles(); // Destroys (removes) all the spawned vehicles
Current = TdmID; // Current will be the ID of the base that we just started. We do this so that we can use this ID later on (e.g. check /car command for the use).
//ClearPlayerVariables(); // Clears all saved variables for the crashed players.
ClearKillList(); // Clears the kill-list.
ServerLastPlayed = Current;
ElapsedTime = 0;
SetRecentRound(TdmID, TDM);
if(TdmPlayed >= MAX_TDM-10) {
for(new i = 0; i < MAX_TDM-10; i++) {
RecentTdm[i] = -1;
}
TdmPlayed = 0;
}
foreach(new i : Player) {
PlayerTextDrawShow(i, RoundText[i]);
if(Player[i][Team] == ATTACKER || Player[i][Team] == DEFENDER /*|| Player[i][Team] == REFEREE*/) {
HideEndRoundTextDraw(i);
if(Player[i][Spectating] == true) StopSpectate(i);
if(Player[i][InDM] == true) { //Make sure to remove player from DM, otherwise the player will have Player[playerid][Playing] = true and Player[playerid][InDM] = true, so you are saying that the player is both in Base and in DM.
Player[i][InDM] = false;
Player[i][DMReadd] = 0;
}
SetPlayerVirtualWorld(i, 2); //Set player virtual world to something different that that for lobby and DM so that they don't collide with each other. e.g. You shouldn't be able to see players in lobby or DM while you are in base.
SetPlayerInterior(i, TInterior[Current]);
TogglePlayerControllable(i, false); //Pause players.
SetPlayerCameraLookAt(i,TCPSpawn[Current][0],TCPSpawn[Current][1],TCPSpawn[Current][2]);
SetPlayerCameraPos(i,TCPSpawn[Current][0]+100,TCPSpawn[Current][1],TCPSpawn[Current][2]+80);
SetPlayerPos(i, TCPSpawn[Current][0], TCPSpawn[Current][1], TCPSpawn[Current][2]);
}
}
TdmZone = GangZoneCreate(TMin[Current][0],TMin[Current][1],TMax[Current][0],TMax[Current][1]);
GangZoneShowForAll(TdmZone,0x95000099);
ViewTimer = 4;
ViewTdmForPlayers();
new iString[160];
format(iString, sizeof(iString), "mapname TDM: %d", Current); //Will change the map name in samp.exe to your base id (e.g. Base: 4)
SendRconCommand(iString);
format(iString, sizeof(iString), "~w~~h~~h~TDM ~w~~h~~h~(~r~~h~~h~%d~w~~h~~h~)", Current);
TextDrawSetString(BaseID_VS, iString);
format(iString, sizeof(iString), "%s: %d - %s: %d", TeamName[ATTACKER], TeamScore[ATTACKER], TeamName[DEFENDER], TeamScore[DEFENDER]);
SetGameModeText(iString);
}
forward ViewTdmForPlayers();
public ViewTdmForPlayers()
{
ViewTimer--;
if(ViewTimer == 0) {
SpawnPlayersInTdm();
return 1;
}
foreach(new i : Player) {
if(Player[i][Team] == ATTACKER || Player[i][Team] == DEFENDER/*|| Player[i][Team] == REFEREE*/) {
PlayerPlaySound(i,1056,0.0,0.0,0.0);
switch(ViewTimer) {
case 4: {
SetPlayerCameraLookAt(i,TCPSpawn[Current][0],TCPSpawn[Current][1],TCPSpawn[Current][2]);
SetPlayerCameraPos(i,TCPSpawn[Current][0]+100,TCPSpawn[Current][1],TCPSpawn[Current][2]+80);
} case 3: {
SetPlayerCameraLookAt(i,TCPSpawn[Current][0],TCPSpawn[Current][1],TCPSpawn[Current][2]);
SetPlayerCameraPos(i,TCPSpawn[Current][0],TCPSpawn[Current][1]+100,TCPSpawn[Current][2]+80);
} case 2: {
SetPlayerCameraLookAt(i,TCPSpawn[Current][0],TCPSpawn[Current][1],TCPSpawn[Current][2]);
SetPlayerCameraPos(i,TCPSpawn[Current][0]-100,TCPSpawn[Current][1],TCPSpawn[Current][2]+80);
} case 1: {
SetPlayerCameraLookAt(i,TCPSpawn[Current][0],TCPSpawn[Current][1],TCPSpawn[Current][2]);
SetPlayerCameraPos(i,TCPSpawn[Current][0],TCPSpawn[Current][1]-100,TCPSpawn[Current][2]+80);
}
}
new iString[140];
format(iString,sizeof(iString),"~w~~h~~h~TDM starting in ~r~~h~~h~%d ~w~~h~~h~seconds~n~", ViewTimer);
PlayerTextDrawSetString(i, RoundText[i], iString);
}
}
return SetTimer("ViewTdmForPlayers", 1000, false);
}
SpawnPlayersInTdm()
{
foreach(new i : Player) {
PlayerTextDrawHide(i, RoundText[i]);
if(Player[i][Team] == ATTACKER || Player[i][Team] == DEFENDER /*|| Player[i][Team] == REFEREE*/) {
if(Player[i][Spectating] == true) StopSpectate(i);
Player[i][Playing] = true;
Player[i][WasInBase] = true;
Player[i][RoundKills] = 0;
Player[i][RoundDeaths] = 0;
Player[i][RoundDamage] = 0;
Player[i][shotsHit] = 0;
PlayerPlaySound(i, 1057, 0, 0, 0);
SetCameraBehindPlayer(i);
SetPlayerVirtualWorld(i, 2);
SetPlayerInterior(i, TInterior[Current]);
SetPlayerArmour(i, 100);
SetPlayerHealth(i, 100);
switch(Player[i][Team]) {
case ATTACKER: {
SetSpawnInfo(i, Player[i][Team], Skin[Player[i][Team]], TAttackerSpawn[Current][0] + random(6), TAttackerSpawn[Current][1] + random(6), TAttackerSpawn[Current][2]+0.5, 0, 0, 0, 0, 0, 0, 0);
// Player[i][IgnoreSpawn] = true;
SetPlayerColor(i, ATTACKER_PLAYING);
SpawnPlayerEx(i);
SAMP_SetPlayerTeam(i, 1);
if(TeamHPDamage == true) {
TextDrawShowForPlayer(i, AttackerTeam[0]);
TextDrawShowForPlayer(i, AttackerTeam[1]);
}
} case DEFENDER: {
SetSpawnInfo(i, Player[i][Team], Skin[Player[i][Team]], TDefenderSpawn[Current][0] + random(6), TDefenderSpawn[Current][1] + random(6), TDefenderSpawn[Current][2]+0.5, 0, 0, 0, 0, 0, 0, 0);
// Player[i][IgnoreSpawn] = true;
SetPlayerColor(i, DEFENDER_PLAYING);
SpawnPlayerEx(i);
SAMP_SetPlayerTeam(i, 2);
if(TeamHPDamage == true) {
TextDrawShowForPlayer(i, DefenderTeam[0]);
TextDrawShowForPlayer(i, DefenderTeam[1]);
}
} /*case REFEREE: {
SetSpawnInfo(i, Player[i][Team], Skin[Player[i][Team]], ACPSpawn[Current][0] + random(6), ACPSpawn[Current][1] + random(6), ACPSpawn[Current][2]+0.5, 0, 0, 0, 0, 0, 0, 0);
Player[i][IgnoreSpawn] = true;
SpawnPlayerEx(i);
SetPlayerColor(i, REFEREE_COLOR);
SAMP_SetPlayerTeam(i, 3);
} */
}
TogglePlayerControllable(i, true);
GivePlayerTdmWeapons(i);
new iString[160];
format(iString, sizeof(iString), "~n~~n~~w~~h~~h~Kills ~r~~h~~h~%d~n~~w~~h~~h~Damage ~r~~h~~h~%.0f~n~~w~~h~~h~Total Dmg ~r~~h~~h~%.0f", Player[i][RoundKills], Player[i][RoundDamage], Player[i][TotalDamage]);
PlayerTextDrawSetString(i, RoundKillDmgTDmg[i], iString);
}
switch(Player[i][Team]) {
case ATTACKER_SUB: {
if(TeamHPDamage == true) {
TextDrawShowForPlayer(i, AttackerTeam[0]);
TextDrawShowForPlayer(i, AttackerTeam[1]);
}
} case DEFENDER_SUB: {
if(TeamHPDamage == true) {
TextDrawShowForPlayer(i, DefenderTeam[0]);
TextDrawShowForPlayer(i, DefenderTeam[1]);
}
} case REFEREE: {
SetPlayerTeam(i, i);
}
}
}
ClearChat();
RoundMints = ConfigRoundTime;
RoundSeconds = 0;
TextDrawShowForAll(RoundStats);
AllowStartBase = true;
TdmStarted = true;
RadarFix();
}
forward AddPlayerToTdm(playerid);
public AddPlayerToTdm(playerid)
{
if(Player[playerid][Spectating] == true) {
StopSpectate(playerid);
SetTimerEx("AddPlayerToTdm", 500, false, "i", playerid);
return 1;
}
PlayerTextDrawHide(playerid, RoundText[playerid]);
if(Player[playerid][InDM] == true) { //Make sure to remove player from DM, otherwise the player will have Player[playerid][Playing] = true and Player[playerid][InDM] = true, so you are saying that the player is both in Base and in DM.
Player[playerid][InDM] = false;
Player[playerid][DMReadd] = 0;
}
if(Player[playerid][LastVehicle] != -1) {
DestroyVehicle(Player[playerid][LastVehicle]);
Player[playerid][LastVehicle] = -1;
}
Player[playerid][Playing] = true;
Player[playerid][WasInBase] = true;
Player[playerid][RoundKills] = 0;
Player[playerid][RoundDeaths] = 0;
Player[playerid][RoundDamage] = 0;
Player[playerid][shotsHit] = 0;
PlayerPlaySound(playerid, 1057, 0, 0, 0);
SetCameraBehindPlayer(playerid);
SetPlayerArmour(playerid, 100);
SetPlayerHealth(playerid, 100);
SetPlayerVirtualWorld(playerid, 2);
SetPlayerInterior(playerid, AInterior[Current]);
switch(Player[playerid][Team]) {
case ATTACKER: {
SetSpawnInfo(playerid, Player[playerid][Team], Skin[Player[playerid][Team]], AAttackerSpawn[Current][0] + random(6), AAttackerSpawn[Current][1] + random(6), AAttackerSpawn[Current][2]+0.5, 0, 0, 0, 0, 0, 0, 0);
// Player[playerid][IgnoreSpawn] = true;
SpawnPlayerEx(playerid);
SetPlayerColor(playerid, ATTACKER_PLAYING);
SetPlayerMapIcon(playerid, 59, AAttackerSpawn[Current][0], AAttackerSpawn[Current][1], AAttackerSpawn[Current][2], 59, 0, MAPICON_GLOBAL);
SAMP_SetPlayerTeam(playerid, 1);
if(TeamHPDamage == true) {
TextDrawShowForPlayer(playerid, AttackerTeam[0]);
TextDrawShowForPlayer(playerid, AttackerTeam[1]);
TextDrawHideForPlayer(playerid, DefenderTeam[0]);
TextDrawHideForPlayer(playerid, DefenderTeam[1]);
}
} case DEFENDER: {
SetSpawnInfo(playerid, Player[playerid][Team], Skin[Player[playerid][Team]], ADefenderSpawn[Current][0] + random(6), ADefenderSpawn[Current][1] + random(6), ADefenderSpawn[Current][2]+0.5, 0, 0, 0, 0, 0, 0, 0);
// Player[playerid][IgnoreSpawn] = true;
SpawnPlayerEx(playerid);
SetPlayerColor(playerid, DEFENDER_PLAYING);
SAMP_SetPlayerTeam(playerid, 2);
if(TeamHPDamage == true) {
TextDrawShowForPlayer(playerid, DefenderTeam[0]);
TextDrawShowForPlayer(playerid, DefenderTeam[1]);
TextDrawHideForPlayer(playerid, AttackerTeam[0]);
TextDrawHideForPlayer(playerid, AttackerTeam[1]);
}
} case REFEREE: {
SetSpawnInfo(playerid, Player[playerid][Team], Skin[Player[playerid][Team]], ACPSpawn[Current][0] + random(6), ACPSpawn[Current][1] + random(6), ACPSpawn[Current][2]+0.5, 0, 0, 0, 0, 0, 0, 0);
// Player[playerid][IgnoreSpawn] = true;
SpawnPlayerEx(playerid);
SetPlayerColor(playerid, REFEREE_COLOR);
SAMP_SetPlayerTeam(playerid, 3);
}
}
if(RoundPaused == false) TogglePlayerControllable(playerid, true);
else TogglePlayerControllable(playerid, false);
GivePlayerTdmWeapons(playerid);
new iString[160];
format(iString, sizeof(iString), "~n~~n~~w~~h~~h~Kills ~r~~h~~h~%d~n~~w~~h~~h~Damage ~r~~h~~h~%.0f~n~~w~~h~~h~Total Dmg ~r~~h~~h~%.0f", Player[playerid][RoundKills], Player[playerid][RoundDamage], Player[playerid][TotalDamage]);
PlayerTextDrawSetString(playerid, RoundKillDmgTDmg[playerid], iString);
// RadarFix();
foreach(new i : Player) {
OnPlayerStreamIn(i, playerid);
OnPlayerStreamIn(playerid, i);
}
return 1;
}
GivePlayerTdmWeapons(playerid)
{
ResetPlayerWeapons(playerid);
if(Player[playerid][Team] != REFEREE) {
GivePlayerWeapon(playerid, DEAGLE, 9999);
GivePlayerWeapon(playerid, SHOTGUN, 9999);
GivePlayerWeapon(playerid, M4, 9999);
GivePlayerWeapon(playerid, MP5, 9999);
GivePlayerWeapon(playerid, SNIPER, 9999);
SetPlayerArmedWeapon(playerid, DEAGLE);
/*MenuID[playerid] = 1;
ShowTDMWeaponMenu(playerid, Player[playerid][Team]);*/
if(!IsPlayerInAnyVehicle(playerid)) SetPlayerVirtualWorld(playerid, playerid+100);
}
}