Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #define COLOR_RED 0xFF0000FF
- #define COLOR_YELLOW 0xFFFF00FF
- forward NotAtBuyableLocation(playerid);
- forward C4Options(playerid);
- forward ExplodeC4(playerid);
- new C4Owned[MAX_PLAYERS];
- new C4[MAX_PLAYERS];
- new string[128];
- public OnFilterScriptInit()
- {
- print("\n - | Torran's Plant C4 Script | - \n");
- CreatePickup(1239, 29, -2044.0807, 149.9639, 28.8359);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- C4Owned[playerid] = 0;
- C4[playerid] = 0;
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- DisablePlayerCheckpoint(playerid);
- return 1;
- }
- public NotAtBuyableLocation(playerid)
- {
- SendClientMessage(playerid, COLOR_RED, " - | You need to be at the point marked on your map with a checkpoint | -");
- SetPlayerCheckpoint(playerid, -2044.0807, 149.9639, 28.8359, 5.0);
- return 1;
- }
- public C4Options(playerid)
- {
- SendClientMessage(playerid, COLOR_RED, " - | Usage: /c4 [option] | -");
- SendClientMessage(playerid, COLOR_RED, " - | Options: buy, plant, detonate, quantity, credits | -");
- return 1;
- }
- public ExplodeC4(playerid)
- {
- new Float:x, Float:y, Float:z;
- GetObjectPos(C4[playerid], x, y, z);
- DestroyObject(C4[playerid]);
- CreateExplosion(x, y, z, 7, 10.0);
- C4[playerid] = 0;
- return 1;
- }
- CMD:c4(playerid, params[])
- {
- if(strcmp(params, "buy", true) == 0)
- {
- if(!IsPlayerInRangeOfPoint(playerid, 5.0, -2044.0807, 149.9639, 28.8359)) return NotAtBuyableLocation(playerid);
- C4Owned[playerid]++;
- format(string, sizeof string, " - | Success: C4 Bought, You currently have %d C4 | -", C4Owned[playerid]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- if(strcmp(params, "plant", true) == 0)
- {
- new Float:x, Float:y, Float:z;
- if(!C4Owned[playerid]) return SendClientMessage(playerid, COLOR_RED, " - | You must buy C4 before using this command | -");
- if(C4[playerid]) return SendClientMessage(playerid, COLOR_RED, " - | You can only plant one C4 block at a time | -");
- GetPlayerPos(playerid, x, y, z);
- C4[playerid] = CreateObject(1654, x, y, z, 0, 0, 0);
- SendClientMessage(playerid, COLOR_YELLOW, " - | Success: C4 Planted, Detonate using: /c4 detonate| -");
- return 1;
- }
- if(strcmp(params, "detonate", true) == 0)
- {
- if(!C4Owned[playerid]) return SendClientMessage(playerid, COLOR_RED, " - | You must buy C4 before using this command | -");
- if(!C4[playerid]) return SendClientMessage(playerid, COLOR_RED, " - | You must plant your current C4 before detonating | -");
- C4Owned[playerid]--;
- SendClientMessage(playerid, COLOR_YELLOW, " - | C4 Detonated, Exploding in 5 seconds, Run! | -");
- SetTimerEx("ExplodeC4", 5000, 0, "i", playerid);
- return 1;
- }
- if(strcmp(params, "quantity", true) == 0)
- {
- if(!C4Owned[playerid]) return SendClientMessage(playerid, COLOR_RED, " - | You do not have any C4 | -");
- format(string, sizeof string, " - | Quantity of C4: %d | -", C4Owned[playerid]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- return 1;
- }
- if(strcmp(params, "credits", true) == 0)
- {
- SendClientMessage(playerid, COLOR_YELLOW, " - | Made by Torran | -");
- return 1;
- }
- return C4Options(playerid);
- }
Advertisement
Add Comment
Please, Sign In to add comment