Post by ZinoZack47 on Jul 13, 2018 11:35:59 GMT
First What are d_models?
d_models are look simular to w_models but they are bigger, they float in the air and keep spinning until someone comes to take them.
When can I use them?
For example you can make them spawn randomly on the map or above other objects like supplyboxes and giftboxes, or simply after killing a certain enemy like nemesis, assassin...
So How to use them?
Here is a code I made which explains how to make a d_model after killing nemesis, in this example we will use the red dragon cannon d_model
ScreenShot
The Model used in this example
Must be putted in models/z47_cannonex/
d_cannonex.mdl (116.55 KB)
Other d_models I imported and fixed from cso
It contains:
-AK47 Paladin
-M4A1 Dark Knight
-STUN RIFLE IN CASE YOU USE RAHEEM'S STUN RIFLE
-THE DUAL BERETTA GUNSLINGER
-THE M3 BLACK DRAGON
-THE GOLDEN RED DRAGON CANNON
d_models collection fixed by ZinoZack47.zip (406.12 KB)
d_models are look simular to w_models but they are bigger, they float in the air and keep spinning until someone comes to take them.
When can I use them?
For example you can make them spawn randomly on the map or above other objects like supplyboxes and giftboxes, or simply after killing a certain enemy like nemesis, assassin...
So How to use them?
Here is a code I made which explains how to make a d_model after killing nemesis, in this example we will use the red dragon cannon d_model
#include <amxmodx>
#include <fakemeta> //We could use engine instead but I prefer fakemeta
#include <hamsandwich>
#include <zombieplague>
//Plugin Info
#define PLUGIN "d_model Tutorial"
#define VERSION "1.0"
#define AUTHOR "ZinoZack47"
native z47_give_rdc(id) //this is the native we will use to give the weapon
new const RDC_D_MODEL[64] = "models/z47_cannonex/d_cannonex.mdl" //The d_model that we will use in this tutorial
#define D_MODEL_CLASSNAME "rdc_d_model" //In order to name our d_model entity
//it works like this in case of 1.0 the d_model will spin normally 2.0 it will spin twice faster and so on
#define Speed 3.0 // I looks very cool when adjusted to 3.0
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR) //Registering plugin info
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled") //Resgistring a ham to call the Death Event forward
register_forward(FM_Think, "fw_Think") //You can use engine instead to manage the d_ model entity's think
register_forward(FM_Touch, "fw_Touch") //You can use engine instead to manage the d_ model entity's touch
}
public plugin_precache()
{
precache_model(RDC_D_MODEL) //Precache the d_model from earlier
}
public fw_PlayerKilled(Victim)
{
if(!zp_get_user_nemesis(Victim)) //make sure that the victim is a nemesis just for an example
return HAM_IGNORED //The Check was positive so stop here
make_d_model(Victim) //Now let us call this function in order to make a d_model
return HAM_IGNORED //Just to prevent the annoying warning
}
public make_d_model(Victim)
{
new Float:flOrigin[3] //We will use this to store the Victim's coordinantes
pev(Victim, pev_origin, flOrigin) // Now Get the Victim's coordinantes
new d_model = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target")) //create our d_ model's entity
if(!pev_valid(d_model)) //Just to make sure that the entity still exists
return
flOrigin[2] += 5.0 //Just a litlle up
set_pev(d_model, pev_classname, D_MODEL_CLASSNAME) //when a baby is born it should be given a name
engfunc(EngFunc_SetModel, d_model, RDC_D_MODEL) //Now we have to set its model but this isnt over yet
set_pev(d_model, pev_solid, SOLID_SLIDEBOX) //Make it a bit solid and soft so we can touch it
//The Game can't know the original size of the d_model so we will have to set it for it
new Float:mins[3] = { -10.0, -10.0, -20.0 } //for mins I think it works like this backwards, left, down
new Float:maxs[3] = { 10.0, 10.0, 40.0 } //for maxs I think it works like this forward, right, up
engfunc(EngFunc_SetSize, d_model, mins, maxs) //Adjust its size
engfunc(EngFunc_SetOrigin, d_model, flOrigin) //Now we will make it appear above the corpse :)
engfunc(EngFunc_DropToFloor, d_model) //In Case The Victim is in the air go down a bit (This Function won't literally stuck it to the floor)
spin_d_model(d_model, Speed) //spind our d_model
}
public fw_Think(iEnt)
{
if(!pev_valid(iEnt)) //Make sure this entity exists
return FMRES_IGNORED //Nope it doesn't exist, stop here
if(fm_is_ent_classname(iEnt, D_MODEL_CLASSNAME)) //Make sure that our entity is the d_model from earlier
spin_d_model(iEnt, Speed)
return FMRES_IGNORED //Just to prevent unnecessary wanrnings
}
public fw_Touch(iPlayer, iTouchedEnt)
{
if(!pev_valid(iTouchedEnt)) //Make sure that this entity still exists
return FMRES_IGNORED //Nope it doesn't exist anymore, stop here
if(!fm_is_ent_classname(iTouchedEnt, D_MODEL_CLASSNAME)) //Make sure that the entity we touched is the d_model from earlier
return FMRES_IGNORED //the check was positve this isn't the entity that we are looking for, stop here.
if(!is_user_alive(iPlayer) || zp_get_user_zombie(iPlayer)) //Make sure that the player is alive and is not a zombie and he isn't any other entity
return FMRES_IGNORED //This dude isn't alive or maybe it is just an object (Note: I am not comparing dead people to objects)
z47_give_rdc(iPlayer) //Give this guy a weapon to protect himself
set_pev(iTouchedEnt, pev_flags, FL_KILLME) //The entity must be killed, it can't die if it isn't killed...
engfunc(EngFunc_RemoveEntity, iTouchedEnt) //Finally remove the d_model
return FMRES_IGNORED //We are clear now
}
//Just a simple stock I made to make the d_model spin properly
//d_model stands of our entity, and the speed stands for the rotation speed
stock spin_d_model(d_model, Float:speed)
{
if(!pev_valid(d_model)) // Just a usual bs
return
set_pev(d_model, pev_animtime, get_gametime()) //make it animate as long as possible
set_pev(d_model, pev_framerate, speed) //Adjust the framerate it doesn't matter anyway
set_pev(d_model, pev_sequence, 1) //Play the first sequence which is the idle sequence
//Make our entity think so we can make it spin over and over again since in case of normal speed the full spin takes 6 seconds after that we do the maths
set_pev(d_model, pev_nextthink, get_gametime() + 6.0 / speed)
}
//Just a simple stock that can be found in fakemeta_util
stock bool:fm_is_ent_classname(index, const classname[])
{
if (!pev_valid(index))
return false;
new class[32];
pev(index, pev_classname, class, sizeof class - 1);
if (equal(class, classname))
return true;
return false;
}
ScreenShot
The Model used in this example
Must be putted in models/z47_cannonex/
d_cannonex.mdl (116.55 KB)
Other d_models I imported and fixed from cso
It contains:
-AK47 Paladin
-M4A1 Dark Knight
-STUN RIFLE IN CASE YOU USE RAHEEM'S STUN RIFLE
-THE DUAL BERETTA GUNSLINGER
-THE M3 BLACK DRAGON
-THE GOLDEN RED DRAGON CANNON
d_models collection fixed by ZinoZack47.zip (406.12 KB)