[FilterScript] Dynamic Military Landmines System
#1

Hello, I would like to present a dynamic system landmines.

Video:
https://www.youtube.com/watch?v=SXwb26E-kkU
https://www.youtube.com/watch?v=_E3tw_qYzhI

Functions:
PHP Code:
Mines::Create(type,Float:detection_range,Float:explode_radius,Float:health,respawntime,Float:x,Float:y,Float:z,worldid,interiorid,playerid,Float:streamdistance,mine_object MINE_OBJECT_STANDARD,teamid ANY_TEAM,detect_type MINE_DETECT_TYPE_ALL,byplayerid INVALID_PLAYER_ID,Float:damage=-1.0,Float:vehicle_damage=-1.0);

type explosion type //https://sampwiki.blast.hk/wiki/Explosion_List
Float:detection_range detection range player/vehicle
Float
:explode_radius the explosion range (the same as in CreateExplosion)
Float:health mine health (set MINE_INFINITY_HEALTH to be indestructible)
respawntime respawn time in seconds
Float
:xFloat:yFloat:zworldidinterioridplayeridFloat:streamdistance the same as in CreateDynamicObject
mine_object 
mine object
teamid 
player team will be immune to detection range or destroy mine
detect_type 
specify which elements are to be detected (MINE_DETECT_TYPE_ALL MINE_DETECT_TYPE_PLAYER MINE_DETECT_TYPE_VEHICLE)
Float:damage player damage on explosion created
Float
:vehicle_damage vehicle damage on explosion created

Mines
::CreateEx(objectid,type,Float:detection_range,Float:explode_radius,Float:health,respawntime,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,worldid,interiorid,playerid,Float:streamdistance,teamid ANY_TEAM,detect_type MINE_DETECT_TYPE_ALL,byplayerid INVALID_PLAYER_ID,Float:damage=-1.0,Float:vehicle_damage=-1.0);

Mines::Destroy(mobid);

Mines::GetExplodeVisibility();
Mines::SetExplodeVisibility(Float:explode_stream); 
Callbacks:
PHP Code:
OnMineDestroy(mobid,Float:x,Float:y,Float:z,type,killerid,Float:radius,damagerid);

types:
MINE_DESTROY_TYPE_DETECT  //When mine has been destroyed by detection range
MINE_DESTROY_TYPE_KILL    //When mine has been destroyed by player shoot 
Mine Object:
PHP Code:
MINE_OBJECT_STANDARD //default
MINE_OBJECT_UNDERWATER
MINE_OBJECT_LASER
MINE_OBJECT_PIZZA 
Example Pawn Code:
PHP Code:
#include <a_samp>
#include <streamer>
#include <ADM/3DTryg>
#include <Mines>

public OnFilterScriptInit(){
    
    
    
/*
    simply enter the coordinates of /save
    AddPlayerClass(71,-0.3440,0.2275,3.1172,65.1647,0,0,0,0,0,0); // 
    and select other parameters
    */
    
    // not recommended set worldid and interiorid -1
    
    
    
Mines::Create(MINE_TYPE_EXPLODE_HUGE2.00.1200.06010.0,0.0,3.11720,0,-1300.0MINE_OBJECT_STANDARD);
    
    
Mines::Create(MINE_TYPE_EXPLODE_SMALL1.50.01100.0150.00.03.11720,0, -1200.0,MINE_OBJECT_PIZZA);
    
    
Mines::Create(MINE_TYPE_EXPLODE_HUGE6.00.012000.012071.8122175.3036, -0.55470,0,-1,200.0MINE_OBJECT_UNDERWATER);

    return 
1;

Example Command:
PHP Code:
CMD:addmine(playerid,params[]){
    if(!
IsPlayerAdmin(playerid)) return 0;
    
    new 
buffer[128], typeFloat:detection_rangeFloat:explode_radiusFloat:healthrespawntime,
        
Float:xFloat:yFloat:zworldidinterioridFloat:streamdistancemine_object MINE_OBJECT_STANDARDteamid ANY_TEAM;
    
GetPlayerPos(playerid,x,y,z);
    
worldid GetPlayerVirtualWorld(playerid);
    
interiorid GetPlayerInterior(playerid);
    if(
sscanf(params,"dfffdfD(-1)D(-1)",type,detection_range,explode_radius,health,respawntime,streamdistance,mine_object,teamid)) return SendClientMessage(playerid,-1,"/addmine <type> <detection r> <explode r> <hp> <respawn> <stream distance> [obj] [team]");
    
    if(
mine_object == -1mine_object MINE_OBJECT_STANDARD;
    if(
teamid == -1teamid ANY_TEAM;
    
    new 
mobid Mines::Create(type,detection_range,explode_radius,health,respawntime,x,y,z,worldid,interiorid,-1,streamdistance,mine_object,teamid);
    
format(buffer,sizeof buffer,"Added mine id %d",mobid);
    
SendClientMessage(playerid,-1,buffer);
    
    
/*
    Mines::SetSpecialWeapon(mobid,GRENADE_SPECIAL_WEAPON_TEARGAS);
    Mines::SetEffectID(mobid,GRENADE_EFFECT_HUGE_SMOKE_1);
    Mines::SetEffectDMG(mobid,1.0);
    Mines::SetEffectVDMG(mobid,0.0);
    Mines::SetEffectTime(mobid,25);
    */
    
    
return 1;
}

CMD:delmine(playerid,params[]){
    if(!
IsPlayerAdmin(playerid)) return 0;
    new 
buffer[128], mobid INVALID_MINE_ID;
    if(
sscanf(params,"d",mobid)) return SendClientMessage(playerid,-1,"/delmine <mobid>");
    
    if(
MineComponent[mobid][mine_status] != MINE_STATUS_UNACTIVE){
        
Mines::Destroy(mobid);
        
format(buffer,sizeof buffer,"Removed mine id %d",mobid);
        
SendClientMessage(playerid,-1,buffer);
    } else {
        
format(buffer,sizeof buffer,"Mine id %d not exist",mobid);
        
SendClientMessage(playerid,-1,buffer);
    }
    return 
1;

Download:
Mines.inc
3DTryg.inc Thread
ExtendedGrenade.inc Thread

Notice:

Filterscript not exist because filterscripts have limits.

This has been replaced by include, having automatic installation, efficient GameMode/FilterScript.


Non-Registered Users:
Bug Report
Reply
#2

Update 1.1: fixed CreateExplosionForRangePoint (reported by Wizzard2H)
Reply
#3

I like it, small but great idea
Reply
#4

Nice, Good for COD servers. Rep++
Reply
#5

Thanks for this amazing include I love it.Also glad you've fixed my bug report
Reply
#6

Awesome job dude.
Reply
#7

Nice one. But you should take a look at this thread: https://sampforum.blast.hk/showthread.php?tid=571153 - how to hook a function in pawn, so people won't need to do this steps:
PHP Code:
//to hook functions 
Min_OnFilterScriptInit(); //IN OnFilterScriptInit OR OnGameModeInit 
Min_OnFilterScriptExit(); //IN OnFilterScriptExit OR OnGameModeExit 
Min_OnPlayerShootDynamicObject(playeridweaponidobjectidxyz); //IN OnPlayerShootDynamicObject 
Min_OnPlayerEnterDynamicArea(playeridareaid); //IN OnPlayerEnterDynamicArea 
Reply
#8

I can, but as a creature of such hooks are many you can get lost
Reply
#9

Nice one!
Reply
#10

added auto hooks in v1.3
Reply
#11

Good Job
Reply
#12

Nice. This looks interesting, going to try this out.
Reply
#13

You forgot one thing here....

Код:
public DestroyDynamicMine(mineid){
	if(mineid < 0 || mineid >= MAX_MINES) return 0;
	DestroyDynamicObject(MineComponent[mineid][mine_objectid]);
	DestroyDynamicArea(MineComponent[mineid][mine_areaid]);
No verification of the mine actually exists but still running deletion functions on arbitrary reference id's is never good
Reply
#14

Quote:
Originally Posted by Pottus
Посмотреть сообщение
You forgot one thing here....

Код:
public DestroyDynamicMine(mineid){
	if(mineid < 0 || mineid >= MAX_MINES) return 0;
	DestroyDynamicObject(MineComponent[mineid][mine_objectid]);
	DestroyDynamicArea(MineComponent[mineid][mine_areaid]);
No verification of the mine actually exists but still running deletion functions on arbitrary reference id's is never good
True, I forgot.
I corrected.
Reply
#15

added a new parameter 'mine_object'

Values:
PHP код:
MINE_OBJECT_STANDARD //default
MINE_OBJECT_UNDERWATER
MINE_OBJECT_LASER
MINE_OBJECT_PIZZA 
//what ? xD 
Reply
#16

Update 1.6:
Added additional parameters:

Код:
CreateDynamicMine(type,Float:detection_range,Float:explode_radius,Float:health,respawntime,
Float:x,Float:y,Float:z,worldid,interiorid,playerid,Float:streamdistance,
mine_object=MINE_OBJECT_STANDARD,teamid=ANY_TEAM); 

teamid - player team will be immune to detection range or destroy mine
Reply
#17

you should make an command to plant them btw, good job +rep
Reply
#18

Quote:
Originally Posted by samp_boy
Посмотреть сообщение
you should make an command to plant them btw, good job +rep
Example command has been added in description
Reply
#19

Update v1.7:

Added callback:
PHP код:
OnMineDestroy(mobid,Float:x,Float:y,Float:z,type,killerid); 
Fixed explosion in VW = -1, INT = -1
Reply
#20

Update v1.8:
- Increase Mine capacity from 300 to 2048
- Added function CreateDynamicMineEx
PHP код:
CreateDynamicMineEx(objectid,type,Float:detection_range,Float:explode_radius,Float:health,respawntime,Float:x,Float:y,Float:z,Float:rx,Float:ry,Float:rz,worldid,interiorid,playerid,Float:streamdistance,teamid ANY_TEAM); 
- Added extended functions:
PHP код:
Float:GetMineExplodeVisibility();
SetMineExplodeVisibility(Float:explode_stream); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)