Yeah don't worry i remember that post, that's alright though i'll just google it hopefully giving me a description.
10 min. later: Okay now i know that ptr is the toucher and ptd is the touched!!! Nice sweet!
P.S. I could get help from the amxmod forum right?
Next day: Alright so here's my coding for my hero so far...I suppose I could also add hp armor, gravity and all those stuff a lil later. But for some reason the server keeps crashing, getting four warnings about tag mismatch exceptions at lines 142, 148, 151, and 175. I know I probably won't get help because of where I come from, but I just wanted show anyone that is reading this forum of what I have done so far.
Code:
//Cell
#include <amxmod.inc>
#include <superheromod.inc>
#include <engine.inc>
#include <Vexd_Utilities.inc>
#include <amxmisc.inc>
#include <xtrafun.inc>
new gHeroName[] = "Cell"
new bool:g_hasCellPowers[SH_MAXSLOTS+1]
new diskTimer[SH_MAXSLOTS+1]
//This variable will represent the disk being made.
new NewEnt
//------------------------------------------------------------------------------------
public plugin_init()
{
register_plugin("SUPERHERO Cell", "1.0", "Gorlag/Batman")
//THE CVARS
register_cvar("cell_level", "4")
register_cvar("cell_damage", "75")
register_cvar("cell_radius", "50")
register_cvar("cell_cooldown", "50")
register_cvar("cell_diskspeed", "750")
register_cvar("cell_disklife", "5")
register_cvar("cell_blastdecal", "1")
//THIS LINE MAKES THE HERO SELECTABLE
shCreateHero(gHeroName, "Energy Disk", "Unleash an energy disk and take control of where it flies!", true, "cell_level")
//INITIAL ACTIONS
register_srvcmd("cell_init", "cell_init")
shRegHeroInit(gHeroName, "cell_init")
//KEY DOWN COMMAND
register_srvcmd("cell_kd", "cell_kd")
shRegKeyDown(gHeroName, "cell_kd")
//SPAWNING EVENT
register_event("ResetHUD", "newSpawn", "b")
//SET THE LIFE OF THE DISK
set_task(1.0, "cell_disklife", 0, "", 0, "b")
for(new id = 1; id <= SH_MAXSLOTS; id++)
diskTimer[id] = -1
}
//--------------------------------------------------------------------------------------
public plugin_precache()
{
precache_model("models/shmod/friezadisc.mdl")
//boom = precache_model("sprites/zerogxplode.spr")
}
//---------------------------------------------------------------------------------------
public cell_init()
{
new temp[6] //To store temporary information
//First Argument is the id of the player
read_argv(1,temp,5) //Converts the string to a number
new id = str_to_num(temp)
//Second Argument is either 0 or 1 depending on whether the person has the hero or not
read_argv(2,temp,5)
new hasPowers = str_to_num(temp) //Makes the string into a number
g_hasCellPowers[id] = (hasPowers != 0)
if(!hasPowers && diskTimer[id] > 0){
diskTimer[id] = -1
remove_entity(NewEnt)
}
}
//---------------------------------------------------------------------------------------
public cell_kd()
{
if(!hasRoundStarted()) return
new temp[6]
//Get the id of the player
read_argv(1,temp,5)
new id = str_to_num(temp)
if(!is_user_alive(id) || !g_hasCellPowers[id] || gPlayerUltimateUsed[id]) return
if(gPlayerUltimateUsed[id]){
playSoundDenySelect(id)
return
}
diskTimer[id] = get_cvar_num("cell_disklife")
fire_disk(id)
if(get_cvar_float("cell_cooldown") > 0.0)
ultimateTimer(id, get_cvar_float("cell_cooldown"))
}
//----------------------------------------------------------------------------------------
public newSpawn(id)
{
gPlayerUltimateUsed[id] = false //Makes you able to use power again
}
//----------------------------------------------------------------------------------------
public cell_disklife(){
for(new id = 1; id <= SH_MAXSLOTS; id++){
if(g_hasCellPowers[id] && is_user_alive(id)){
if(diskTimer[id] > 0){
diskTimer[id]--
}
else{
remove_entity(NewEnt)
diskTimer[id]--
}
}
}
}
//----------------------------------------------------------------------------------------
public fire_disk(id)
{
//Makes an array of origin in the (x,y,z) coordinate system.
new origin[3]
//Makes an array of velocity, specifically in the (x,y,z) coordinate system
new velocity[3]
get_user_origin(id, origin, 0)
create_disk(id, origin, velocity)
}
//----------------------------------------------------------------------------------------
public create_disk(id, origin[3], velocity[3])
{
NewEnt = CreateEntity("info_target") //Makes an object
entity_set_string(NewEnt, EV_SZ_classname, "cell_disk_ent")
//This tells what the object will look like
ENT_SetModel(NewEnt, "models/shmod/friezadisc.mdl")
//This will set the origin of the entity
entity_set_vector(NewEnt, EV_VEC_origin, origin)
//This will set the movetype of the entity
entity_set_int(NewEnt,EV_INT_movetype, MOVETYPE_FLY)
//This will set the velocity of the entity
velocity_by_aim(NewEnt, get_cvar_num("cell_maxspeed"), velocity)
//This will set the entity in motion
entity_set_vector(NewEnt, EV_VEC_velocity, velocity)
}
//-----------------------------------------------------------------------------------------
public pfn_touch(ptr, ptd) //ptr is the toucher, and ptd is the touched!
{
//Checks to make sure that the entity is valid!
if(!is_valid_ent(ptr) || !is_valid_ent(ptd))
return PLUGIN_CONTINUE
//Checks to make sure that the victim is alive and connected to the server!
if(!is_user_alive(ptd) || !is_user_connected(ptd))
return PLUGIN_CONTINUE
//Now to deal the damage to the victim (touched) and remove the toucher (the disk)
new resulting_string[41] //Makes a new empty string that will store 40 characters.
//Allows you to retrieve the entity of the toucher, in this case the disk.
entity_get_string(ptr, EV_SZ_classname, resulting_string, 40)
//Now because the data above is a string, the "==" would not work, when comparing.
//Instead I will use the equal method.
//Makes sure that the toucher entity is the disk.
if(equal(resulting_string, "cell_disk_ent")){
new aimvec[3] //This is the position where the disk collides
get_user_origin(ptd, aimvec, 0)
RadiusDamage(aimvec, get_cvar_num("cell_damage"), get_cvar_num("cell_radius"))
remove_entity(ptr) //Makes sure the entity is removed after contact.
}
else{
remove_entity(ptr)
}
return PLUGIN_CONTINUE
}
//-----------------------------------------------------------------------------------------
I'll add some animation to it when it collides against another object a lil later. And I'll make the disk follow wherever you aim a lil later as well.