Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *
- *
- adm_Bomb 2.0 (Author: Admantis)
- *
- * Features
- - Easy to configure system.
- - Can set the bomb shop coordenates
- - Can set the bomb cost
- - After a time the bomb will explode (can set too)
- - Can set realistic features (beep, object on ground)
- * Commands
- - /buybomb
- - /givebomb
- - /plantbomb
- * Disclaimer
- - Credits are not needed, just don't claim it as yours
- - You may not re-release this or sell it
- * Notes
- - Please report any bugs to Admantis via SA:MP forums PM
- - I'm not responsible of how this could harm your server
- - You need the command processor 'zcmd' to use this
- - Slow computers may lag at the bomb explosion
- *
- *
- *
- *
- */
- #include a_samp
- #include zcmd
- #include sscanf2
- #define ShopX 0.000 // Change me, I'm the X place of bomb shop!
- #define ShopY 0.000 // Change me, I'm the Y place of bomb shop!
- #define ShopZ 0.000 // Change me, I'm the Z place of bomb shop!
- #define ShopV 0 // Change me, I'm the virtual world of bomb shop!
- #define Cost 25000 // Change me, I'm the cost of the bomb!
- #define BombTimer 30 // Change me, I'm in how many seconds will the bomb blow up!
- #define Realism 1 // Change me, I'm the one who toggles realism options! (0=false/1=true)
- #define Explosions 5 // Change me, I'm how many explosions will happen when bombs blow!
- /*
- TBA: More realism and features options.
- Realism includes;
- * Beep sound when you are close to the bomb.
- * Bomb object.
- It's up to you to use it!
- */
- new iPlanter;
- new Timer;
- new Float:fBombX;
- new Float:fBombY;
- new Float:fBombZ;
- forward Explode();
- forward Beep();
- forward ResetPlant(playerid);
- public OnPlayerConnect(playerid)
- {
- SetPVarInt(playerid, "Bomb", 0);
- SetPVarInt(playerid, "Plant", 0);
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- SetPVarInt(playerid, "Bomb", 0);
- SetPVarInt(playerid, "Plant", 0);
- if (iPlanter == playerid) iPlanter = 0;
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if (dialogid == 1)
- {
- if (response)
- {
- SetPVarInt(playerid, "Bomb", 1);
- GivePlayerMoney(playerid, -Cost);
- ShowPlayerDialog(playerid, 0, 0, "{CC0000}Success", "{FFFFFF}You have bought a bomb", "Close", "");
- return 1;
- }
- }
- return 1;
- }
- public ResetPlant(playerid)
- {
- return SetPVarInt(playerid, "Plant", 0);
- }
- public Beep()
- {
- for(new I = 0; I < MAX_PLAYERS; I++)
- {
- if (IsPlayerInRangeOfPoint(I, 15.0, fBombX, fBombY, fBombZ))
- {
- PlayerPlaySound(I, 1056, 0.0, 0.0, 0.0);
- }
- }
- return 1;
- }
- public Explode()
- {
- new Bombs;
- do
- {
- Bombs += 1;
- CreateExplosion(fBombX, fBombY, fBombZ, 2, 20);
- }
- while (Bombs != Explosions);
- SendClientMessage(iPlanter, -1, "{FFFFFF}Your bomb has {CC0000}exploded sucessfully");
- #if Realism == 1
- {
- KillTimer(Timer);
- }
- #endif
- return 1;
- }
- stock IsAtBombShop(playerid)
- {
- if (IsPlayerInRangeOfPoint(playerid, 3, ShopX, ShopY, ShopZ)
- && (GetPlayerVirtualWorld(playerid) == ShopV)) return 1;
- return 0;
- }
- stock CanAffordBomb(playerid)
- {
- if (GetPlayerMoney(playerid) > Cost) return 1;
- return 0;
- }
- stock RecentlyPlanted(playerid)
- {
- if (GetPVarInt(playerid, "Plant") == 1) return 1;
- return 0;
- }
- CMD:buybomb(playerid, params[])
- {
- new szString[124];
- format(szString, 124, "{FFFFFF}Are you sure you want to buy a bomb for {00CC00}%d$?", Cost);
- if (!IsAtBombShop(playerid))
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You are not at the {CC0000}bomb shop");
- return 1;
- }
- if (!CanAffordBomb(playerid))
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You can't afford this {CC0000}bomb");
- return 1;
- }
- if (GetPVarInt(playerid, "Bomb") == 1)
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You already have a {CC0000}bomb");
- return 1;
- }
- return ShowPlayerDialog(playerid, 1, 0, "{CC0000}Confirmation", szString, "Yes", "No");
- }
- CMD:givebomb(playerid, params[])
- {
- new szString[124], szDestName[24], szpName[24], iDest, Float:fDestX, Float:fDestY, Float:fDestZ;
- if (sscanf(params, "u", iDest))
- {
- SendClientMessage(playerid, -1, "{CC0000}Usage:{FFFFFF} /givebomb [playerid/PartOfName]");
- return 1;
- }
- GetPlayerPos(iDest, fDestX, fDestY, fDestZ);
- if (!IsPlayerInRangeOfPoint(playerid, 3, fDestX, fDestY, fDestZ))
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You are not {CC0000}near the player!");
- return 1;
- }
- if (GetPVarInt(iDest, "Bomb") == 1)
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}This player already has {CC0000}a bomb!");
- return 1;
- }
- if (iDest == INVALID_PLAYER_ID)
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}This player is {CC0000}not online!");
- return 1;
- }
- GetPlayerName(iDest, szDestName, 24);
- GetPlayerName(playerid, szpName, 24);
- format(szString, 124, "{FFFFFF}You've given a bomb to {CC0000}%s(%d)", szDestName, iDest);
- SendClientMessage(playerid, -1, szString);
- format(szString, 124, "{FFFFFF}You've recived a bomb from {CC0000}%s(%d)", szpName, playerid);
- SendClientMessage(iDest, -1, szString);
- SetPVarInt(playerid, "Bomb", 0);
- SetPVarInt(iDest, "Bomb", 1);
- return 1;
- }
- CMD:plantbomb(playerid, params[])
- {
- if (GetPVarInt(playerid, "Bomb") == 0)
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You do not have a {CC0000}bomb!");
- return 1;
- }
- if (GetPVarInt(playerid, "Plant") == 1)
- {
- SendClientMessage(playerid, -1, "{CC0000}Error: {FFFFFF}You need to wait before {CC0000}planting again!");
- return 1;
- }
- new Float:fpX, Float:fpY, Float:fpZ, szString[124];
- GetPlayerPos(playerid, fpX, fpY, fpZ);
- fBombX = fpX;
- fBombY = fpY;
- fBombZ = fpZ-1.5;
- SetTimer("Explode", BombTimer * 1000, 0);
- SetTimerEx("ResetPlant", 20 * 60 * 1000, false, "i", playerid);
- SetPVarInt(playerid, "Bomb", 0);
- SetPVarInt(playerid, "Plant", 1);
- ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0); // Place Bomb
- iPlanter = playerid;
- format(szString, 124, "{FFFFFF}You have planted a bomb in your location and it will explode in {CC0000}%d seconds", BombTimer);
- SendClientMessage(playerid, -1, szString);
- #if Realism == 1
- {
- CreateObject(1252, fpX, fpY, fpZ-1.4, 0, 0, 0); // 'fpZ-1.4' may be inaccurate. Be aware.
- Timer = SetTimer("Beep", 4000, 1);
- }
- #endif
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment