20.11.2009, 02:06
pawn Код:
#include <a_samp>
/*
The problem is that on my test server I see the visual bomb object deploy. But in
my actual server I see no bomb object deply. This possiblt only happens to ID 0.
Please // and make comments on the parts you change to fix it.
*/
//Bomb
forward BombTimer(playerid);
forward BombTimer2(playerid);
new bool: BombArmed[MAX_PLAYERS];
new bool: BombArmed2[MAX_PLAYERS];
new BombObject1[MAX_PLAYERS];
new BombObject2[MAX_PLAYERS];
new Float: BombX[MAX_PLAYERS], Float: BombY[MAX_PLAYERS], Float: BombZ[MAX_PLAYERS];
new BombTime;
new BombTime2;
new Difusing;
new BombSiteB;
new bomba;
new bombb;
new bool: DM20[MAX_PLAYERS];
new bool: DM21[MAX_PLAYERS];
new bool: PlayerIsInDM[MAX_PLAYERS];
new CSSPICKUP;
new Menu: CSS;
//#define COLOR_GREY 0xAFAFAFAA these are commented because it messed up the pawn colour on the forum
//#define COLOR_GREEN 0x33AA33AA
//CSS
forward BombSiteBdiffuse(playerid);
forward Difusingbomba(playerid);
public OnPlayerConnect(playerid)
{
CSS = CreateMenu("Choose Team", 2,200,100,150,100);
AddMenuItem(CSS, 0, "Counter Terrorists");
AddMenuItem(CSS, 0, "Terrorists");
DM20[playerid] = false;
DM21[playerid] = false;
PlayerIsInDM[playerid] = false;
BombArmed[playerid] = false;
BombArmed2[playerid] = false;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
DM20[playerid] = false;
DM21[playerid] = false;
BombArmed[playerid] = false;
BombArmed2[playerid] = false;
return 1;
}
public OnFilterScriptInit()
{
//BombA
bomba = CreatePickup(1254, 2, -954.4540,2956.6855,192.7991);
bombb = CreatePickup(1254, 2, -891.3544,2945.1326,192.5893);
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if (pickupid == CSSPICKUP)
{
TogglePlayerControllable(playerid, 0);
ShowMenuForPlayer(CSS, playerid);
return 1;
}
if (pickupid == bomba)
{
if(BombArmed[playerid] == false && DM21[playerid] == true)
{
new string [128];
format(string, sizeof(string), "The Bomb is ticking at A");
GameTextForAll(string, 5000, 1);
SendClientMessage(playerid, 0x0066FFAA, "Bomb Planted (exploding in 30 seconds).");
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
BombTime = SetTimerEx("BombTimer",30000,0, "d", playerid);
GetPlayerPos(playerid, BombX[playerid], BombY[playerid], BombZ[playerid]);
GetXYInFrontOfPlayer(playerid, BombX[playerid], BombY[playerid], 0.7);
BombObject1[playerid] = CreateObject(1252, BombX[playerid], BombY[playerid], BombZ[playerid] - 0.8,270,0,0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed[i] = true;
}
}
}
else if(BombArmed[playerid] == true && DM21[playerid] == true)
{
SendClientMessage(playerid, 0x0066FFAA, "The bomb is armed (30 Seconds) Do not let it become diffused!");
}
else if(BombArmed[playerid] == true && DM20[playerid] == true)
{
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
Difusing = SetTimerEx("Difusingbomba",5000,0, "d", playerid);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed[i] = false;
}
}
}
else if(BombArmed[playerid] == false && DM20[playerid] == true)
{
SendClientMessage(playerid, 0x0066FFAA, "This is bombsite A. You must not let the terrorists arm it");
}
return 1;
}
if (pickupid == bombb)
{
if(BombArmed2[playerid] == false && DM21[playerid] == true)
{
new string [128];
format(string, sizeof(string), "The Bomb is ticking at B");
GameTextForAll(string, 5000, 1);
SendClientMessage(playerid, 0x0066FFAA, "Bomb Planted (exploding in 30 seconds).");
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
BombTime2 = SetTimerEx("BombTimer2",30000,0, "d", playerid);
GetPlayerPos(playerid, BombX[playerid], BombY[playerid], BombZ[playerid]);
GetXYInFrontOfPlayer(playerid, BombX[playerid], BombY[playerid], 0.7);
BombObject2[playerid] = CreateObject(1252, BombX[playerid], BombY[playerid], BombZ[playerid] - 0.8,270,0,0);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed2[i] = true;
}
}
}
else if(BombArmed2[playerid] == true && DM21[playerid] == true)
{
SendClientMessage(playerid, 0x0066FFAA, "The bomb is armed (30 Seconds) Do not let it become diffused!");
}
else if(BombArmed2[playerid] == true && DM20[playerid] == true)
{
ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
BombSiteB = SetTimerEx("BombSiteBdiffuse",5000,0, "d", playerid);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed2[i] = false;
}
}
}
else if(BombArmed2[playerid] == false && DM20[playerid] == true)
{
SendClientMessage(playerid, 0x0066FFAA, "This is bombsite B. You must not let the terrorists arm it");
}
return 1;
}
return 0;
}
public BombTimer(playerid)
{
if(DM20[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has blown up bomb site A!", pName);
GameTextForAll(string, 5000, 1);
}
else if(DM21[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has blown up bomb site A!", pName);
GameTextForAll(string, 5000, 1);
}
DestroyObject(BombObject1[playerid]);
CreateExplosion(BombX[playerid], BombY[playerid], BombZ[playerid], 7, 50);
SendClientMessage(playerid, COLOR_GREY, "Bomb A exploded.");
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
KillTimer(BombTime);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed[i] = false;
}
}
return 1;
}
public BombTimer2(playerid)
{
if(DM20[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has blown up bomb site B!", pName);
GameTextForAll(string, 5000, 1);
}
else if(DM21[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has blown up bomb site B!", pName);
GameTextForAll(string, 5000, 1);
}
DestroyObject(BombObject2[playerid]);
CreateExplosion(BombX[playerid], BombY[playerid], BombZ[playerid], 7, 50);
SendClientMessage(playerid, COLOR_GREY, "Bomb B exploded.");
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
KillTimer(BombTime2);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed2[i] = false;
}
}
return 1;
}
public Difusingbomba(playerid)
{
if(DM20[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has diffused bomb site A!", pName);
GameTextForAll(string, 5000, 1);
}
else if(DM21[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has diffused bomb site A!", pName);
GameTextForAll(string, 5000, 1);
}
DestroyObject(BombObject1[playerid]);
KillTimer(BombTime);
KillTimer(Difusing);
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
SendClientMessage(playerid, COLOR_GREEN, "Bomb A Diffused.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed[i] = false;
}
}
return 1;
}
public BombSiteBdiffuse(playerid)
{
if(DM20[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has diffused bomb site B!", pName);
GameTextForAll(string, 5000, 1);
}
else if(DM21[playerid] == true)
{
new string [128];
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
format(string, sizeof(string), "%s has diffused bomb site B!", pName);
GameTextForAll(string, 5000, 1);
}
DestroyObject(BombObject2[playerid]);
KillTimer(BombTime2);
KillTimer(BombSiteB);
SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
SendClientMessage(playerid, COLOR_GREEN, "Bomb B Diffused.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
BombArmed2[i] = false;
}
}
return 1;
}
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
GetPlayerFacingAngle(playerid, a);
if (GetPlayerVehicleID(playerid)) {
GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
}