Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*===================================CREDITS====================================
- FILTER SCRIPT CREATED BY
- inshal
- [iBomb] Attach Bomb to a player
- v1.2
- http://forum.sa-mp.com/showthread.php?p=2961629
- //============================================================================*/
- //=================================INCLUDES=====================================
- #include <a_samp>
- #include <sscanf2>
- #include <zcmd>
- //==============================================================================
- //==================================NEW=========================================
- new BombAttached[MAX_PLAYERS];
- new AttemptedToBombRecently[MAX_PLAYERS];
- new HasBombedRecently[MAX_PLAYERS];
- new AttemptedToDefuseBombRecently[MAX_PLAYERS];
- new Text:Bomb;
- new Text:ExpTime[3];
- new VehicleBombed[MAX_VEHICLES];
- new HasBlownVehicleRecently[MAX_PLAYERS];
- new ExplosionTime[MAX_PLAYERS];
- //==============================================================================
- //==============================FORWARDS========================================
- forward OneSVariables();
- forward Explosion();
- forward Float:GetDistanceBetweenPlayers(p1,p2);
- //==============================================================================
- //===============================COLORS=========================================
- #define RED 0xFF0000AA
- #define LIGHTGREEN 0x33AA33AA
- #define GREY 0xAFAFAFAA
- //==============================================================================
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" iBomb Filterscript v1.2 loaded!");
- print("--------------------------------------\n");
- SetTimer("OneSVariables",1000,1);
- //=================================TEXTDRAWS====================================
- Bomb = TextDrawCreate(503.500000, 127.750053, "Bombed");
- TextDrawLetterSize(Bomb, 0.449999, 1.600000);
- TextDrawAlignment(Bomb, 1);
- TextDrawColor(Bomb, RED);
- TextDrawSetShadow(Bomb, 0);
- TextDrawSetOutline(Bomb, 1);
- TextDrawBackgroundColor(Bomb, 51);
- TextDrawFont(Bomb, 3);
- TextDrawSetProportional(Bomb, 1);
- ExpTime[0] = TextDrawCreate(409.500000, 337.500000, "usebox");
- TextDrawLetterSize(ExpTime[0], 0.000000, 2.296668);
- TextDrawTextSize(ExpTime[0], 223.000000, 0.000000);
- TextDrawAlignment(ExpTime[0], 1);
- TextDrawColor(ExpTime[0], 0);
- TextDrawUseBox(ExpTime[0], true);
- TextDrawBoxColor(ExpTime[0], 102);
- TextDrawSetShadow(ExpTime[0], 0);
- TextDrawSetOutline(ExpTime[0], 0);
- TextDrawFont(ExpTime[0], 0);
- ExpTime[1] = TextDrawCreate(232.500000, 339.360046, "Explosion time: 10");
- TextDrawLetterSize(ExpTime[1], 0.449999, 1.600000);
- TextDrawAlignment(ExpTime[1], 1);
- TextDrawColor(ExpTime[1], -16776961);
- TextDrawSetShadow(ExpTime[1], 0);
- TextDrawSetOutline(ExpTime[1], 1);
- TextDrawBackgroundColor(ExpTime[1], 51);
- TextDrawFont(ExpTime[1], 3);
- TextDrawSetProportional(ExpTime[1], 1);
- //==============================================================================
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("\n----------------------------------");
- print(" iBomb Filterscript v1.2 unloaded!");
- print("----------------------------------\n");
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SendClientMessage(playerid, LIGHTGREEN, "[INFO]{FFFFFF}: iBomb v1.2 by inshal is successfully being used in this server.");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- TextDrawDestroy(Bomb);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- AttemptedToBombRecently[playerid] =0;
- HasBombedRecently[playerid] =0;
- AttemptedToDefuseBombRecently[playerid] =0;
- BombAttached[playerid] =0;
- HasBlownVehicleRecently[playerid] =0;
- TextDrawHideForPlayer(playerid, Bomb);
- TextDrawHideForPlayer(playerid, ExpTime[0]);
- TextDrawHideForPlayer(playerid, ExpTime[1]);
- ExplosionTime[playerid] =0;
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- AttemptedToBombRecently[playerid] =0;
- HasBombedRecently[playerid] =0;
- AttemptedToDefuseBombRecently[playerid] =0;
- BombAttached[playerid] =0;
- HasBlownVehicleRecently[playerid] =0;
- TextDrawHideForPlayer(playerid, Bomb);
- TextDrawHideForPlayer(playerid, ExpTime[0]);
- TextDrawHideForPlayer(playerid, ExpTime[1]);
- ExplosionTime[playerid] =0;
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- //================================COMMANDS======================================
- CMD:plantbomb(playerid,params[])
- {
- #pragma unused params
- new pName[MAX_PLAYER_NAME], string[128];
- if(!IsPlayerInAnyVehicle(playerid))
- {
- SendClientMessage(playerid,RED,"[ERROR]{FFFFFF} You are not in any vehicle. How are you supposed to blow one up?");
- return 1;
- }
- if(HasBlownVehicleRecently[playerid] >= 1)
- {
- format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before bombing a car again.",HasBlownVehicleRecently[playerid]);
- SendClientMessage(playerid,RED,string);
- return 1;
- }
- new pveh =GetPlayerVehicleID(playerid);
- GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
- SendClientMessage(playerid,RED,"[INFO]{FFFFFF} You have successfully bombed the vehicle and it is about to explode in 10 seconds.");
- HasBlownVehicleRecently[playerid] =120;
- SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
- SetPVarString(playerid, "Name", pName);
- VehicleBombed[pveh] =10;
- return 1;
- }
- CMD:pb(playerid, params[]) return cmd_plantbomb(playerid, params);
- CMD:bomb(playerid,params[])
- {
- new targetid, string[128], pName[MAX_PLAYER_NAME+1];
- new crand = random(50);
- if(GetDistanceBetweenPlayers(playerid, targetid) > 4) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} Player is too far away.");
- if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, RED, "[USAGE]{FFFFFF} /bomb [name/id]")&&
- SendClientMessage(playerid, GREY, "[FUNCTION]{FFFFFF} Will attach a bomb to a player.");
- if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} Player not found.");
- if(BombAttached[targetid] == 1) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} A bomb is already attached to the player.");
- // if(playerid == targetid) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} You cannot attach a bomb on yourself!");
- if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} The player is in a vehicle.");
- if(HasBombedRecently[playerid] >= 1)
- {
- format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before bombing someone again.",HasBombedRecently[playerid]);
- SendClientMessage(playerid,RED,string);
- return 1;
- }
- if(AttemptedToBombRecently[playerid] >= 1)
- {
- format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before trying to bomb someone again.",AttemptedToBombRecently[playerid]);
- SendClientMessage(playerid,RED,string);
- return 1;
- }
- if(crand <= 25) return AttemptedToBombRecently[playerid] =30, SendClientMessage(playerid, RED, "[FAIL]{FFFFFF} You have failed to attach the bomb on the player.");
- if(crand > 25)
- {
- GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
- SendClientMessage(playerid, LIGHTGREEN, "[SUCCESSFUL]{FFFFFF} You have attached the bomb on the player and it will detonate in 10 seconds.");
- SendClientMessage(targetid, RED, "[DANGER]{FFFFFF} A bomb has been attached on you and will detonate in 10 seconds!");
- SendClientMessage(targetid, GREY, "[TIP]{FFFFFF} You can try to defuse the bomb by using /defusebomb.");
- //SetTimer("Explosion", 10000, false);
- BombAttached[targetid] =1;
- TextDrawShowForPlayer(playerid, Bomb);
- HasBombedRecently[playerid] =60;
- //SetPVarString(playerid, "Name", pName);
- //SetPVarInt(playerid, "ID", playerid);
- SetPlayerScore(playerid, GetPlayerScore(playerid)+1);
- SetPlayerAttachedObject(targetid, 2,1252,1,0.10,-0.18,0.01,8.0,85.0,-4.0,0.86,1.16,1.00);
- ExplosionTime[targetid] =10;
- TextDrawShowForPlayer(targetid, ExpTime[0]);
- TextDrawShowForPlayer(targetid, ExpTime[1]);
- }
- return 1;
- }
- CMD:defusebomb(playerid,params[])
- {
- new crand = random(40), string[128];
- if(BombAttached[playerid] == 0) return SendClientMessage(playerid, RED, "[ERROR]{FFFFFF} There is no bomb attached on you.");
- if(AttemptedToDefuseBombRecently[playerid] >= 1)
- {
- format(string, sizeof(string),"[ERROR]{FFFFFF} Please wait {FF0000}%d seconds{FFFFFF} before trying to defuse a bomb again.",AttemptedToDefuseBombRecently[playerid]);
- SendClientMessage(playerid,RED,string);
- return 1;
- }
- if(crand <= 20) return AttemptedToDefuseBombRecently[playerid] =30, SendClientMessage(playerid, RED, "[FAIL]{FFFFFF} You have failed to defuse the bomb.");
- if(crand > 20)
- {
- SendClientMessage(playerid, LIGHTGREEN, "[SUCCESSFUL]{FFFFFF} You have successfully defused the bomb.");
- BombAttached[playerid] =0;
- TextDrawHideForPlayer(playerid, Bomb);
- RemovePlayerAttachedObject(playerid, 2);
- ExplosionTime[playerid] =0;
- TextDrawHideForPlayer(playerid, ExpTime[0]);
- TextDrawHideForPlayer(playerid, ExpTime[1]);
- }
- return 1;
- }
- //==============================================================================
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- //================================STOCKS AND OTHERS=============================
- /*
- public Explosion()
- {
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(BombAttached[i] == 1)
- {
- new string[128], Float:x, Float:y, Float:z;
- //new pName[MAX_PLAYER_NAME+1];
- GetPlayerPos(i, x, y, z);
- CreateExplosion(x,y,z,6,10.0);
- SetPlayerHealth(i, 0);
- BombAttached[i] =0;
- format(string, sizeof(string), "[DEATH]{FFFFFF} %s[%d] has been blown up with a bomb" attached by %s[%d]."", GetName(i), i, GetPVarString(i, "Name", pName), GetPVarInt(i, "ID"));
- SendClientMessageToAll(RED, string);
- TextDrawHideForPlayer(i, Bomb);
- }
- }
- }
- }
- */
- public OneSVariables()
- {
- for(new i=0; i<MAX_PLAYERS; i++)
- {
- if(IsPlayerConnected(i))
- {
- if(HasBombedRecently[i] >= 1)
- {
- HasBombedRecently[i] --;
- }
- if(HasBlownVehicleRecently[i] >= 1)
- {
- HasBlownVehicleRecently[i] --;
- }
- if(AttemptedToBombRecently[i] >= 1)
- {
- AttemptedToBombRecently[i] --;
- }
- if(AttemptedToDefuseBombRecently[i] >= 1)
- {
- AttemptedToDefuseBombRecently[i] --;
- }
- if(ExplosionTime[i] >= 1)
- {
- new string[50];
- format(string, sizeof(string), "Explosion Time: %d", ExplosionTime[i]);
- TextDrawSetString(ExpTime[1], string);
- ExplosionTime[i] --;
- }
- if(ExplosionTime[i] == 0)
- {
- if(IsPlayerConnected(i))
- {
- if(BombAttached[i] == 1)
- {
- new string[128], Float:x, Float:y, Float:z;
- //new pName[MAX_PLAYER_NAME+1];
- GetPlayerPos(i, x, y, z);
- CreateExplosion(x,y,z,6,10.0);
- SetPlayerHealth(i, 0);
- BombAttached[i] =0;
- format(string, sizeof(string), "[DEATH]{FFFFFF} %s[%d] has been blown to bits with a bomb."/* attached by %s[%d].*/"", GetName(i), i/*, GetPVarString(i, "Name", pName), GetPVarInt(i, "ID")*/);
- SendClientMessageToAll(RED, string);
- TextDrawHideForPlayer(i, Bomb);
- TextDrawHideForPlayer(i, ExpTime[0]);
- TextDrawHideForPlayer(i, ExpTime[1]);
- ExplosionTime[i] =0;
- }
- }
- }
- for(new v=0; v<MAX_VEHICLES; v++)
- {
- if(VehicleBombed[v] > 1)
- {
- VehicleBombed[v] --;
- }
- if(VehicleBombed[v] == 1)
- {
- new Float:x, Float:y, Float:z;
- GetVehiclePos(v, x, y, z);
- CreateExplosion(x, y, z, 6, 10.0);
- SetVehicleToRespawn(v);
- VehicleBombed[v] =0;
- SendClientMessageToAll(RED, "[INFO]{FFFFFF} The vehicle which was bombed by %s has been exploded.");
- }
- }
- }
- }
- }
- public Float:GetDistanceBetweenPlayers(p1,p2)
- {
- new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
- if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
- {
- return -1.00;
- }
- GetPlayerPos(p1,x1,y1,z1);
- GetPlayerPos(p2,x2,y2,z2);
- return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
- }
- stock GetName(playerid)
- {
- new Name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
- return Name;
- }
- //==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement