Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Bomb System for SA:MP 0.3c
- // Made by Admantis
- // You may not re-release or sell this under any circumstance.
- */
- #include <a_samp>
- #include <zcmd>
- #include <sscanf2>
- #define ShopX 0.000
- #define ShopY 0.000
- #define ShopZ 0.000
- #define ShopV 0
- #define Cost 25000
- #define BombTimer 1
- new iPlanter;
- new Float:fBombX;
- new Float:fBombY;
- new Float:fBombZ;
- forward Explode();
- 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 Explode()
- {
- CreateExplosion(fBombX, fBombY, fBombZ, 9, 30.0);
- CreateExplosion(fBombX, fBombY, fBombZ, 0, 30.0);
- CreateExplosion(fBombX-1, fBombY-1, fBombZ-1, 0, 30.0);
- CreateExplosion(fBombX+1, fBombY+1, fBombZ+1, 0, 30.0);
- CreateExplosion(fBombX, fBombY, fBombZ, 13, 30.0);
- SendClientMessage(iPlanter, -1, "{FFFFFF}Your bomb has {CC0000}exploded sucessfully");
- 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[128];
- format(szString, 128, "{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[128], szDestName[28], szpName[28], 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, 28);
- GetPlayerName(playerid, szpName, 28);
- format(szString, 128, "{FFFFFF}You've given a bomb to {CC0000}%s(%d)", szDestName, iDest);
- SendClientMessage(playerid, -1, szString);
- format(szString, 128, "{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[128];
- GetPlayerPos(playerid, fpX, fpY, fpZ);
- fBombX = fpX;
- fBombY = fpY;
- fBombZ = fpZ-1.5;
- SetTimer("Explode", BombTimer * 60 * 1000, 0);
- SetTimerEx("ResetPlant", 30 * 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, 128, "{FFFFFF}You have planted a bomb in your location and it will explode in {CC0000}%d minutes", BombTimer);
- SendClientMessage(playerid, -1, szString);
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment