rendered paste body// 0.2 Fixed version of CS:All in One made by FeaR
#include <a_samp>
#include <core>
static gTeam[MAX_PLAYERS];
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_YELLOW2 0xF5DEB3AA
#define COLOR_LIGHTRED 0xFF6347AA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define CARS 7
new rndtimer;
new starttimer;
new bombtimer;
new defusetimer;
new Terrorists = 0;
new CTerrorists = 0;
new locked = 0;
new ShowMessage = 0;
new MapTimeCount = 0;
new MapTime = 300;
new RoundStarted = 0;
new ActiveMap = 0;
new BombExploded = 0;
new BombDropped = 0;
new BombPlaced = 0;
new BombTime = 0;
new HoldingBomb = 999;
new PlacingBomb = 999;
new DefuseBomb = 999;
new Float:Pos[MAX_PLAYERS][3];
new Float:PlayerPlacingBomb[MAX_PLAYERS][3];
new Float:PlayerDefuseBomb[MAX_PLAYERS][3];
new PlayingRound[MAX_PLAYERS];
new Kills[MAX_PLAYERS];
new TeamKills[MAX_PLAYERS];
enum gInfo
{
Gun1,
Gun2,
Ammo1,
Ammo2,
Float:Health,
};
new PlayerGuns[MAX_PLAYERS][gInfo];
enum bInfo
{
Float:MaxX,
Float:MinX,
Float:MaxY,
Float:MinY,
};
new Bounds[bInfo];
enum mInfo
{
mTitle[64],
Float:mTSpawn[3],
Float:mCTSpawn[3],
Float:mTAngle,
Float:mCTAngle,
Float:mBomb[3],
Float:mLimit1[3],
Float:mLimit2[3],
Float:mLimit3[3],
Float:mLimit4[3],
};
new MapMaking[MAX_PLAYERS][mInfo];
enum rInfo
{
pMaker[MAX_PLAYER_NAME],
pTitle[64],
Float:pTSpawn[3],
Float:pCTSpawn[3],
Float:pTAngle,
Float:pCTAngle,
Float:pBomb[3],
Float:pLimit1[3],
Float:pLimit2[3],
Float:pLimit3[3],
Float:pLimit4[3],
};
new MapInfo[rInfo];
new MapNames[6][128] = {
{"File: ffo | Mapname: Fight For Oil"},
{"File: fobw | Mapname: Fight of Big Wheel"},
{"File: jungle | Mapname: Jungle"},
{"File: rocks | Mapname: Rocks"},
{"File: area51 | Mapname: The Dust"},
{"File: chicken | Mapname: Chicken Fight"}
};
main()
{
print("\n----------------------------------");
print(" Counter Strike: All in One");
print("----------------------------------\n");
}
public OnGameModeInit()
{
print("GameModeInit()");
SetGameModeText("GF-RP: Event");
ShowNameTags(0);
ShowPlayerMarkers(0);
AddPlayerClass(285,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);//Counter Terrorist
AddPlayerClass(284,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);
AddPlayerClass(286,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);
AddPlayerClass(164,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);
AddPlayerClass(254,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);//Terrorist
AddPlayerClass(248,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);
AddPlayerClass(247,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);
AddPlayerClass(100,1958.3783,1343.1572,1100.3746,269.1425,0,0,0,0,0,0);
AddStaticVehicle(522,1667.4299,-1237.8550,233.3750,267.0053,6,1);
AddStaticVehicle(447,1459.2539,-689,94.7500,267.0053,6,1);
AddStaticVehicle(522,1459.2539,-683,94.7500,267.0053,6,1);
AddStaticVehicle(451,1459.2539,-677,94.7500,267.0053,6,1);
AddStaticVehicle(451,1459.2539,-674,94.7500,267.0053,6,1);
AddStaticVehicle(487,1504.0309,-695.0297,94.4567,178.9508,-1,-1); // maverick
AddStaticVehicle(487,1490.2667,-695.1058,94.4574,180.3512,-1,-1); // maverick
SetTimer("MapCheck", 500, 1);
SetTimer("OverallCheck", 1000, 1);
return 1;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
clear(playerid)
{
if(IsPlayerConnected(playerid))
{
for(new a=1;a<=10;a++)
{
SendClientMessage(playerid,0xFFFFFFFF,"\n");
}
}
return 1;
}
SendTeamMessage(team, color, string[])
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == team)
{
SendClientMessage(i, color, string);
}
}
}
}
forward MapCheck();
public MapCheck()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
SetPlayerScore(i, Kills[i]);
if(ActiveMap > 0 && RoundStarted > 0 && PlayingRound[i] != 0)
{
new Float:x,Float:y,Float:z;
GetPlayerPos(i,x,y,z);
if(x > Bounds[MaxX]) { SetPlayerPos(i,Bounds[MaxX]-2,y,z); }
if(y > Bounds[MaxY]) { SetPlayerPos(i,x,Bounds[MaxY]-19,z); }
if(x < Bounds[MinX]) { SetPlayerPos(i,Bounds[MinX]+1,y,z); }
if(y < Bounds[MinY]) { SetPlayerPos(i,x,Bounds[MinY]+1,z); }
}
}
}
return 1;
}
forward OverallCheck();
public OverallCheck()
{
new string[256];
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(6.0,i,MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2]) && HoldingBomb == i)
{
GameTextForPlayer(i, "~w~Type /bomb to plant the bomb", 5000, 3);
}
else if(PlayerToPoint(6.0,i,MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2]) && gTeam[i] == 1 && BombPlaced == 1)
{
GameTextForPlayer(i, "~w~Type /diffuse to diffuse the bomb", 5000, 3);
}
}
}
if(RoundStarted > 0)
{
ShowMessage += 1;
if(ShowMessage >= 45)
{
ShowMessage = 0;
new time = 300 - MapTimeCount;
if(time > 60)
{
time = time / 60;
format(string, sizeof(string), "Terrorists Alive: %d | Counter Terrorists Alive: %d | Round Time left: %d Minutes.", Terrorists, CTerrorists, time);
}
else
{
format(string, sizeof(string), "Terrorists Alive: %d | Counter Terrorists Alive: %d | Round Time left: %d Seconds.", Terrorists, CTerrorists, time);
}
SendClientMessageToAll(COLOR_YELLOW2, string);
}
MapTimeCount += 1;
if(CTerrorists > 0 && Terrorists < 1 && BombPlaced != 1)
{
CTWon();
}
else if(Terrorists > 0 && CTerrorists < 1)
{
TWon();
}
else if(MapTimeCount >= MapTime)
{
MapTimeCount = 0;
if(CTerrorists > Terrorists)
{
CTWon();
}
else if(Terrorists > CTerrorists)
{
TWon();
}
else
{
new rand = random(1);
if(rand == 1) { CTWon(); }
else { TWon(); }
}
}
}
if(BombPlaced > 0)
{
BombTime ++;
if(BombTime >= 30)
{
GameTextForAll("~w~bomb exploded", 5000, 3);
BombExploded = 1;
BombTime = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerToPoint(80.0,i,MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2]))
{
PlayerPlaySound(i, 1148, 0.0, 0.0, 0.0);
}
if(PlayerToPoint(60.0,i,MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2]))
{
SetPlayerHealth(i, 0.0);
}
}
}
TWon();
}
}
return 1;
}
CTWon()
{
RoundStarted = 0;
SendClientMessageToAll(0xF1DA7CFF,"Counter-Terrorists have won the round.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == 1)
{
GivePlayerMoney(i, 1500);
}
}
}
rndtimer = SetTimer("NewRound", 5000, 0);
return 1;
}
TWon()
{
RoundStarted = 0;
SendClientMessageToAll(0xF1DA7CFF,"Terrorists have won the round.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(gTeam[i] == 2)
{
GivePlayerMoney(i, 1500);
}
}
}
rndtimer = SetTimer("NewRound", 5000, 0);
return 1;
}
StopMap()
{
KillTimer(rndtimer);
KillTimer(starttimer);
KillTimer(bombtimer);
KillTimer(defusetimer);
RoundStarted = 0;
ShowMessage = 0;
MapTimeCount = 0;
ActiveMap = 0;
HoldingBomb = 999;
PlacingBomb = 999;
DefuseBomb = 999;
BombExploded = 0;
BombPlaced = 0;
BombTime = 0;
Terrorists = 0;
CTerrorists = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
DisablePlayerCheckpoint(i);
PlayingRound[i] = 0;
TogglePlayerControllable(i, 1);
SpawnPlace(i);
ResetPlayerWeapons(i);
PlayerGuns[i][Gun1] = 0;
PlayerGuns[i][Gun2] = 0;
PlayerGuns[i][Ammo1] = 0;
PlayerGuns[i][Ammo2] = 0;
PlayerGuns[i][Health] = 100.0;
}
}
return 1;
}
forward NewRound();
public NewRound()
{
RoundStarted = 0;
ShowMessage = 0;
Terrorists = 0;
CTerrorists = 0;
BombDropped = 0;
MapTimeCount = 0;
HoldingBomb = 999;
PlacingBomb = 999;
DefuseBomb = 999;
BombPlaced = 0;
BombTime = 0;
BombExploded = 0;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
PlayingRound[i] = 1;
GivePlayerMoney(i, 1000);
if(GetPlayerMoney(i) > 16000)
{
ResetPlayerMoney(i);
GivePlayerMoney(i, 16000);
}
ResetPlayerWeapons(i);
SendClientMessage(i, COLOR_WHITE, "Type /b to buy equipment.");
DisablePlayerCheckpoint(i);
TogglePlayerControllable(i, 0);
SpawnPlace(i);
if(gTeam[i] == 2 && HoldingBomb == 999)
{
HoldingBomb = i;
GameTextForPlayer(HoldingBomb, "~w~You have the bomb", 5000, 3);
PlayerPlaySound(HoldingBomb, 1095, 0.0, 0.0, 0.0);
}
if(gTeam[i] == 1)
{
CTerrorists ++;
}
else if(gTeam[i] == 2)
{
Terrorists ++;
}
}
}
starttimer = SetTimer("StartRound", 25000, 0);
return 1;
}
forward StartRound();
public StartRound()
{
new Gun1Name[64];
new Gun2Name[64];
new string[256];
MapTimeCount = 0;
RoundStarted = 1;
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayingRound[i] != 0)
{
SendClientMessage(i, COLOR_WHITE,"RADIO: Go, go, go!");
if(PlayerGuns[i][Gun1] > 0)
{
GetWeaponName(PlayerGuns[i][Gun1], Gun1Name, sizeof(Gun1Name));
format(string, sizeof(string), "You spawned with a %s with %d bullets.",Gun1Name,PlayerGuns[i][Ammo1]);
SendClientMessage(i, COLOR_YELLOW2, string);
}
if(PlayerGuns[i][Gun2] > 0)
{
GetWeaponName(PlayerGuns[i][Gun2], Gun2Name, sizeof(Gun2Name));
format(string, sizeof(string), "You spawned with a %s with %d bullets.",Gun2Name,PlayerGuns[i][Ammo2]);
SendClientMessage(i, COLOR_YELLOW2, string);
}
new time = 300 - MapTimeCount;
time = time / 60;
format(string, sizeof(string), "Terrorists Alive: %d | Counter Terrorists Alive: %d | Round Time left: %d Minutes.", Terrorists, CTerrorists, time);
SendClientMessage(i, COLOR_YELLOW2, string);
TogglePlayerControllable(i, 1);
GiveWeapons(i);
SetPlayerCheckpoint(i, MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2],6.0);
}
}
}
return 1;
}
forward PlaceBomb();
public PlaceBomb()
{
if(IsPlayerConnected(PlacingBomb))
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(PlacingBomb, X,Y,Z);
if(X==PlayerPlacingBomb[PlacingBomb][0] && Y==PlayerPlacingBomb[PlacingBomb][1] && Z==PlayerPlacingBomb[PlacingBomb][2])
{
GameTextForAll("~w~Bomb has been planted~n~~r~30 seconds till ignition", 5000, 3);
SendClientMessage(PlacingBomb, COLOR_YELLOW2, "Bomb planted.");
HoldingBomb = 999;
PlacingBomb = 999;
BombPlaced = 1;
}
else
{
SendClientMessage(PlacingBomb, COLOR_GREY, " You left the spot, Bomb Placing failed !");
}
}
return 1;
}
forward Defusing();
public Defusing()
{
if(IsPlayerConnected(DefuseBomb))
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(DefuseBomb, X,Y,Z);
if(X==PlayerDefuseBomb[DefuseBomb][0] && Y==PlayerDefuseBomb[DefuseBomb][1] && Z==PlayerDefuseBomb[DefuseBomb][2] && BombExploded != 1)
{
GameTextForAll("~w~Bomb has been defused", 5000, 3);
DefuseBomb = 999;
BombPlaced = 0;
CTWon();
}
else
{
SendClientMessage(DefuseBomb, COLOR_GREY, " You left the spot, Bomb Diffusing failed !");
}
}
return 1;
}
SpawnPlace(playerid)
{
if(IsPlayerConnected(playerid))
{
SetPlayerInterior(playerid, 0);
if(ActiveMap > 0)
{
if(PlayingRound[playerid] != 0)
{
if(gTeam[playerid] == 1)
{
SetPlayerPos(playerid, MapInfo[pCTSpawn][0],MapInfo[pCTSpawn][1],MapInfo[pCTSpawn][2]);
SetPlayerFacingAngle(playerid, MapInfo[pCTAngle]);
}
else if(gTeam[playerid] == 2)
{
SetPlayerPos(playerid, MapInfo[pTSpawn][0],MapInfo[pTSpawn][1],MapInfo[pTSpawn][2]);
SetPlayerFacingAngle(playerid, MapInfo[pTAngle]);
}
}
else
{
//Player must be spectating and be placed somewhere safe
SendClientMessage(playerid, COLOR_YELLOW2, "You've been killed, wait for the next round.");
SetPlayerPos(playerid, 2223.8,-1147.1,1025.7);
SetPlayerInterior(playerid, 15);
TogglePlayerControllable(playerid, 0);
}
}
else
{
SetPlayerPos(playerid, 2223.8,-1147.1,1025.7);
SetPlayerFacingAngle(playerid, 270.0);
SetPlayerInterior(playerid,15);
}
}
return 1;
}
GiveWeapons(playerid)
{
if(IsPlayerConnected(playerid))
{
if(ActiveMap > 0 && RoundStarted > 0)
{
GivePlayerWeapon(playerid, 4, 1);
GivePlayerWeapon(playerid, 46, 1);
if(PlayerGuns[playerid][Gun1] > 0) { GivePlayerWeapon(playerid, PlayerGuns[playerid][Gun1],PlayerGuns[playerid][Ammo1]); }
SetPlayerHealth(playerid, PlayerGuns[playerid][Health]);
if(gTeam[playerid] == 1)//CT
{
if(PlayerGuns[playerid][Gun2] == 0)
{
GivePlayerWeapon(playerid, 23, 70);
}
else
{
GivePlayerWeapon(playerid, PlayerGuns[playerid][Gun2],PlayerGuns[playerid][Ammo2]);
}
}
else if(gTeam[playerid] == 2)//T
{
if(PlayerGuns[playerid][Gun2] == 0)
{
GivePlayerWeapon(playerid, 22, 70);
}
else
{
GivePlayerWeapon(playerid, PlayerGuns[playerid][Gun2],PlayerGuns[playerid][Ammo2]);
}
}
}
}
return 1;
}
SaveMap(playerid,name[])
{
if(IsPlayerConnected(playerid))
{
new coordsstring[256];
new mapname[64];
new var[128];
new makername[MAX_PLAYER_NAME];
GetPlayerName(playerid, makername, sizeof(makername));
format(mapname, sizeof(mapname), "%s.map",name);
new File: hFile = fopen(mapname, io_write);
format(var, 128, "Maker=%s\n", makername);fwrite(hFile, var);
format(var, 128, "Title=%s\n", MapMaking[playerid][mTitle]);fwrite(hFile, var);
format(var, 128, "TAngle=%f\n", MapMaking[playerid][mTAngle]);fwrite(hFile, var);
format(var, 128, "CTAngle=%f\n", MapMaking[playerid][mCTAngle]);fwrite(hFile, var);
format(var, 128, "TSpawnX=%f\n", MapMaking[playerid][mTSpawn][0]);fwrite(hFile, var);
format(var, 128, "TSpawnY=%f\n", MapMaking[playerid][mTSpawn][1]);fwrite(hFile, var);
format(var, 128, "TSpawnZ=%f\n", MapMaking[playerid][mTSpawn][2]);fwrite(hFile, var);
format(var, 128, "CTSpawnX=%f\n", MapMaking[playerid][mCTSpawn][0]);fwrite(hFile, var);
format(var, 128, "CTSpawnY=%f\n", MapMaking[playerid][mCTSpawn][1]);fwrite(hFile, var);
format(var, 128, "CTSpawnZ=%f\n", MapMaking[playerid][mCTSpawn][2]);fwrite(hFile, var);
format(var, 128, "BombX=%f\n", MapMaking[playerid][mBomb][0]);fwrite(hFile, var);
format(var, 128, "BombY=%f\n", MapMaking[playerid][mBomb][1]);fwrite(hFile, var);
format(var, 128, "BombZ=%f\n", MapMaking[playerid][mBomb][2]);fwrite(hFile, var);
format(var, 128, "Limit1X=%f\n", MapMaking[playerid][mLimit1][0]);fwrite(hFile, var);
format(var, 128, "Limit1Y=%f\n", MapMaking[playerid][mLimit1][1]);fwrite(hFile, var);
format(var, 128, "Limit1Z=%f\n", MapMaking[playerid][mLimit1][2]);fwrite(hFile, var);
format(var, 128, "Limit2X=%f\n", MapMaking[playerid][mLimit2][0]);fwrite(hFile, var);
format(var, 128, "Limit2Y=%f\n", MapMaking[playerid][mLimit2][1]);fwrite(hFile, var);
format(var, 128, "Limit2Z=%f\n", MapMaking[playerid][mLimit2][2]);fwrite(hFile, var);
format(var, 128, "Limit3X=%f\n", MapMaking[playerid][mLimit3][0]);fwrite(hFile, var);
format(var, 128, "Limit3Y=%f\n", MapMaking[playerid][mLimit3][1]);fwrite(hFile, var);
format(var, 128, "Limit3Z=%f\n", MapMaking[playerid][mLimit3][2]);fwrite(hFile, var);
format(var, 128, "Limit4X=%f\n", MapMaking[playerid][mLimit4][0]);fwrite(hFile, var);
format(var, 128, "Limit4Y=%f\n", MapMaking[playerid][mLimit4][1]);fwrite(hFile, var);
format(var, 128, "Limit4Z=%f\n", MapMaking[playerid][mLimit4][2]);fwrite(hFile, var);
fclose(hFile);
format(coordsstring, sizeof(coordsstring), "%s Map Saved.",name);
SendClientMessage(playerid, COLOR_WHITE,coordsstring);
}
return 1;
}
LoadMap(playerid,name[])
{
if(IsPlayerConnected(playerid))
{
new strFromFile2[128];
new mapname[64];
format(mapname, sizeof(mapname), "%s.map",name);
new File: file = fopen(mapname, io_read);
if (file)
{
new key[ 256 ] , val[ 256 ];
new Data[ 256 ];
while ( fread( file , Data , sizeof( Data ) ) )
{
key = ini_GetKey( Data );
if( strcmp( key , "Maker" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(MapInfo[pMaker], val, 0, strlen(val), 255); }
if( strcmp( key , "Title" , true ) == 0 ) { val = ini_GetValue( Data ); strmid(MapInfo[pTitle], val, 0, strlen(val), 255); }
if( strcmp( key , "TAngle" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pTAngle] = floatstr( val ); }
if( strcmp( key , "CTAngle" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pCTAngle] = floatstr( val ); }
if( strcmp( key , "TSpawnX" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pTSpawn][0] = floatstr( val ); }
if( strcmp( key , "TSpawnY" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pTSpawn][1] = floatstr( val ); }
if( strcmp( key , "TSpawnZ" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pTSpawn][2] = floatstr( val ); }
if( strcmp( key , "CTSpawnX" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pCTSpawn][0] = floatstr( val ); }
if( strcmp( key , "CTSpawnY" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pCTSpawn][1] = floatstr( val ); }
if( strcmp( key , "CTSpawnZ" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pCTSpawn][2] = floatstr( val ); }
if( strcmp( key , "BombX" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pBomb][0] = floatstr( val ); }
if( strcmp( key , "BombY" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pBomb][1] = floatstr( val ); }
if( strcmp( key , "BombZ" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pBomb][2] = floatstr( val ); }
if( strcmp( key , "Limit1X" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit1][0] = floatstr( val ); }
if( strcmp( key , "Limit1Y" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit1][1] = floatstr( val ); }
if( strcmp( key , "Limit1Z" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit1][2] = floatstr( val ); }
if( strcmp( key , "Limit2X" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit2][0] = floatstr( val ); }
if( strcmp( key , "Limit2Y" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit2][1] = floatstr( val ); }
if( strcmp( key , "Limit2Z" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit2][2] = floatstr( val ); }
if( strcmp( key , "Limit3X" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit3][0] = floatstr( val ); }
if( strcmp( key , "Limit3Y" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit3][1] = floatstr( val ); }
if( strcmp( key , "Limit3Z" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit3][2] = floatstr( val ); }
if( strcmp( key , "Limit4X" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit4][0] = floatstr( val ); }
if( strcmp( key , "Limit4Y" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit4][1] = floatstr( val ); }
if( strcmp( key , "Limit4Z" , true ) == 0 ) { val = ini_GetValue( Data ); MapInfo[pLimit4][2] = floatstr( val ); }
}
fclose(file);
format(strFromFile2, sizeof(strFromFile2), "%s Map Loaded.",name);
SendClientMessage(playerid, COLOR_LIGHTRED,strFromFile2);
format(strFromFile2, sizeof(strFromFile2), "Playing Map: %s | By : %s",MapInfo[pTitle],MapInfo[pMaker]);
SendClientMessageToAll(COLOR_LIGHTRED, strFromFile2);
if(MapInfo[pLimit1][0] > MapInfo[pLimit2][0] && MapInfo[pLimit1][0] > MapInfo[pLimit3][0] && MapInfo[pLimit1][0] > MapInfo[pLimit4][0]) { Bounds[MaxX] = MapInfo[pLimit1][0]; }
else if(MapInfo[pLimit2][0] > MapInfo[pLimit1][0] && MapInfo[pLimit2][0] > MapInfo[pLimit3][0] && MapInfo[pLimit2][0] > MapInfo[pLimit4][0]) { Bounds[MaxX] = MapInfo[pLimit2][0]; }
else if(MapInfo[pLimit3][0] > MapInfo[pLimit1][0] && MapInfo[pLimit3][0] > MapInfo[pLimit2][0] && MapInfo[pLimit3][0] > MapInfo[pLimit4][0]) { Bounds[MaxX] = MapInfo[pLimit3][0]; }
else if(MapInfo[pLimit4][0] > MapInfo[pLimit1][0] && MapInfo[pLimit4][0] > MapInfo[pLimit2][0] && MapInfo[pLimit4][0] > MapInfo[pLimit3][0]) { Bounds[MaxX] = MapInfo[pLimit4][0]; }
if(MapInfo[pLimit1][0] < MapInfo[pLimit2][0] && MapInfo[pLimit1][0] < MapInfo[pLimit3][0] && MapInfo[pLimit1][0] < MapInfo[pLimit4][0]) { Bounds[MinX] = MapInfo[pLimit1][0]; }
else if(MapInfo[pLimit2][0] < MapInfo[pLimit1][0] && MapInfo[pLimit2][0] < MapInfo[pLimit3][0] && MapInfo[pLimit2][0] < MapInfo[pLimit4][0]) { Bounds[MinX] = MapInfo[pLimit2][0]; }
else if(MapInfo[pLimit3][0] < MapInfo[pLimit1][0] && MapInfo[pLimit3][0] < MapInfo[pLimit2][0] && MapInfo[pLimit3][0] < MapInfo[pLimit4][0]) { Bounds[MinX] = MapInfo[pLimit3][0]; }
else if(MapInfo[pLimit4][0] < MapInfo[pLimit1][0] && MapInfo[pLimit4][0] < MapInfo[pLimit2][0] && MapInfo[pLimit4][0] < MapInfo[pLimit3][0]) { Bounds[MinX] = MapInfo[pLimit4][0]; }
if(MapInfo[pLimit1][1] > MapInfo[pLimit2][1] && MapInfo[pLimit1][1] > MapInfo[pLimit3][1] && MapInfo[pLimit1][1] > MapInfo[pLimit4][1]) { Bounds[MaxY] = MapInfo[pLimit1][1]; }
else if(MapInfo[pLimit2][1] > MapInfo[pLimit1][1] && MapInfo[pLimit2][1] > MapInfo[pLimit3][1] && MapInfo[pLimit2][1] > MapInfo[pLimit4][1]) { Bounds[MaxY] = MapInfo[pLimit2][1]; }
else if(MapInfo[pLimit3][1] > MapInfo[pLimit1][1] && MapInfo[pLimit3][1] > MapInfo[pLimit2][1] && MapInfo[pLimit3][1] > MapInfo[pLimit4][1]) { Bounds[MaxY] = MapInfo[pLimit3][1]; }
else if(MapInfo[pLimit4][1] > MapInfo[pLimit1][1] && MapInfo[pLimit4][1] > MapInfo[pLimit2][1] && MapInfo[pLimit4][1] > MapInfo[pLimit3][1]) { Bounds[MaxY] = MapInfo[pLimit4][1]; }
if(MapInfo[pLimit1][1] < MapInfo[pLimit2][1] && MapInfo[pLimit1][1] < MapInfo[pLimit3][1] && MapInfo[pLimit1][1] < MapInfo[pLimit4][1]) { Bounds[MinY] = MapInfo[pLimit1][1]; }
else if(MapInfo[pLimit2][1] < MapInfo[pLimit1][1] && MapInfo[pLimit2][1] < MapInfo[pLimit3][1] && MapInfo[pLimit2][1] < MapInfo[pLimit4][1]) { Bounds[MinY] = MapInfo[pLimit2][1]; }
else if(MapInfo[pLimit3][1] < MapInfo[pLimit1][1] && MapInfo[pLimit3][1] < MapInfo[pLimit2][1] && MapInfo[pLimit3][1] < MapInfo[pLimit4][1]) { Bounds[MinY] = MapInfo[pLimit3][1]; }
else if(MapInfo[pLimit4][1] < MapInfo[pLimit1][1] && MapInfo[pLimit4][1] < MapInfo[pLimit2][1] && MapInfo[pLimit4][1] < MapInfo[pLimit3][1]) { Bounds[MinY] = MapInfo[pLimit4][1]; }
ActiveMap = 1;
}
else
{
SendClientMessage(playerid, COLOR_LIGHTRED,"Run File not found.");
}
}
return 1;
}
ini_GetKey( line[] )
{
new keyRes[256];
keyRes[0] = 0;
if ( strfind( line , "=" , true ) == -1 ) return keyRes;
strmid( keyRes , line , 0 , strfind( line , "=" , true ) , sizeof( keyRes) );
return keyRes;
}
ini_GetValue( line[] )
{
new valRes[256];
valRes[0]=0;
if ( strfind( line , "=" , true ) == -1 ) return valRes;
strmid( valRes , line , strfind( line , "=" , true )+1 , strlen( line ) , sizeof( valRes ) );
return valRes;
}
public OnPlayerRequestClass(playerid, classid)
{
if(classid >= 0 && classid <= 3)
{
SetPlayerColor(playerid, 0x4B85CBFF);
GameTextForPlayer(playerid, "~y~>> ~b~Counter-Terrorist ~y~<<",1000,5);
gTeam[playerid] = 1;
}
else
{
SetPlayerColor(playerid, 0xBD1115FF);
GameTextForPlayer(playerid, "~y~>> ~r~Terrorist ~y~<<",1000,5);
gTeam[playerid] = 2;
}
SetPlayerInterior(playerid,0);
SetPlayerPos(playerid,-1657.5237,1207.6644,13.6719);
SetPlayerFacingAngle(playerid,357.6906);
SetPlayerCameraPos(playerid, -1657.4678,1211.2292,13.6781);
SetPlayerCameraLookAt(playerid,-1657.5237,1207.6644,13.6719);
return 1;
}
public OnGameModeExit()
{
print("GameModeExit()");
return 1;
}
public OnPlayerConnect(playerid)
{
Kills[playerid] = 0;
TeamKills[playerid] = 0;
PlayingRound[playerid] = 0;
PlayerGuns[playerid][Gun1] = 0;
PlayerGuns[playerid][Gun2] = 0;
PlayerGuns[playerid][Ammo1] = 0;
PlayerGuns[playerid][Ammo2] = 0;
PlayerGuns[playerid][Health] = 100.0;
GivePlayerMoney(playerid, 1250);
return 1;
}
public OnPlayerDisconnect(playerid)
{
if(PlayingRound[playerid] != 0)
{
if(HoldingBomb == playerid)
{
GameTextForAll("~w~Bomb has been dropped", 5000, 3);
BombDropped = 1;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayingRound[i] != 0)
{
SetPlayerCheckpoint(i, X,Y,Z,2.0);
}
}
}
}
if(gTeam[playerid] == 1)
{
CTerrorists --;
}
else if(gTeam[playerid] == 2)
{
Terrorists --;
}
}
return 1;
}
public OnPlayerSpawn(playerid)
{
SpawnPlace(playerid);
GiveWeapons(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
SendDeathMessage(killerid, playerid, reason);
if(PlayingRound[playerid] > 0)
{
if(HoldingBomb == playerid)
{
GameTextForAll("~w~Bomb has been dropped", 5000, 3);
BombDropped = 1;
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayingRound[i] != 0)
{
SetPlayerCheckpoint(i, X,Y,Z,2.0);
}
}
}
}
PlayingRound[playerid] = 0;
Kills[killerid] += 1;
if(gTeam[playerid] == 1) { CTerrorists --; }
else if(gTeam[playerid] == 2) { Terrorists --; }
if(gTeam[killerid] == gTeam[playerid])
{
SendClientMessage(killerid, COLOR_LIGHTRED, "** You made a Team Kill, only kill the opposite of your team! **");
GivePlayerMoney(killerid, -1500);
Kills[killerid] -= 2;
TeamKills[killerid] += 1;
if(TeamKills[killerid] >= 4)
{
Kick(killerid);
}
}
else
{
GivePlayerMoney(killerid, 250);
}
}
PlayerGuns[playerid][Gun1] = 0;
PlayerGuns[playerid][Gun2] = 0;
PlayerGuns[playerid][Ammo1] = 0;
PlayerGuns[playerid][Ammo2] = 0;
PlayerGuns[playerid][Health] = 100.0;
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid)
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new sendername[MAX_PLAYER_NAME];
new string[256];
new cmd[256];
new tmp[256];
new giveplayerid, idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/help", true) == 0)
{
if(IsPlayerConnected(playerid))
{
SendClientMessage(playerid, COLOR_YELLOW2, "There are 2 teams, Terrorists and Counter-Terrorists...The Terrorists try to place the bomb");
SendClientMessage(playerid, COLOR_YELLOW2, "and the Counter-Terrorists try to prevent that from happening and defuse it if necessary.");
SendClientMessage(playerid, COLOR_YELLOW2, "Commands Players: /help /(b)uy /(t)eam /bomb /diffuse /time.");
if(IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_YELLOW2, "Commands Admins: /goto /mark /gotomark /kick /ban /make /cssavemap /csloadmap.");
SendClientMessage(playerid, COLOR_YELLOW2, "Commands Admins: /rescars /gotocar /lock /unlock /start /stop.");
}
}
return 1;
}
if(strcmp(cmd, "/maps", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
for(new i = 0; i < sizeof(MapNames); i++)
{
format(string, sizeof(string), "%s", MapNames[i]);
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
return 1;
}
if(strcmp(cmd, "/time", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(RoundStarted != 1)
{
SendClientMessage(playerid, COLOR_GREY, " No Round has started yet !");
return 1;
}
new time = 300 - MapTimeCount;
if(time > 60)
{
time = time / 60;
format(string, sizeof(string), "* %d minutes left till the next round.",time);
}
else
{
format(string, sizeof(string), "* %d seconds left till the next round.",time);
}
SendClientMessage(playerid, COLOR_YELLOW2, string);
}
return 1;
}
if(strcmp(cmd, "/t", true) == 0 || strcmp(cmd, "/team", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /(t)eam [text]");
return 1;
}
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string),"** %s: %s", sendername, result);
SendTeamMessage(gTeam[playerid], COLOR_LIGHTBLUE, string);
}
return 1;
}
if(strcmp(cmd, "/start", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
if(ActiveMap != 1)
{
SendClientMessage(playerid, COLOR_GREY, " No map has been loaded yet !");
return 1;
}
rndtimer = SetTimer("NewRound", 1000, 0);
}
return 1;
}
if(strcmp(cmd, "/stop", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
if(ActiveMap != 1)
{
SendClientMessage(playerid, COLOR_GREY, " No map has been loaded yet !");
return 1;
}
StopMap();
}
return 1;
}
if(strcmp(cmd, "/b", true) == 0 || strcmp(cmd, "/buy", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(ActiveMap != 1)
{
SendClientMessage(playerid, COLOR_GREY, " No Map has been loaded, can't buy now !");
return 1;
}
if(RoundStarted != 0)
{
SendClientMessage(playerid, COLOR_GREY, " You can't buy now anymore !");
return 1;
}
tmp = strtok(cmdtext, idx);
new arg = strval(tmp);
if(arg == 1)
{ // Menu 1
new ste;
tmp = strtok(cmdtext, idx);
ste = strval(tmp);
if(ste == 1)
{ // Pistols
new money;
money = GetPlayerMoney(playerid);
if(money >= 400)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You've bought Pistols");
GivePlayerMoney(playerid,-400);
PlayerGuns[playerid][Gun2] = 22;
PlayerGuns[playerid][Ammo2] = 20;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(ste == 2)
{ // Silenced Pistol
new money;
money = GetPlayerMoney(playerid);
if(money >= 400)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought a Silenced Pistol.");
GivePlayerMoney(playerid,-400);
PlayerGuns[playerid][Gun2] = 23;
PlayerGuns[playerid][Ammo2] = 20;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(ste == 3)
{ // Desert Eagle
new money;
money = GetPlayerMoney(playerid);
if(money >= 600)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought a Desert Eagle");
GivePlayerMoney(playerid,-600);
PlayerGuns[playerid][Gun2] = 24;
PlayerGuns[playerid][Ammo2] = 20;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else
{
clear(playerid);
SendClientMessage(playerid,0xFBE8BBFFF,"USAGE /b (category) (item)");
SendClientMessage(playerid,0xE8E8E8FF,"1 - Pistols ($400)");
SendClientMessage(playerid,0xE8E8E8FF,"2 - Silenced Pistol ($400)");
SendClientMessage(playerid,0xE8E8E8FF,"3 - Desert Eagle ($600)");
}
}
else if(arg == 2)
{ // Menu 2
new ste;
tmp = strtok(cmdtext, idx);
ste = strval(tmp);
if(ste == 1)
{
new money;
money = GetPlayerMoney(playerid);
if(money >= 2560)
{ // Shotgun
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You've bought a Shotgun");
GivePlayerMoney(playerid,-2560);
PlayerGuns[playerid][Gun1] = 25;
PlayerGuns[playerid][Gun1] = 40;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(ste == 2)
{ // Combat Shotgun
new money;
money = GetPlayerMoney(playerid);
if(money >= 12000)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought a Combat Shotgun.");
GivePlayerMoney(playerid,-12000);
PlayerGuns[playerid][Gun1] = 27;
PlayerGuns[playerid][Ammo1] = 40;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else
{
clear(playerid);
SendClientMessage(playerid,0xFBE8BBFFF,"USAGE /b (category) (item)");
SendClientMessage(playerid,0xE8E8E8FF,"1 - Shotgun ($2560)");
SendClientMessage(playerid,0xE8E8E8FF,"2 - Combat Shotgun ($12000)");
}
}
else if(arg == 3)
{ // Menu 3
new ste;
tmp = strtok(cmdtext, idx);
ste = strval(tmp);
if(ste == 1)
{ // Mac 10
new money;
money = GetPlayerMoney(playerid);
if(money >= 1530)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You've bought a Mac 10");
GivePlayerMoney(playerid,-1530);
PlayerGuns[playerid][Gun1] = 28;
PlayerGuns[playerid][Ammo1] = 100;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(ste == 2)
{ // Tec9
new money;
money = GetPlayerMoney(playerid);
if(money >= 1590)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought a Tec9");
GivePlayerMoney(playerid,-1590);
PlayerGuns[playerid][Gun1] = 32;
PlayerGuns[playerid][Ammo1] = 100;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(ste == 3)
{ // MP5
new money;
money = GetPlayerMoney(playerid);
if(money >= 1800)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought a MP5");
GivePlayerMoney(playerid,-1800);
PlayerGuns[playerid][Gun1] = 29;
PlayerGuns[playerid][Ammo1] = 100;
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else
{
clear(playerid);
SendClientMessage(playerid,0xFBE8BBFFF,"USAGE /b (category) (item)");
SendClientMessage(playerid,0xE8E8E8FF,"1 - Mac 10 ($1530)");
SendClientMessage(playerid,0xE8E8E8FF,"2 - Tec9 ($1590)");
SendClientMessage(playerid,0xE8E8E8FF,"3 - MP5 ($1800)");
}
}
else if(arg == 4)
{ // Menu 4
new teams;
teams = gTeam[playerid];
new ste;
tmp = strtok(cmdtext, idx);
ste = strval(tmp);
if(ste == 1)
{
new money;
money = GetPlayerMoney(playerid);
if(money >= 4200)
{
clear(playerid);
if(teams == 2)
{
PlayerGuns[playerid][Gun1] = 30;
PlayerGuns[playerid][Ammo1] = 100;
SendClientMessage(playerid,0x4FD200FF,"You've bought an AK47");
GivePlayerMoney(playerid,-4200);
}
else
{
PlayerGuns[playerid][Gun1] = 31;
PlayerGuns[playerid][Ammo1] = 100;
SendClientMessage(playerid,0x4FD200FF,"You've bought a M4");
GivePlayerMoney(playerid,-4200);
}
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else
{
clear(playerid);
SendClientMessage(playerid,0xFBE8BBFFF,"USAGE /b (category) (item)");
if(teams == 2) { SendClientMessage(playerid,0xE8E8E8FF,"1 - AK47($4200)"); }
else { SendClientMessage(playerid,0xE8E8E8FF,"1 - M4 ($4200)"); }
}
}
else if(arg == 5)
{ // Menu 5
new money;
money = GetPlayerMoney(playerid);
if(money >= 800)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought Primary Ammo");
PlayerGuns[playerid][Ammo1] = 500;
GivePlayerMoney(playerid,-800);
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(arg == 6)
{ // Menu 6
new money;
money = GetPlayerMoney(playerid);
if(money >= 200)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought Secondary Ammo");
PlayerGuns[playerid][Ammo2] = 70;
GivePlayerMoney(playerid,-200);
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(arg == 7)
{ // Menu 7
new ste;
tmp = strtok(cmdtext, idx);
ste = strval(tmp);
if(ste == 1)
{
new money;
money = GetPlayerMoney(playerid);
if(money >= 1010)
{ // Kevlar
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought Kevlar");
PlayerGuns[playerid][Health] = 150;
GivePlayerMoney(playerid,-1010);
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else if(ste == 2)
{ // Kevlar and Helmet
new money;
money = GetPlayerMoney(playerid);
if(money >= 1400)
{
clear(playerid);
SendClientMessage(playerid,0x4FD200FF,"You bought kevlar and helmet");
PlayerGuns[playerid][Health] = 200;
GivePlayerMoney(playerid,-1400);
}
else
{
clear(playerid);
SendClientMessage(playerid,0xEC0000FF,"Insufficient funds");
}
}
else
{
clear(playerid);
SendClientMessage(playerid,0xFBE8BBFFF,"USAGE /b (category) (item)");
SendClientMessage(playerid,0xE8E8E8FF,"1 - Kevlar ($1010)");
SendClientMessage(playerid,0xE8E8E8FF,"2 - Kevlar and Helmet ($1400)");
}
}
else
{
clear(playerid);
SendClientMessage(playerid,0xFBE8BBFF,"USAGE /b 'category' 'item'");
SendClientMessage(playerid,0xE8E8E8FF,"1 - Pistols");
SendClientMessage(playerid,0xE8E8E8FF,"2 - Shotguns");
SendClientMessage(playerid,0xE8E8E8FF,"3 - SMGs");
SendClientMessage(playerid,0xE8E8E8FF,"4 - Rifles");
SendClientMessage(playerid,0xE8E8E8FF,"5 - Primary Ammo($800)");
SendClientMessage(playerid,0xE8E8E8FF,"6 - Secondary Ammo($200)");
SendClientMessage(playerid,0xE8E8E8FF,"7 - Equipment");
}
}
return 1;
}
if(strcmp(cmd, "/bomb", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gTeam[playerid] != 2)
{
return 1;
}
if(!PlayerToPoint(6.0,playerid,MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2]))
{
SendClientMessage(playerid, COLOR_GREY, " You are not at the Bomb Place !");
return 1;
}
if(IsPlayerConnected(HoldingBomb))
{
if(HoldingBomb != playerid)
{
SendClientMessage(playerid, COLOR_GREY, " You don't have the Bomb !");
return 1;
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You don't have the Bomb !");
return 1;
}
if(BombPlaced != 0)
{
SendClientMessage(playerid, COLOR_GREY, " Bomb is already placed !");
return 1;
}
GetPlayerPos(playerid, PlayerPlacingBomb[playerid][0],PlayerPlacingBomb[playerid][1],PlayerPlacingBomb[playerid][2]);
PlacingBomb = playerid;
bombtimer = SetTimer("PlaceBomb", 6000, 0);
SendClientMessage(playerid, COLOR_YELLOW2, "Stay here for 6 seconds to place the Bomb.");
}
return 1;
}
if(strcmp(cmd, "/diffuse", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(gTeam[playerid] != 1)
{
return 1;
}
if(!PlayerToPoint(6.0,playerid,MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2]))
{
SendClientMessage(playerid, COLOR_GREY, " You are not at the Bomb Place !");
return 1;
}
if(BombPlaced != 1)
{
SendClientMessage(playerid, COLOR_GREY, " Bomb hasn't been placed yet !");
return 1;
}
GetPlayerPos(playerid, PlayerDefuseBomb[playerid][0],PlayerDefuseBomb[playerid][1],PlayerDefuseBomb[playerid][2]);
DefuseBomb = playerid;
defusetimer = SetTimer("Defusing", 8000, 0);
SendClientMessage(playerid, COLOR_YELLOW2, "Stay here for 8 seconds to Diffuse the Bomb.");
}
return 1;
}
if(strcmp(cmd, "/make", true) == 0)
{
if(IsPlayerConnected(playerid))
{
new Float:X,Float:Y,Float:Z;
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
new x_mk[256];
x_mk = strtok(cmdtext, idx);
if(!strlen(x_mk)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /make [name]");
SendClientMessage(playerid, COLOR_GREY, "Available names: (/make title [text]) (/make TSpawn) (/make CTSpawn)");
SendClientMessage(playerid, COLOR_GREY, "Available names: (/make bomb) (/make limit [number])");
return 1;
}
if(strcmp(x_mk,"title",true) == 0)
{
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /make title [text]");
return 1;
}
strmid(MapMaking[playerid][mTitle], result, 0, strlen(result), 255);
SendClientMessage(playerid, COLOR_WHITE, "You've made the Title of the Map.");
}
else if(strcmp(x_mk,"tspawn",true) == 0)
{
GetPlayerPos(playerid, X,Y,Z);
MapMaking[playerid][mTSpawn][0] = X;
MapMaking[playerid][mTSpawn][1] = Y;
MapMaking[playerid][mTSpawn][2] = Z;
GetPlayerFacingAngle(playerid, MapMaking[playerid][mTAngle]);
SendClientMessage(playerid, COLOR_WHITE, "You've made the Terrorist Spawn of the Map.");
}
else if(strcmp(x_mk,"ctspawn",true) == 0)
{
GetPlayerPos(playerid, X,Y,Z);
MapMaking[playerid][mCTSpawn][0] = X;
MapMaking[playerid][mCTSpawn][1] = Y;
MapMaking[playerid][mCTSpawn][2] = Z;
GetPlayerFacingAngle(playerid, MapMaking[playerid][mCTAngle]);
SendClientMessage(playerid, COLOR_WHITE, "You've made the Counter-Terrorist of the Map.");
}
else if(strcmp(x_mk,"bomb",true) == 0)
{
GetPlayerPos(playerid, X,Y,Z);
MapMaking[playerid][mBomb][0] = X;
MapMaking[playerid][mBomb][1] = Y;
MapMaking[playerid][mBomb][2] = Z;
SendClientMessage(playerid, COLOR_WHITE, "You've made the Bomb Spawn of the Map.");
}
else if(strcmp(x_mk,"limit",true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /make limit [number]");
return 1;
}
new number = strval(tmp);
if(number < 1 || number > 4) { SendClientMessage(playerid, COLOR_GREY, " Limit number can't be below 1 or above 4 !"); return 1; }
GetPlayerPos(playerid, X,Y,Z);
if(number==1) { MapMaking[playerid][mLimit1][0] = X; MapMaking[playerid][mLimit1][1] = Y; MapMaking[playerid][mLimit1][2] = Z; }
else if(number==2) { MapMaking[playerid][mLimit2][0] = X; MapMaking[playerid][mLimit2][1] = Y; MapMaking[playerid][mLimit2][2] = Z; }
else if(number==3) { MapMaking[playerid][mLimit3][0] = X; MapMaking[playerid][mLimit3][1] = Y; MapMaking[playerid][mLimit3][2] = Z; }
else if(number==4) { MapMaking[playerid][mLimit4][0] = X; MapMaking[playerid][mLimit4][1] = Y; MapMaking[playerid][mLimit4][2] = Z; }
format(string, sizeof(string), "You've made LimitNr %d of the Map.",number);
SendClientMessage(playerid, COLOR_WHITE, string);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " Invalid Run Making name !");
return 1;
}
}
return 1;
}
if(strcmp(cmd, "/cssavemap", true)==0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /cssavemap [mapname]");
return 1;
}
SaveMap(playerid,tmp);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " you are not authorized to use that command!");
}
}
return 1;
}
if(strcmp(cmd, "/csloadmap", true)==0)
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /csloadmap [mapname]");
return 1;
}
LoadMap(playerid,tmp);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " you are not authorized to use that command!");
}
}
return 1;
}
if(strcmp(cmd, "/mark", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
GetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
SendClientMessage(playerid, COLOR_GREY, " Position saved !");
}
return 1;
}
if(strcmp(cmd, "/gotomark", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
SetPlayerPos(playerid, Pos[playerid][0], Pos[playerid][1], Pos[playerid][2]);
}
return 1;
}
if(strcmp(cmd, "/goto", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /goto [playerid/PartOfName]");
return 1;
}
new Float:plocx,Float:plocy,Float:plocz;
giveplayerid = ReturnUser(tmp);
if (IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerPos(giveplayerid, plocx, plocy, plocz);
if (GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
}
else
{
SetPlayerPos(playerid,plocx,plocy+2, plocz);
}
}
}
else
{
format(string, sizeof(string), " %d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_GREY, string);
}
}
return 1;
}
if(strcmp(cmd, "/rescars", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
for(new i = 0; i <= CARS; i++)
{
SetVehicleToRespawn(i);
}
}
return 1;
}
if(strcmp(cmd, "/gotocar", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /gotocar [carid]");
return 1;
}
new testcar = strval(tmp);
new Float:cwx2,Float:cwy2,Float:cwz2;
GetVehiclePos(testcar, cwx2, cwy2, cwz2);
SetPlayerPos(playerid, cwx2, cwy2, cwz2);
SetPlayerInterior(playerid,0);
}
return 1;
}
if(strcmp(cmd, "/lock", true)==0 && IsPlayerAdmin(playerid) == 1){
locked = 1;
SendClientMessageToAll(0x00DD37FF, "* All cars locked");
return 1;}
if(strcmp(cmd, "/unlock", true)==0 && IsPlayerAdmin(playerid) == 1){
locked = 0;
SendClientMessageToAll(0x00DD37FF, "* All cars unlocked");
return 1;}
if(strcmp(cmd, "/kick", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /kick [playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
Kick(giveplayerid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is Offline !");
return 1;
}
}
return 1;
}
if(strcmp(cmd, "/ban", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if(!IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, COLOR_GREY, " You are not an Admin !");
return 1;
}
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /ban [playerid/PartOfName]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
Ban(giveplayerid);
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, " That player is Offline !");
return 1;
}
}
return 1;
}
return 1;
}
public OnPlayerInfoChange(playerid)
{
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
if(locked){SetPlayerPos(playerid,x,y,z);}
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
if(BombDropped > 0 && gTeam[playerid] == 2)
{
BombDropped = 0;
HoldingBomb = playerid;
SendClientMessage(playerid, COLOR_YELLOW, "You picked up the Bomb.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayingRound[i] != 0)
{
SetPlayerCheckpoint(i, MapInfo[pBomb][0],MapInfo[pBomb][1],MapInfo[pBomb][2],6.0);
}
}
}
}
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
IsNumeric(const string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
ReturnUser(text[], playerid = INVALID_PLAYER_ID)
{
new pos = 0;
while (text[pos] < 0x21) // Strip out leading spaces
{
if (text[pos] == 0) return INVALID_PLAYER_ID; // No passed text
pos++;
}
new userid = INVALID_PLAYER_ID;
if (IsNumeric(text[pos])) // Check whole passed string
{
// If they have a numeric name you have a problem (although names are checked on id failure)
userid = strval(text[pos]);
if (userid >=0 && userid < MAX_PLAYERS)
{
if(!IsPlayerConnected(userid))
{
/*if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "User not connected");
}*/
userid = INVALID_PLAYER_ID;
}
else
{
return userid; // A player was found
}
}
/*else
{
if (playerid != INVALID_PLAYER_ID)
{
SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
}
userid = INVALID_PLAYER_ID;
}
return userid;*/
// Removed for fallthrough code
}
// They entered [part of] a name or the id search failed (check names just incase)
new len = strlen(text[pos]);
new count = 0;
new name[MAX_PLAYER_NAME];
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i, name, sizeof (name));
if (strcmp(name, text[pos], true, len) == 0) // Check segment of name
{
if (len == strlen(name)) // Exact match
{
return i; // Return the exact player on an exact match
// Otherwise if there are two players:
// Me and MeYou any time you entered Me it would find both
// And never be able to return just Me's id
}
else // Partial match
{
count++;
userid = i;
}
}
}
}
if (count != 1)
{
if (playerid != INVALID_PLAYER_ID)
{
if (count)
{
SendClientMessage(playerid, 0xFF0000AA, "Multiple users found, please narrow earch");
}
else
{
SendClientMessage(playerid, 0xFF0000AA, "No matching user found");
}
}
userid = INVALID_PLAYER_ID;
}
return userid; // INVALID_USER_ID for bad return
}