Raised This Month: $ Target: $400
 0% 

How do I do things with Entities?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-25-2005 , 15:59  
Reply With Quote #3

Quote:
Originally Posted by Zenith77
Plz tell us the EXACT errors...not just where there located..for all we know it could be loose indention :/
He told us the warnings, tag mismatch.

This should get rid of the tag mismatches, but I don't know if the server will still crash or not:
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]) {     new Float:fOrigin[3], Float:fVelocity[3]     IVecFVec(origin, fOrigin)     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, fOrigin)     //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"), fVelocity)     FVecIVec(fVelocity, velocity)     //This will set the entity in motion     entity_set_vector(NewEnt, EV_VEC_velocity, fVelocity) } //----------------------------------------------------------------------------------------- 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], Float:fAimvec[3]  //This is the position where the disk collides         get_user_origin(ptd, aimvec, 0)     IVecFVec(aimvec, fAimvec)         RadiusDamage(fAimvec, 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 } //-----------------------------------------------------------------------------------------
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
 



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 14:21.


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