Raised This Month: $32 Target: $400
 8% 

Solved How to set Physics Properties on custom model ?


Post New Thread Reply   
 
Thread Tools Display Modes
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 05-22-2020 , 11:17   Re: How to set Physics Properties on custom model ?
Reply With Quote #11

Just forgotten to say if you use Blender than there is a pretty nice plugin called "vhacd" for making phymodels......
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 05-22-2020 , 11:55   Re: How to set Physics Properties on custom model ?
Reply With Quote #12

Actually i posted the 3 or 4 files than the .mdl outpouts when i decompile it, and i think it has $concave in the qc :/ how can i debug whats the error is ? maybe is plugin error, or is model error 100% ? because the guy made the model from 0

PD: Do you have a model or something just to test if the physics are correct in the model, so i can replace the route model and see if it works with a correct model... if works its plugin problems so i can go out of doubt.
__________________

Last edited by Elitcky; 05-22-2020 at 11:58.
Elitcky is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 05-22-2020 , 12:20   Re: How to set Physics Properties on custom model ?
Reply With Quote #13

Yeah, create a blank txt-file ex. "test.txt" , in it place:

Code:
"E:\Steam\SteamApps\common\Counter-Strike Global Offensive\bin\studiomdl.exe" -printbones -debug %1

Pause
Replace this: "E:\Steam\SteamApps\common\Counter-Strike Global Offensive\bin" with your own path to studio.mdl.

Save the file and rename it to "test.bat" and place it on your desktop. Open a new window and go to where your qc-file is located. Simply now drag and drop your qc-file on the created test.bat.
It will print out in a window all steps/bones/errors/progress and not close the window automaticly.
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 05-22-2020 , 12:40   Re: How to set Physics Properties on custom model ?
Reply With Quote #14

Code:
C:\Users\cheby\Desktop\SSSSSSSSSS\wee>"C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\bin\studiomdl.exe" -printbones -debug C:\Users\cheby\Desktop\SSSSSSSSSS\wee\tripmine.qc
WARNING: AppFramework : Unable to load module p4lib.dll!
WARNING: Warning: falling back to auto detection of vproject directory.
WARNING: Unable to find gameinfo.txt. Solutions:

1. Read http://www.valve-erc.com/srcsdk/faq.html#NoGameDir
2. Run vconfig to specify which game you're working on.
3. Add -game <path> on the command line where <path> is the directory that gameinfo.txt is in.

Unable to find gameinfo.txt. Solutions:

1. Read http://www.valve-erc.com/srcsdk/faq.html#NoGameDir
2. Run vconfig to specify which game you're working on.
3. Add -game <path> on the command line where <path> is the directory that gameinfo.txt is in.


ERROR: 'EXCEPTION_ACCESS_VIOLATION' (assert: 1)

C:\Users\cheby\Desktop\SSSSSSSSSS\wee>Pause
Presione una tecla para continuar . . .
EDIT: I needed to put some params in the start line to fix that errors, this is the actual output

Code:
C:\Users\cheby\Desktop\SSSSSSSSSS\wee>"C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\bin\studiomdl.exe" -printbones -game "C:/Program Files (x86)/Steam/steamapps/common/Counter-Strike Global Offensive/csgo/" -nop4 -debug C:\Users\cheby\Desktop\SSSSSSSSSS\wee\tripmine.qc
qdir:    "c:\users\cheby\desktop\ssssssssss\wee\"
gamedir: "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\"
g_path:  "C:\Users\cheby\Desktop\SSSSSSSSSS\wee\tripmine.qc"
Building binary model files...
Working on "tripmine.qc"
SMD MODEL perfectworld_wings01_v3_reference.smd
SMD MODEL tripmine_anims\idle.smd
SMD MODEL tripmine_physics.smd
Processing LOD for material: tripmine
Processing LOD for material: tripmine2
Hardware bone usage:
0 "ValveBiped.Bip01_R_Hand" lod0
  1 "w_tripmine" lod0
        2 bones used in lod 0
CPU bone usage:
0 "ValveBiped.Bip01_R_Hand" lod0
  1 "w_tripmine" lod0
        2 bones used in lod 0
Model has 1 convex sub-parts
Collision model completed.
---------------------
writing C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\models/sharks/tripmine/tripmine.mdl:
Loading preexisting model: C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\models/sharks/tripmine/tripmine.mdl
   Found 1 preexisting sequences.
bones         1180 bytes (2)
   animation       x       y       ips    angle
animations     268 bytes (1 anims) (101 frames) [0:03]
Building sequence index remapping table...
No re-ordering required.
sequences      224 bytes (1 seq)
hdr@0057F174=7A530200
ik/pose        164 bytes
eyeballs         0 bytes (0 eyeballs)
flexes           0 bytes (0 flexes)
hdr@0057F174=7A530200
textures       136 bytes
keyvalues      264 bytes
hdr@0057F16C=7A530398
hdr@0057F174=7A530200
bone transforms      336 bytes
bone flex driver       0 bytes
bodygroup presets       0 bytes
Collision model volume 460.31 in^3
collision        0 bytes
total         2952
---------------------
writing C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\models/sharks/tripmine/tripmine.vvd:
vertices     77568 bytes (1616 vertices)
tangents     25856 bytes (1616 vertices)
total       103488 bytes
---------------------
Generating optimized mesh "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo\models/sharks/tripmine/tripmine.dx90.vtx":
body parts:         8 bytes
models:            20 bytes
model LODs:        12 bytes
meshes:            18 bytes
strip groups:      66 bytes
strips:            70 bytes
verts:          14544 bytes
indices:         8298 bytes
bone changes:      24 bytes
everything:     23084 bytes
WARNING: ConVarRef r_staticlight_streams doesn't point to an existing ConVar
WARNING: ConVarRef r_staticlight_streams_indirect_only doesn't point to an existing ConVar

Completed "tripmine.qc"

C:\Users\cheby\Desktop\SSSSSSSSSS\wee>Pause
Presione una tecla para continuar . . .
__________________

Last edited by Elitcky; 05-22-2020 at 12:47.
Elitcky is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 05-22-2020 , 15:44   Re: How to set Physics Properties on custom model ?
Reply With Quote #15

Well if you would try out another existing Tripminemodel than go to this:https://forums.alliedmods.net/showthread.php?t=201305

Otherwise ask the guy that made your model if he can check the phymodel he created.....
__________________
Waiting for HL3,Day of Defeat3 ,but will it ever come? So I'm gonna play COD WW2.>>>>SM_SKINCHOOSER<<<<
>>You need Models for DODS/CSS/CSGO , than click here!!!<<
andi67 is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 05-22-2020 , 18:00   Re: How to set Physics Properties on custom model ?
Reply With Quote #16

Well it didn't created the physics either sir :/
photo: https://prnt.sc/sm1oa4

Should be something with the plugin ?
PHP Code:
#pragma semicolon 1

/*
            I N C L U D E S
    ------------------------------------------------
*/
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <lasermines>
#include <csgocolors>
/*
    ------------------------------------------------
*/

/*
            D E F I N E S
    ------------------------------------------------
*/
#define PLUGIN_VERSION "1.5.1"

#define MDL_LASER "materials/sprites/purplelaser1.vmt"
#define MDL_MINE "models/tripmine/tripmine.mdl"

#define SND_MINEPUT "laser/mine_deploy.mp3"
#define SND_MINEACT "laser/mine_activate.mp3"
#define SND_BUYMINE "laser/gunpickup2.mp3"
#define SND_CANTBUY "buttons/weapon_cant_buy.wav"
/*
    ------------------------------------------------
*/

/*
        |G|  |L| |O| |B| |A| |L| |S|
    ------------------------------------------------
*/

new Handle:h_enablebool:b_enable,
    
Handle:h_messagebool:b_message,
    
Handle:h_amounti_amount,
    
Handle:h_maxamounti_maxamount,
    
Handle:h_damagei_damage,
    
Handle:h_explode_damagei_explode_damage,
    
Handle:h_explode_radiusi_explode_radius,
    
Handle:h_healthi_health,
    
Handle:h_color_tString:s_color_t[16],
    
Handle:h_color_ctString:s_color_ct[16],
    
Handle:h_activate_timeFloat:f_activate_time,
    
Handle:h_use_buy_modebool:b_use_buy_mode,
    
Handle:h_should_buy_zonebool:b_should_buy_zone,
    
Handle:h_allow_pickupbool:b_allow_pickup,
    
Handle:h_allow_friendly_pickupbool:b_allow_friendly_pickup,
    
Handle:h_allow_enemy_pickupbool:b_allow_enemy_pickup,
    
Handle:h_pricei_price,
    
Handle:h_wpn_dmgString:s_wpn_dmg[16],
    
Handle:h_lm_hsbool:b_lm_hs;

new 
Handle:h_friendlyfirebool:b_friendlyfire;

/*
        F O R W A R D S
    ------------------------------------------------
*/
new Handle:h_fwdOnPlantLasermine,
    
Handle:h_fwdOnLaserminePlanted,
    
Handle:h_fwdOnPreHitByLasermine,
    
Handle:h_fwdOnPostHitByLasermine,
    
Handle:h_fwdOnPreBuyLasermine,
    
Handle:h_fwdOnPostBuyLasermine,
    
Handle:h_fwdOnPrePickupLasermine,
    
Handle:h_fwdOnPostPickupLasermine;

/*
    ------------------------------------------------
*/

new i_clients_amount[MAXPLAYERS+1],
    
i_clients_myamount[MAXPLAYERS+1],
    
i_clients_maxlimit[MAXPLAYERS+1],
    
b_used_by_native[MAXPLAYERS+1],
    
i_buy_limit[MAXPLAYERS+1];

new 
gInBuyZone = -1;
new 
gAccount = -1;

/*
        P L U G I N    I N F O
    ------------------------------------------------
*/

public Plugin:myinfo 
{
    
name "[CS:GO] Lasermines",
    
author "FrozDark (adapting by Grey83)",
    
description "Plants a laser mine in CS:GO",
    
version PLUGIN_VERSION,
    
url "http://www.hlmod.ru/"
};

new 
bool:b_late;
/*
    Fires when the plugin is asked to be loaded
    -------------------------------------------------------
*/
public APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
    
CreateNative("AddClientLasermines"Native_AddMines);
    
CreateNative("SetClientLasermines"Native_SetMines);
    
CreateNative("SubClientLasermines"Native_SubstractMines);
    
CreateNative("GetClientLasermines"Native_GetMines);
    
CreateNative("PlantClientLasermine"Native_PlantMine);
    
CreateNative("ClearMapClientLasermines"Native_ClearMapMines);
    
CreateNative("IsEntityLasermine"Native_IsLasermine);
    
CreateNative("GetClientByLasermine"Native_GetClientByLasermine);
    
CreateNative("SetClientMaxLasermines"Native_SetClientMaxLasermines);
    
CreateNative("ResetClientMaxLasermines"Native_ResetClientMaxLasermines);
    
CreateNative("GetBeamByLasermine"Native_GetBeamByLasermine);
    
CreateNative("GetLasermineByBeam"Native_GetLasermineByBeam);
    
    
h_fwdOnPlantLasermine CreateGlobalForward("OnPlantLasermine"ET_HookParam_CellParam_FloatByRefParam_CellByRefParam_CellByRefParam_CellByRefParam_Array);
    
h_fwdOnLaserminePlanted CreateGlobalForward("OnLaserminePlanted"ET_IgnoreParam_CellParam_CellParam_FloatParam_CellParam_CellParam_CellParam_Array);
    
    
h_fwdOnPreHitByLasermine CreateGlobalForward("OnPreHitByLasermine"ET_HookParam_CellParam_CellByRefParam_CellByRefParam_CellByRefParam_CellByRef);
    
h_fwdOnPostHitByLasermine CreateGlobalForward("OnPostHitByLasermine"ET_IgnoreParam_CellParam_CellParam_CellParam_CellParam_Cell);
    
    
h_fwdOnPreBuyLasermine CreateGlobalForward("OnPreBuyLasermine"ET_HookParam_CellParam_CellByRefParam_CellByRef);
    
h_fwdOnPostBuyLasermine CreateGlobalForward("OnPostBuyLasermine"ET_IgnoreParam_CellParam_CellParam_Cell);
    
    
h_fwdOnPrePickupLasermine CreateGlobalForward("OnPrePickupLasermine"ET_EventParam_CellParam_CellParam_Cell);
    
h_fwdOnPostPickupLasermine CreateGlobalForward("OnPostPickupLasermine"ET_IgnoreParam_CellParam_CellParam_Cell);
    
    
RegPluginLibrary("lasermines");
    
    
b_late late;
    
    return 
APLRes_Success;
}

/*
        Fires when the plugin starts
    ------------------------------------------------
*/
public OnPluginStart()
{
    
// Creates console variable version
    
CreateConVar("csgo_lasermines_version"PLUGIN_VERSION"The version of the plugin"FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
    
// Creates console variables
    
h_enable CreateConVar("sm_lasermines_enable""1""Enables/Disables the plugin"FCVAR_NOTIFYtrue0.0true1.0);
    
h_message CreateConVar("sm_lasermines_welcome_message""1""Show Plugin Message at the beginning of each round."_true0.0true1.0);
    
h_amount CreateConVar("sm_lasermines_amount""3""The amount to give laser mines to a player each spawn (if buy mode is disabled, -1 = Infinity)"_true, -1.0);
    
h_maxamount CreateConVar("sm_lasermines_maxamount""3""The maximum amount of laser mines a player can carry. (0-Unlimited)"_true0.0);
    
h_damage CreateConVar("sm_lasermines_damage""500""The damage to deal to a player by the laser"_true1.0true100000.0);
    
h_explode_damage CreateConVar("sm_lasermines_explode_damage""300""The damage to deal to a player when a laser mine breaks"_true0.0true100000.0);
    
h_explode_radius CreateConVar("sm_lasermines_explode_radius""300""The radius of the explosion"_true1.0true100000.0);
    
h_health CreateConVar("sm_lasermines_health""300""The laser mines health. 0 = never breaked"_true0.0true100000.0);
    
h_activate_time CreateConVar("sm_lasermines_activatetime""2""The delay of laser mines' activation"_true0.0true10.0);
    
h_use_buy_mode CreateConVar("sm_lasermines_buymode""0""Enables buy mode. In this mode you will have to buy mines"FCVAR_NOTIFYtrue0.0true1.0);
    
h_should_buy_zone CreateConVar("sm_lasermines_buyzone""1""Whether a player have to stay in buy zone to buy mines"FCVAR_NOTIFYtrue0.0true1.0);
    
h_price CreateConVar("sm_lasermines_price""500""The price of the laser mines"FCVAR_NOTIFYtrue0.0);
    
h_color_t CreateConVar("sm_lasermines_color_t""255 127 0""Terrorist's color. Set by RGB"_);
    
h_color_ct CreateConVar("sm_lasermines_color_ct""0 127 255""Counter-Terrorist's color. Set by RGB"_);
    
h_allow_pickup CreateConVar("sm_lasermines_allow_pickup""1""Allow players to pickup their planted lasermines"_);
    
h_allow_friendly_pickup CreateConVar("sm_lasermines_allow_friendly_pickup""0""Allow players to pickup allies planted lasermines"_);
    
h_allow_enemy_pickup CreateConVar("sm_lasermines_allow_enemy_pickup""0""Allow players to pickup enemys planted lasermines"_);
    
h_wpn_dmg CreateConVar("sm_lasermines_wpn""taser""Enemy has died from this weapon"_);
    
h_lm_hs CreateConVar("sm_lasermines_hs""1""Headshot On/Off"_true0.0true1.0);
    
    
h_friendlyfire FindConVar("mp_friendlyfire");
    
    
// Gets them to the global
    
b_enable GetConVarBool(h_enable);
    
b_message GetConVarBool(h_message);
    
i_amount GetConVarInt(h_amount);
    
i_maxamount GetConVarInt(h_maxamount);
    
i_damage GetConVarInt(h_damage);
    
i_explode_damage GetConVarInt(h_explode_damage);
    
i_explode_radius GetConVarInt(h_explode_radius);
    
i_health GetConVarInt(h_health);
    
f_activate_time GetConVarFloat(h_activate_time);
    
b_use_buy_mode GetConVarBool(h_use_buy_mode);
    
b_should_buy_zone GetConVarBool(h_should_buy_zone);
    
i_price GetConVarInt(h_price);
    
b_allow_pickup GetConVarBool(h_allow_pickup);
    
b_allow_friendly_pickup GetConVarBool(h_allow_friendly_pickup);
    
b_allow_enemy_pickup GetConVarBool(h_allow_enemy_pickup);
    
    
GetConVarString(h_color_ts_color_tsizeof(s_color_t));
    
GetConVarString(h_color_cts_color_ctsizeof(s_color_ct));
    
GetConVarString(h_wpn_dmgs_wpn_dmgsizeof(s_wpn_dmg));
    
b_lm_hs GetConVarBool(h_lm_hs);
    
    
b_friendlyfire GetConVarBool(h_friendlyfire);
    
    
// Hooks their change
    
HookConVarChange(h_enableOnConVarChanged);
    
HookConVarChange(h_messageOnConVarChanged);
    
HookConVarChange(h_amountOnConVarChanged);
    
HookConVarChange(h_maxamountOnConVarChanged);
    
HookConVarChange(h_damageOnConVarChanged);
    
HookConVarChange(h_explode_damageOnConVarChanged);
    
HookConVarChange(h_explode_radiusOnConVarChanged);
    
HookConVarChange(h_healthOnConVarChanged);
    
HookConVarChange(h_activate_timeOnConVarChanged);
    
HookConVarChange(h_use_buy_modeOnConVarChanged);
    
HookConVarChange(h_should_buy_zoneOnConVarChanged);
    
HookConVarChange(h_priceOnConVarChanged);
    
HookConVarChange(h_color_tOnConVarChanged);
    
HookConVarChange(h_color_ctOnConVarChanged);
    
HookConVarChange(h_allow_pickupOnConVarChanged);
    
HookConVarChange(h_allow_friendly_pickupOnConVarChanged);
    
HookConVarChange(h_allow_enemy_pickupOnConVarChanged);
    
HookConVarChange(h_wpn_dmgOnConVarChanged);
    
HookConVarChange(h_lm_hsOnConVarChanged);
    
    
HookConVarChange(h_friendlyfireOnConVarChanged);
    
    
// Hooks event changes
    
HookEvent("player_spawn"OnPlayerSpawn);
//    HookEvent("player_death", OnPlayerDeath);
    
HookEvent("player_death"OnPlayerDeath_PreEventHookMode_Pre);
    
HookEvent("round_start"RoundStart);
    
    
// Registers new console commands
    
RegConsoleCmd("sm_colocar"Command_PlantMine"Plant a laser mine");

    
RegConsoleCmd("sm_sacar",Cmd_RemoveMines"Remove all your laser mines");

    
RegConsoleCmd("sm_lm"Command_BuyMines"Buy laser mines");
    
RegConsoleCmd("sm_lasermine"Command_BuyMines"Buy laser mines");

    
// Hooks entity env_beam ouput events
    
HookEntityOutput("env_beam""OnTouchedByEntity"OnTouchedByEntity);
    
    
// Loads the translation
    
LoadTranslations("csgo_lasermines.phrases");
    
    
// Finds offsets
    
if ((gInBuyZone FindSendPropInfo("CCSPlayer""m_bInBuyZone")) == -1)
        
SetFailState("Could not find offset \"m_bInBuyZone\"");
    if ((
gAccount FindSendPropInfo("CCSPlayer""m_iAccount")) == -1)
        
SetFailState("Could not find offset \"m_iAccount\"");
    
    
AutoExecConfig(true"plugin.csgo_lasermines");
    
    if (
b_late)
    {
        
b_late false;
        
OnMapStart();
    }
}
/*
    ------------------------------------------------
*/

/*
            Cvars changes
    ------------------------------------------------
*/
public OnConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if (
convar == h_enable)
    {
        
b_enable bool:StringToInt(newValue);
    }
    else if (
convar == h_message)
    {
        
b_message bool:StringToInt(newValue);
    }
    else if (
convar == h_amount)
    {
        
i_amount StringToInt(newValue);
        
LookupClients();
    }
    else if (
convar == h_maxamount)
    {
        
i_maxamount StringToInt(newValue);
        
LookupClients();
    }
    else if (
convar == h_damage)
    {
        
i_damage StringToInt(newValue);
    }
    else if (
convar == h_explode_damage)
    {
        
i_explode_damage StringToInt(newValue);
    }
    else if (
convar == h_explode_radius)
    {
        
i_explode_radius StringToInt(newValue);
    }
    else if (
convar == h_health)
    {
        
i_health StringToInt(newValue);
    }
    else if (
convar == h_activate_time)
    {
        
f_activate_time StringToFloat(newValue);
    }
    else if (
convar == h_use_buy_mode)
    {
        
b_use_buy_mode bool:StringToInt(newValue);
    }
    else if (
convar == h_should_buy_zone)
    {
        
b_should_buy_zone bool:StringToInt(newValue);
    }
    else if (
convar == h_price)
    {
        
i_price StringToInt(newValue);
    }
    else if (
convar == h_color_t)
    {
        
strcopy(s_color_tsizeof(s_color_t), newValue);
    }
    else if (
convar == h_color_ct)
    {
        
strcopy(s_color_ctsizeof(s_color_ct), newValue);
    }
    else if (
convar == h_friendlyfire)
    {
        
b_friendlyfire bool:StringToInt(newValue);
    }
    else if (
convar == h_allow_pickup)
    {
        
b_allow_pickup bool:StringToInt(newValue);
    }
    else if (
convar == h_allow_friendly_pickup)
    {
        
b_allow_friendly_pickup bool:StringToInt(newValue);
    }
    else if (
convar == h_allow_enemy_pickup)
    {
        
b_allow_enemy_pickup bool:StringToInt(newValue);
    }
    else if (
convar == h_wpn_dmg)
    {
        
strcopy(s_wpn_dmgsizeof(s_wpn_dmg), newValue);
    }
    else if (
convar == h_lm_hs)
    {
        
b_lm_hs bool:StringToInt(newValue);
    }
}

LookupClients()
{
    for (new 
1<= MaxClientsi++)
    {
        
OnClientConnected(i);
    }
}


/*
        Fires when the map starts
    ------------------------------------------------
*/
public OnMapStart()
{
    
PrecacheModel(MDL_MINEtrue);
    
PrecacheModel(MDL_LASERtrue);

    
PrecacheSound(SND_MINEPUTtrue);
    
PrecacheSound(SND_MINEACTtrue);
    
PrecacheSound(SND_BUYMINEtrue);
    
PrecacheSound(SND_CANTBUYtrue);

    
AddFileToDownloadsTable"models/tripmine/tripmine.dx90.vtx" );
    
AddFileToDownloadsTable"models/sharks/tripmine/tripmine.mdl" );
    
AddFileToDownloadsTable"models/tripmine/tripmine.phy" );
    
AddFileToDownloadsTable"models/tripmine/tripmine.vvd" );

    
AddFileToDownloadsTable"materials/models/tripmine/minetexture.vmt" );
    
AddFileToDownloadsTable"materials/models/tripmine/minetexture.vtf" );
}
/*
    ------------------------------------------------
*/

public RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    if(
b_enable && b_message)
    {
          if(
b_use_buy_modeCPrintToChatAll("%t""Welcome Message 2");
         else 
CPrintToChatAll("%t""Welcome Message 1");
    }
}
/*
    ------------------------------------------------
*/

public OnClientConnected(client)
{
    if (!
b_used_by_native[client])
    {
        
i_clients_maxlimit[client] = i_maxamount;
        
i_clients_myamount[client] = i_amount;
    }
}

/*
    Fires when a client disconnects
    ------------------------------------------------
*/
public OnClientDisconnect(client)
{
    
i_buy_limit[client] = 0;
    for (new 
index MaxClients+1index <= 2048index++)
    {
        if (
GetClientByLasermine(index) == client)
        {
            
SDKUnhook(indexSDKHook_OnTakeDamageOnTakeDamage);
            
AcceptEntityInput(index"KillHierarchy");
        }
    }
}

/*
    Fires when a client fully disconnected
    ------------------------------------------------
*/
public OnClientDisconnect_Post(client)
{
    
i_clients_amount[client] = 0;
    
b_used_by_native[client] = false;
}

/*
            Touch event
    ------------------------------------------------
*/
public OnTouchedByEntity(const String:output[], calleractivatorFloat:delay)
{
    if (!(
<= activator <= MaxClients))
    {
        return;
    }
    new 
owner GetEntPropEnt(callerProp_Data"m_hOwnerEntity");
    new 
lasermine GetLasermineByBeam(caller);
    
    if (
owner == -|| lasermine == -|| activator == owner || (!b_friendlyfire && GetClientTeam(activator) == GetClientTeam(owner)))
    {
        return;
    }
    
    
decl dummy_callerdummy_ownerdamagedummy_lasermine;
    
dummy_caller caller;
    
dummy_owner owner;
    
damage i_damage;
    
dummy_lasermine lasermine;
    
    new 
Action:result Forward_OnPreHit(activatordummy_ownerdummy_callerdummy_laserminedamage);
    
    switch (
result)
    {
        case 
Plugin_HandledPlugin_Stop :
        {
            return;
        }
        case 
Plugin_Continue :
        {
            
dummy_caller caller;
            
dummy_owner owner;
            
damage i_damage;
            
dummy_lasermine lasermine;
        }
    }
    
    
// Make custom damage to the client
    
SDKHooks_TakeDamage(activatordummy_callerdummy_ownerfloat(damage), DMG_ENERGYBEAM);
    
    
Forward_OnPostHit(activatordummy_ownerdummy_callerdummy_laserminedamage);
}

public 
OnPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
b_use_buy_mode)
    {
        
i_clients_amount[client] = i_clients_myamount[client];
    }
}

//public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
//{
//    new client = GetClientOfUserId(GetEventInt(event, "userid"));
//    OnClientDisconnect(client);
//}

public Action:OnPlayerDeath_Pre(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
attacker GetClientOfUserId(GetEventInt(event"attacker"));
    if (
<= attacker <= MaxClients)
    {
        
decl String:g_szWeapon[32];
        
GetEventString(event"weapon"g_szWeaponsizeof(g_szWeapon));
        if (
StrEqual(g_szWeapon"env_beam"))
        {
            
SetEventString(event"weapon"s_wpn_dmg);
            if (
b_lm_hs)
            {
                
SetEventBool(event"headshot"true);
            }
        }
    }
    return 
Plugin_Continue;
}

/*
    ------------------------------------------------
*/
public Action:Command_BuyMines(clientargc)
{
    
// client = 0    or    disabled    or    buy mode disabled    or    unlimited amount    or    client is not in game
    
if (!client || !b_enable || !b_use_buy_mode || i_clients_myamount[client] == -|| !IsClientInGame(client))
    {
        return 
Plugin_Continue;    // Stop trigger the command
    
}
    
// client is dead
    
if (!IsPlayerAlive(client))
    {
        
PrintHintText(client"%t""Can't buy, while dead");
        return 
Plugin_Handled;    // Stop trigger the command
    
}
    
// client is spectator
    
if (GetClientTeam(client) <= 1)
    {
        
PrintHintText(client"%t""Can't use, while spec");
        return 
Plugin_Handled;    // Stop trigger the command
    
}
    
// If  buy zone mode is enabled and player is out of buy zone range
    
if (b_should_buy_zone && !bool:GetEntData(clientgInBuyZone1))
    {
        
PrintHintText(client"%t""Out of buy zone");
        return 
Plugin_Handled;    // Stop trigger the command
    
}
    
    new 
amount 1;
    if (
argc)
    {
        
decl String:txt[6];
        
GetCmdArg(1txtsizeof(txt));
        
amount StringToInt(txt);
        if (
bool:i_clients_maxlimit[client])
        {
            if (
amount i_clients_maxlimit[client])
            {
                
amount i_clients_maxlimit[client];
            }
            else if (
amount 1)
            {
                
amount 1;
            }
        }
    }
    
    
decl dummy_amountcostboughtamount;
    
dummy_amount amount;
    
cost i_price;
    
boughtamount 0;
    new 
Action:result Forward_OnPreBuy(clientdummy_amountcost);
    
    switch (
result)
    {
        case 
Plugin_HandledPlugin_Stop :
        {
            return 
result;
        }
        case 
Plugin_Continue :
        {
            
dummy_amount amount;
            
cost i_price;
        }
    }
    
    new 
money GetEntData(clientgAccount);
    do
    {
        if (
bool:i_clients_maxlimit[client] && (i_clients_amount[client] >= i_clients_maxlimit[client]) || (i_buy_limit[client] >= i_clients_maxlimit[client]))
        {
            
PrintHintText(client"%t""Can't buy, max amount"i_clients_maxlimit[client]);
            return 
Plugin_Handled;
        }
        
        
money -= cost;
        
        if (
money 0)
        {
            
PrintHintText(client"%t""Can't buy, not enough money"i_clients_amount[client]);
            
EmitSoundToClient(clientSND_CANTBUY);
            return 
Plugin_Handled;
        }
        
SetEntData(clientgAccountmoney);
        
i_clients_amount[client]++;
        
i_buy_limit[client]++;
        
boughtamount++;
    } while (--
dummy_amount);
    
    if (
boughtamount)
    {
        
PrintHintText(client"%t""Mines"i_clients_amount[client]);
        
EmitSoundToClient(clientSND_BUYMINE);
        
Forward_OnPostBuy(clientboughtamountboughtamount*cost);
    }
    
    return 
Plugin_Handled;
}

/*
    ------------------------------------------------
*/
public Action:Command_PlantMine(clientargc)
{
    if (!
client || !b_enable || !IsClientInGame(client))
    {
        return 
Plugin_Continue;
    }
    if (!
i_clients_amount[client])
    {
        
PrintHintText(client"%t""Mines"i_clients_amount[client]);
        return 
Plugin_Handled;
    }
    if (!
IsPlayerAlive(client))
    {
        
PrintHintText(client"%t""Can't plant, while dead");
        return 
Plugin_Handled;
    }
    
    
decl color[3];
    switch (
GetClientTeam(client))
    {
        case 
:
        {
            
StringToColor(s_color_tcolor255);
        }
        case 
:
        {
            
StringToColor(s_color_ctcolor255);
        }
        default :
        {
            
PrintHintText(client"%t""Can't use, while spec");
            return 
Plugin_Handled;
        }
    }
    
    
decl Float:delay_timedummy_damagedummy_radiushealthdummy_color[3];
    
delay_time f_activate_time;
    
dummy_damage i_explode_damage;
    
dummy_radius i_explode_radius;
    
health i_health;
    
dummy_color color;
    
    new 
Action:result Forward_OnPlantMine(clientdelay_timedummy_damagedummy_radiushealthdummy_color);
    
    switch (
result)
    {
        case 
Plugin_HandledPlugin_Stop :
        {
            return 
result;
        }
        case 
Plugin_Continue :
        {
            
delay_time f_activate_time;
            
dummy_damage i_explode_damage;
            
dummy_radius i_explode_radius;
            
health i_health;
            
dummy_color color;
        }
    }
    
    new 
mine;
    if ((
mine PlantMine(clientdelay_timedummy_damagedummy_radiushealthdummy_color)) == -1)
        return 
Plugin_Handled;
    
    
Forward_OnMinePlanted(clientminedelay_timedummy_damagedummy_radiushealthdummy_color);
    
    switch (
i_clients_amount[client])
    {
        case -
:
        {
            
PrintHintText(client"%t""Infinity mines");
        }
        default :
        {
            
i_clients_amount[client]--;
            
PrintHintText(client"%t""Mines"i_clients_amount[client]);
        }
    }
    
    return 
Plugin_Handled;
}

public 
Action:Cmd_RemoveMines(clientargc)
{
    if(!
b_allow_pickup || IsFakeClient(client) || !IsPlayerAlive(client))
        return 
Plugin_Handled;

    new 
= -1;
    while ((
FindEntityByClassname(i"prop_physics_override")) != -&& GetClientByLasermine(i) == client)
    {
        
PickupLasermine(clienticlient);
        break;
    }

    return 
Plugin_Handled;
}

public 
Action:OnPlayerRunCmd(client, &buttons, &impulseFloat:vel[3], Float:angles[3], &weapon)
{
    static 
iPrevButtons[MAXPLAYERS+1];

    if (!
b_allow_pickup || IsFakeClient(client) || !IsPlayerAlive(client))
        return 
Plugin_Continue;
    
    if ((
buttons IN_USE) && !(iPrevButtons[client] & IN_USE))
    {
        
OnButtonPressed(client);
    }
    
    
iPrevButtons[client] = buttons;
    
    return 
Plugin_Continue;
}

OnButtonPressed(client)
{
    new 
Handle:trace TraceRay(client);
    
    new 
ent = -1;
    if (
TR_DidHit(trace) && (ent TR_GetEntityIndex(trace)) > MaxClients)
    {    
        
CloseHandle(trace);
        new 
owner GetClientByLasermine(ent);
        if (
owner == -1)
        {
            return;
        }
        if (
owner == client)
        {
            
PickupLasermine(cliententowner);
            return;
        }
        if (
GetClientTeam(owner) == GetClientTeam(client))
        {
            if (
b_allow_friendly_pickup)
            {
                
PickupLasermine(cliententowner);
            }
        }
        else if (
b_allow_enemy_pickup)
        {
            
PickupLasermine(cliententowner);
        }
    }
    else
        
CloseHandle(trace);
}

PickupLasermine(clientlasermineowner)
{
    if (
i_clients_amount[client] >= && i_clients_amount[client] == AddClientLasermines(client))
    {
        return;
    }
    
    new 
Action:result Forward_OnPrePickup(clientlasermineowner);
    
    switch (
result)
    {
        case 
Plugin_HandledPlugin_Stop :
        {
            return;
        }
    }
    
    
RemoveEntity(lasermine);
    if (
i_clients_amount[client] >= 0)
        
PrintHintText(client"%t""Mines"i_clients_amount[client]);
    else
        
PrintHintText(client"%t""Infinity mines");
    
EmitSoundToClient(clientSND_BUYMINE);
    
    
Forward_OnPostPickup(clientlasermineowner);
}

Handle:TraceRay(client)
{
    new 
Float:startent[3], Float:angle[3], Float:end[3];
    
GetClientEyePosition(clientstartent);
    
GetClientEyeAngles(clientangle);
    
GetAngleVectors(angleendNULL_VECTORNULL_VECTOR);
    
NormalizeVector(endend);

    
startent[0] += end[0] * 10.0;
    
startent[1] += end[1] * 10.0;
    
startent[2] += end[2] * 10.0;

    
end[0] = startent[0] + end[0] * 80.0;
    
end[1] = startent[1] + end[1] * 80.0;
    
end[2] = startent[2] + end[2] * 80.0;
    
    return 
TR_TraceRayFilterEx(startentendCONTENTS_SOLIDRayType_EndPointFilterPlayers);
}


/*
    ------------------------------------------------
*/

PlantMine(clientFloat:activation_delay 0.0explode_damageexplode_radius, const health 0, const color[3] = {255255255})
{
    if (
activation_delay 10.0)
    {
        
activation_delay 10.0;
    }
    else if (
activation_delay 0.0)
    {
        
activation_delay 0.0;
    }
    
    new 
Handle:trace TraceRay(client);
    
    
decl Float:end[3], Float:normal[3], Float:beamend[3];
    if (
TR_DidHit(trace) && TR_GetEntityIndex(trace) < 1)
    {
        
TR_GetEndPosition(endtrace);
        
TR_GetPlaneNormal(tracenormal);
        
CloseHandle(trace);
        
        
GetVectorAngles(normalnormal);
        
        
TR_TraceRayFilter(endnormalCONTENTS_SOLIDRayType_InfiniteFilterAll);
        
TR_GetEndPosition(beamendINVALID_HANDLE);
        
        new 
ent CreateEntityByName("prop_physics_override");
        if (
ent == -|| !IsValidEdict(ent))
        {
            
LogError("Could not create entity \"prop_physics_override\"");
            return -
1;
        }
        
        new 
beament CreateEntityByName("env_beam");
        if (
beament == -|| !IsValidEdict(beament))
        {
            
LogError("Could not create entity \"env_beam\"");
            return -
1;
        }
        
        
decl String:start[30], String:tmp[200];
        
Format(startsizeof(start), "Beam%i"beament);
        
        
SetEntityModel(entMDL_MINE);
        
        
decl String:buffer[16];
        
IntToString(explode_damagebuffersizeof(buffer));
        
DispatchKeyValue(ent"ExplodeDamage"buffer);
        
IntToString(explode_radiusbuffersizeof(buffer));
        
DispatchKeyValue(ent"ExplodeRadius"buffer);
        
        
DispatchKeyValue(ent"solid""6");
        
DispatchKeyValue(ent"spawnflags""3");
        
DispatchSpawn(ent);
        
        
AcceptEntityInput(ent"DisableMotion");
        
SetEntityMoveType(entMOVETYPE_NONE);
        
TeleportEntity(entendnormalNULL_VECTOR);
        
        if (
health)
        {
            
SetEntProp(entProp_Data"m_takedamage"2);
            
SetEntProp(entProp_Data"m_iHealth"health);
        }
        
        
Format(tmpsizeof(tmp), "%s,Kill,,0,-1"start);
        
DispatchKeyValue(ent"OnBreak"tmp);
        
        
EmitSoundToAll(SND_MINEPUTent);
        
        
        
        
// Set keyvalues on the beam.
        
DispatchKeyValue(beament"targetname"start);
        
DispatchKeyValue(beament"damage""0");
        
DispatchKeyValue(beament"framestart""0");
        
DispatchKeyValue(beament"BoltWidth""4.0");
        
DispatchKeyValue(beament"renderfx""0");
        
DispatchKeyValue(beament"TouchType""3"); // 0 = none, 1 = player only, 2 = NPC only, 3 = player or NPC, 4 = player, NPC or physprop
        
DispatchKeyValue(beament"framerate""0");
        
DispatchKeyValue(beament"decalname""Bigshot");
        
DispatchKeyValue(beament"TextureScroll""35");
        
DispatchKeyValue(beament"HDRColorScale""1.0");
        
DispatchKeyValue(beament"texture"MDL_LASER);
        
DispatchKeyValue(beament"life""0"); // 0 = infinite, beam life time in seconds
        
DispatchKeyValue(beament"StrikeTime""1"); // If beam life time not infinite, this repeat it back
        
DispatchKeyValue(beament"LightningStart"start);
        
DispatchKeyValue(beament"spawnflags""0"); // 0 disable, 1 = start on, etc etc. look from hammer editor
        
DispatchKeyValue(beament"NoiseAmplitude""0"); // straight beam = 0, other make noise beam
        
DispatchKeyValue(beament"Radius""256");
        
DispatchKeyValue(beament"renderamt""100");
        
DispatchKeyValue(beament"rendercolor""0 0 0");
        
        
AcceptEntityInput(beament"TurnOff");
        
        
SetEntityModel(beamentMDL_LASER);
        
        
TeleportEntity(beamentbeamendNULL_VECTORNULL_VECTOR); // Teleport the beam
        
        
SetEntPropVector(beamentProp_Data"m_vecEndPos"end);
        
SetEntPropFloat(beamentProp_Data"m_fWidth"3.0);
        
SetEntPropFloat(beamentProp_Data"m_fEndWidth"3.0);
        
        
SetEntPropEnt(beamentProp_Data"m_hOwnerEntity"client); // Sets the owner of the beam
        
SetEntPropEnt(entProp_Data"m_hMoveChild"beament);
        
SetEntPropEnt(beamentProp_Data"m_hEffectEntity"ent);
        
        new 
Handle:datapack CreateDataPack();
        
WritePackCell(datapackbeament);
        
WritePackCell(datapackent);
        
WritePackCell(datapackcolor[0]);
        
WritePackCell(datapackcolor[1]);
        
WritePackCell(datapackcolor[2]);
        
WritePackString(datapackstart);
        
CreateTimer(activation_delayOnActivateLaserdatapackTIMER_FLAG_NO_MAPCHANGE|TIMER_HNDL_CLOSE);
        
        
SDKHook(entSDKHook_OnTakeDamageOnTakeDamage);
        
        return 
ent;
    }
    else
        
CloseHandle(trace);
    return -
1;
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)
{
    if (
IsEntityLasermine(victim))
    {
        if (
<= attacker <= MaxClients)
        {
            new 
client GetClientByLasermine(victim);
            if ((
client != -1) && (client != attacker) && (GetClientTeam(client) == GetClientTeam(attacker)))
            {
                return 
Plugin_Handled;
            }
            return 
Plugin_Continue;
        }
        else if (!
IsEntityLasermine(inflictor))
        {
            return 
Plugin_Handled;
        }
    }
    
    return 
Plugin_Continue;
}

/*
    ------------------------------------------------
*/

public bool:FilterAll(entitycontentsMask)
{
    return 
false;
}

public 
bool:FilterPlayers(entitycontentsMask)
{
    return !(
<= entity <= MaxClients);
}

public 
Action:OnActivateLaser(Handle:timerany:hDataPack)
{
    
ResetPack(hDataPack);
    
decl String:start[30], String:tmp[200], color[3];
    new 
beament ReadPackCell(hDataPack);
    new 
ent ReadPackCell(hDataPack);
    
color[0] = ReadPackCell(hDataPack);
    
color[1] = ReadPackCell(hDataPack);
    
color[2] = ReadPackCell(hDataPack);
    
ReadPackString(hDataPackstartsizeof(start));
    
    if (!
IsValidEdict(beament) || !IsValidEdict(ent))
    {
        return 
Plugin_Stop;
    }

    
AcceptEntityInput(beament"TurnOn");
    
    
SetEntityRenderColor(beamentcolor[0], color[1], color[2]);

    
Format(tmpsizeof(tmp), "%s,TurnOff,,0.001,-1"start);
    
DispatchKeyValue(beament"OnTouchedByEntity"tmp);
    
Format(tmpsizeof(tmp), "%s,TurnOn,,0.002,-1"start);
    
DispatchKeyValue(beament"OnTouchedByEntity"tmp);

    
EmitSoundToAll(SND_MINEACTent);
    
    return 
Plugin_Stop;
}

/*
            N A T I V E S
    ------------------------------------------------
*/

public Native_AddMines(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
        return 
0;
    }
    else if (!
IsClientInGame(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not in game"client);
        return 
0;
    }
    
    new 
amount GetNativeCell(2);
    new 
bool:limit bool:GetNativeCell(3);
    
    if (
amount <= 0)
    {
        return 
i_clients_amount[client];
    }
    if (
i_clients_amount[client] < 0)
    {
        return -
1;
    }
    
    
i_clients_amount[client] += amount;
    
    if (
limit)
    {
        if (
i_clients_amount[client] > i_clients_maxlimit[client])
        {
            
i_clients_amount[client] = i_clients_maxlimit[client];
        }
    }
    
    return 
i_clients_amount[client];
}

public 
Native_SetMines(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
        return 
false;
    }
    else if (!
IsClientInGame(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not in game"client);
        return 
false;
    }
    
    new 
amount GetNativeCell(2);
    new 
bool:limit bool:GetNativeCell(3);
    
    if (
amount < -1)
    {
        
amount = -1;
    }
    
    
i_clients_amount[client] = amount;
    
    if (
limit)
    {
        if (
i_clients_amount[client] > i_clients_maxlimit[client])
        {
            
i_clients_amount[client] = i_clients_maxlimit[client];
        }
    }
    
    return 
true;
}

public 
Native_SubstractMines(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
        return 
0;
    }
    else if (!
IsClientInGame(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not in game"client);
        return 
0;
    }
    
    new 
amount GetNativeCell(2);
    
    if (
i_clients_amount[client] == -1)
    {
        return 
i_clients_amount[client];
    }
    
    if (
amount <= 0)
    {
        return 
i_clients_amount[client];
    }
    
    
i_clients_amount[client] -= amount;
    if (
i_clients_amount[client] < 0)
    {
        
i_clients_amount[client] = 0;
    }
    
    return 
i_clients_amount[client];
}

public 
Native_GetMines(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
        return 
0;
    }
    else if (!
IsClientInGame(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not in game"client);
        return 
0;
    }
    
    return 
i_clients_amount[client];
}

public 
Native_ClearMapMines(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
        return;
    }
    else if (!
IsClientInGame(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not in game"client);
        return;
    }
    
    
OnClientDisconnect(client);
}

public 
Native_PlantMine(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
        return 
false;
    }
    else if (!
IsClientInGame(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not in game"client);
        return 
false;
    }
    
    new 
Float:f_delay GetNativeCell(2);
    new 
i_exp_damage GetNativeCell(3);
    new 
i_exp_radius GetNativeCell(4);
    new 
health GetNativeCell(5);
    
decl color[3]; GetNativeArray(6colorsizeof(color));
    
    new 
mine;
    if ((
mine PlantMine(clientf_delayi_exp_damagei_exp_radiushealthcolor)) != -1)
    {
        
Forward_OnMinePlanted(clientminef_delayi_exp_damagei_exp_radiushealthcolor);
    }
    return (
mine != -1);
}

public 
Native_IsLasermine(Handle:pluginnumParams)
{
    new 
entity GetNativeCell(1);
    if (
entity <= MaxClients || !IsValidEdict(entity))
    {
        return 
false;
    }
    
decl String:g_szModel[PLATFORM_MAX_PATH];
    
GetEntPropString(entityProp_Data"m_ModelName"g_szModelsizeof(g_szModel));
    return (
StrEqual(g_szModelMDL_MINEfalse) && GetEntPropEnt(entityProp_Data"m_hMoveChild") != -1);
}

public 
Native_GetClientByLasermine(Handle:pluginnumParams)
{
    new 
entity GetNativeCell(1);
    new 
beam;
    if ((
beam GetBeamByLasermine(entity)) == -1)
    {
        return -
1;
    }
    return 
GetEntPropEnt(beamProp_Data"m_hOwnerEntity");
}

public 
Native_SetClientMaxLasermines(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
    }
    else if (!
IsClientAuthorized(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not authorized"client);
    }
    new 
amount GetNativeCell(2);
    if (
amount < -1)
    {
        
amount = -1;
    }
    
i_clients_maxlimit[client] = amount;
    
i_clients_myamount[client] = amount;
    
b_used_by_native[client] = true;
}

public 
Native_ResetClientMaxLasermines(Handle:pluginnumParams)
{
    new 
client GetNativeCell(1);
    if (
client || client MaxClients)
    {
        
ThrowNativeError(SP_ERROR_INDEX"Client index %i is invalid"client);
    }
    else if (!
IsClientConnected(client))
    {
        
ThrowNativeError(SP_ERROR_NOT_FOUND"Client %i is not connected"client);
    }
    
OnClientConnected(client);
}

public 
Native_GetBeamByLasermine(Handle:pluginnumParams)
{
    new 
entity GetNativeCell(1);
    if (
IsEntityLasermine(entity))
    {
        return 
GetEntPropEnt(entityProp_Data"m_hMoveChild");
    }
    return -
1;
}

public 
Native_GetLasermineByBeam(Handle:pluginnumParams)
{
    new 
mine GetEntPropEnt(GetNativeCell(1), Prop_Data"m_hEffectEntity");
    if (
mine != -&& IsEntityLasermine(mine))
    {
        return 
mine;
    }
    return -
1;
}

/*
        F O R W A R D S
    ------------------------------------------------
*/

Action:Forward_OnPlantMine(client, &Float:activate_time, &exp_damage, &exp_radius, &healthcolor[3])
{
    
decl Action:result;
    
result Plugin_Continue;
    
    
Call_StartForward(h_fwdOnPlantLasermine);
    
Call_PushCell(client);
    
Call_PushFloatRef(activate_time);
    
Call_PushCellRef(exp_damage);
    
Call_PushCellRef(exp_radius);
    
Call_PushCellRef(health);
    
Call_PushArrayEx(colorsizeof(color), SM_PARAM_COPYBACK);
    
Call_Finish(result);
    
    return 
result;
}

Forward_OnMinePlanted(clientmineFloat:activate_timeexp_damageexp_radiushealthcolor[3])
{
    
Call_StartForward(h_fwdOnLaserminePlanted);
    
Call_PushCell(client);
    
Call_PushCell(mine);
    
Call_PushFloat(activate_time);
    
Call_PushCell(exp_damage);
    
Call_PushCell(exp_radius);
    
Call_PushCell(health);
    
Call_PushArray(colorsizeof(color));
    
Call_Finish();
}

Action:Forward_OnPreHit(victim, &attacker, &beam, &lasermine, &damage)
{
    
decl Action:result;
    
result Plugin_Continue;
    
    
Call_StartForward(h_fwdOnPreHitByLasermine);
    
Call_PushCell(victim);
    
Call_PushCellRef(attacker);
    
Call_PushCellRef(beam);
    
Call_PushCellRef(lasermine);
    
Call_PushCellRef(damage);
    
Call_Finish(result);
    
    return 
result;
}

Forward_OnPostHit(victimattackerbeamlaserminedamage)
{
    
Call_StartForward(h_fwdOnPostHitByLasermine);
    
Call_PushCell(victim);
    
Call_PushCell(attacker);
    
Call_PushCell(beam);
    
Call_PushCell(lasermine);
    
Call_PushCell(damage);
    
Call_Finish();
}

Action:Forward_OnPreBuy(client, &amount, &price)
{
    
decl Action:result;
    
result Plugin_Continue;
    
    
Call_StartForward(h_fwdOnPreBuyLasermine);
    
Call_PushCell(client);
    
Call_PushCellRef(amount);
    
Call_PushCellRef(price);
    
Call_Finish(result);
    
    return 
result;
}

Forward_OnPostBuy(clientamountsum)
{
    
Call_StartForward(h_fwdOnPostBuyLasermine);
    
Call_PushCell(client);
    
Call_PushCell(amount);
    
Call_PushCell(sum);
    
Call_Finish();
}

Action:Forward_OnPrePickup(clientlasermineowner)
{
    
decl Action:result;
    
result Plugin_Continue;
    
    
Call_StartForward(h_fwdOnPrePickupLasermine);
    
Call_PushCell(client);
    
Call_PushCell(lasermine);
    
Call_PushCell(owner);
    
Call_Finish(result);
    
    return 
result;
}

Forward_OnPostPickup(clientlasermineowner)
{
    
Call_StartForward(h_fwdOnPostPickupLasermine);
    
Call_PushCell(client);
    
Call_PushCell(lasermine);
    
Call_PushCell(owner);
    
Call_Finish();
}

/*
            S T O C K S
    ------------------------------------------------
*/


stock bool:StringToColor(const String:str[], color[3], const defvalue = -1)
{
    new 
bool:result false;
    
decl String:Splitter[3][64];
    if (
ExplodeString(str" "Splittersizeof(Splitter), sizeof(Splitter[])) == && String_IsNumeric(Splitter[0]) && String_IsNumeric(Splitter[1]) && String_IsNumeric(Splitter[2]))
    {
        
color[0] = StringToInt(Splitter[0]);
        
color[1] = StringToInt(Splitter[1]);
        
color[2] = StringToInt(Splitter[2]);
        
result true;
    }
    else
    {
        
color[0] = defvalue;
        
color[1] = defvalue;
        
color[2] = defvalue;
    }
    return 
result;
}

stock bool:String_IsNumeric(const String:str[])
{    
    new 
x=0;
    new 
numbersFound=0;

    if (
str[x] == '+' || str[x] == '-')
        
x++;

    while (
str[x] != '\0')
    {
        if (
IsCharNumeric(str[x]))
            
numbersFound++;
        else
            return 
false;
        
x++;
    }
    
    if (!
numbersFound)
        return 
false;
    
    return 
true;

Maybe something is wrong in "PlantMine" ?
__________________
Elitcky is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 05-22-2020 , 18:22   Re: How to set Physics Properties on custom model ?
Reply With Quote #17

I seriously think it needs to be something with the plugin, idk if its outdated or what, can u check in your server if this plugin https://forums.alliedmods.net/showthread.php?t=260183 actually works for you ? just upload the tplug model and the version 1.5 which is in the download section and change in the code

SetEntProp(ent, Prop_Data, "m_CollisionGroup", 11);
to
SetEntProp(ent, Prop_Data, "m_CollisionGroup", 5);

If the physics are created in your server, maybe something is interfering with physics in my server :/


EDIT: LOOKING FOR SOMETHING TO DEBUG THE MODEL, NOW I SEE MAYBE THIS IS THE PROBLEM ?

https://prnt.sc/sm36eo

Could maybe that be the problem ? is that 3d model error or plugin angles error ?

EDIT2: SERVERS NEEDED THE NEW OPTIONAL SCRDS UPDATE 1107, THAT IS WHY MODELS WERE NOT WORKING. FIXED
__________________

Last edited by Elitcky; 05-23-2020 at 01:10.
Elitcky is offline
ESK0
BANNED
Join Date: May 2014
Location: Czech Republic
Old 05-25-2020 , 02:05   Re: How to set Physics Properties on custom model ?
Reply With Quote #18

Check your phys model in model viewer in CSGO SDK
ESK0 is offline
Elitcky
AlliedModders Donor
Join Date: Jun 2016
Location: Antofagasta, Chile
Old 05-25-2020 , 12:28   Re: How to set Physics Properties on custom model ?
Reply With Quote #19

Quote:
Originally Posted by ESK0 View Post
Check your phys model in model viewer in CSGO SDK
Quote:
EDIT2: SERVERS NEEDED THE NEW OPTIONAL SCRDS UPDATE 1107, THAT IS WHY MODELS WERE NOT WORKING. FIXED
All was fine
__________________
Elitcky is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:59.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode