[Tutorial] Bombing system
#1

Hello guys, today im going to show you how to make simple Bombing system. Mainly, it is very good for your TDM Server ,DM Server, OR RPServer. So, Lets Getting started!

I'd like using Incognito streamer here as the checkpoint of Bomb. So, make sure, you've this include:
pawn Код:
#include <streamer>
Okay, we need to define some important variables that we gotta use here:

pawn Код:
new Bombed[MAX_PLAYERS][10];
new IsPlayerBombing[MAX_PLAYERS][10];
new UnderBomb[10];
new tCB[10];
new BCP[10];
new Timer[MAX_PLAYERS][10];
BCP[10], means, you can create untill 10 Bomb checkpoints, as you want, with only a variable. Take it:BCP[BOMB].
tCB[10], stands for checking, if the bomb is bombed by particular team.
UnderBomb[10], to check if the bombzone already Bomb or not.
IsPlayerBombing checking for if is player bommbing the zone or not!
Bombed is to check if player already bombed this zone or not.
timer is standing for Timer ID, which we gonna use it later to set the timer, when it will be explode the bomb!

Lets move on with define our Bomb zone name. Take it BOMB.type this:
pawn Код:
#define BOMB 0
#define NONE 1
Why did we define "NONE"??We defined it for check the bomb zone aint controlled by Any Team!
And, ive assumed, that youve already Some Team. Like Team 1 Team 2, or Team Army, etc.
Okay, we gonna use thoose stuffs later.
And dont forget add this OnGameModeInit:
pawn Код:
public OnGameModeInit()
{
BCP[BOMB] = CreateDynamicCP(X,Y,Z,RADIUS,-1,-1,-1,100.0);
tCB[BOMB] = NONE;
return 1;
}
Dont forget to change the bomb zone with your location!
and when the Game mode initialited, the zone aint controlled by anyone. So, we wouldnt get any bugs!.

Time To Script
Okay guys, lets move on!
What we want know, once we have typed /plantbomb or something, the bomb will Automotically planted on Bomb Checkpoint. And, we gotta set time when will the bomb explode. 10 seconds or 20 seconds. We gotta set it later .

Ive assumed you get command include like zcmd or dcmd or something to make this command. I Used to be zcmd on making a commands. So, i'd like using as zcmd parameters as generally
Type this:

pawn Код:
CMD:plantbomb(playerid,params[])
{
if(!IsPlayerInAnyVehicle(playerid)&&IsPlayerInDynamicCP(playerid,BCP[BOMB]&&tCB[BOMB]!=gTeam[playerid])
{
if(IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid,-1,"You cant plant bomb while youre On Vehicle!");//checking if Player is on vehicle while going to plant a bomb, it will return an error message
if(tCB[BOMB] == gTeam[playerid])return SendClientMessage(playerid,-1,"This bomb area already bombed by your Team!");
if(UnderBomb[BOMB] == 1)return SendClientMessage(playerid,-1,"This area is already bombed by someone else!");//checking if the zone already bombed by someone else, it will return an erorr message!
if(!IsPlayerInDynamicCP(playerid, BCP[BOMB]))return SendClientMessage(playerid,-1,"You are not on bomb CP!");//checking if player is not on Bomb checkpoint,it will return an error message
IsPlayerBombing[playerid][BOMB] = 1;//We setted the variable value turn to 1. That means, Player is Planting a bomb
Bombed[playerid][BOMB] = 0;//Bomb that planted here, not Exploded Yet!
UnderBomb[BOMB] = 1;//That means, the zone is under Bomb by someone.
Timer[playerid][BOMB] = SetTimerEx("explodebomb",10000,false,"i",playerid);//Set a timer, that means on 10 seconds, Bomb will be exploded!You can change the time as you want.
}
return 1;
}
Okay, we need to define our callback function "explodebomb" . Therefore, add this:
pawn Код:
forward explodebomb(playerid);
public explodebomb(playerid)
{
KillTimer(Timer[playerid][BOMB]);//We kill a timer here. If we didnt, it will continously exploding!
Bombed[playerid][BOMB] = 1;//that means player already bombed the zone here!
tCB[BOMB] = gTeam[playerid];//This is for checking, bomb zone controlled by his team. And if another team member going to plant a bomb here, it will return an error message!
UnderBomb[BOMB] = 0;//That means, This zone is not under bombed anymore! ;)
CreateExplosion(X,Y,Z,type,radius);//We created an explosion here, dont forget to change the location as the coordinates of your Bomb Checkpoint!
SendClientMessage(playerid,-1,"Congratulation, you have Bombed this zone!");
GivePlayerMoney(playerid,2000);//give bomber money
SetPlayerScore(playerid,GetPlayerScore(playerid)+2);//Give Player a score
return 1;
}
And we almost done right now! On this case, if the player death while bombing, the bomb will be canceled to exploded,or when the player is disconnected! Add this code:
pawn Код:
public OnPlayerDeath(playerid,killerid,reason)
{
if(IsPlayerBombing[playerid][BOMB] == 1 && Bombed[playerid][BOMB] == 0)
{
BombCanceled(playerid);//We gotta define it, The BombCanceled stock!
}
return 1;
}
Same with OnPlayerDisconnect:
pawn Код:
public OnPlayerDisconnect(playerid,reason)
{
if(IsPlayerBombing[playerid][BOMB] == 1 && Bombed[playerid][BOMB] == 0)
{
BombCanceled(playerid);//We gotta define it, The BombCanceled stock!
}
return 1;
}
We gotta define stock BombCanceled here!!

pawn Код:
stock BombCanceled(playerid)
{
KillTimer(Timer[playerid][BOMB]);//Kill a timer here.
Bombed[playerid][BOMB] = 0;//And this zone is not bombed here.
IsPlayerBombing[playerid][BOMB] = 0;//And player is not bombing anymore
UnderBomb[BOMB] = 0;//the bomb zone is not under attack anymore
SendClientMessage(playerid,-1,"You have failed to bomb this zone!");//Send the player a message here!
}
Okay, we have DONE here!
I know, it is just simple tutorial , but at least, if you aint like this, dont -REP me please.

Okay guys, we have done here, wish it helped for you guys!
Reply
#2

Oh comeon guys, no comment?
Reply
#3

Its explained well, but it seems more of Copy-Paste. 7/10
Reply
#4

Quote:
Originally Posted by FaceTutorialz
Посмотреть сообщение
Its explained well, but it seems more of Copy-Paste. 7/10
Thanks for the feedback
I appreciated thaat

Any other comments please?
Reply
#5

up :3
Reply
#6

Indent your code ...
http://tabulador.medianewsonline.com/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)