Raised This Month: $ Target: $400
 0% 

Need help with scripting my hero


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
martop5hng
Junior Member
Join Date: Mar 2014
Old 03-08-2014 , 10:14   Need help with scripting my hero
Reply With Quote #1

Ok so im newbie here and i would be happy if someone help.
so first i read this tut - > https://forums.alliedmods.net/showthread.php?t=120051
i just want to make new hero but im sure where i did wrong (i can't compile it too)..this is my broken code:
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include<superheromod>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"


public plugin_init() {
	register_plugin(PLUGIN, VERSION, AUTHOR)
	
	// Add your code here...
}
#include <superheromod>

new gHeroID
new gHeroName[] = "super" //creates a string varr to hold the hero name
new bool:gHasSuperPower[SH_MAXSLOTS+1] //creates a varr with an aray, with 1 slot per player

public plugin_init()
{
    //This registers the plugin with amx mod x. This is what is shown when you type amx_plugins in console
    register_plugin("SUPERHERO super", "1.0", "Strygwyr")
    
    //now we register the cvars
    //you can make the "pcvarLevel" to what ever you want, but make sure it matches this each time you use it
    new pcvarLevel = register_cvar("super_level", "34") //this is what level the hero should be avalible at
    
    //This is what creates the hero remember the pcvarLevel is pointing at the level for the hero
    gHeroID = sh_create_hero(gHeroName, pcvarLevel)
    //This is setting the hero info. It pretty much explains itself
    sh_set_hero_info(gHeroID, "V", "V For Vendetta")
    
    //if you were used to the old method you will notice that there is no need to register the init anymore therefor nothing more is required
}

public sh_hero_init(id, heroID, mode)
{
    //if no power return
    if (gHeroID != heroID) return
    
    //This is what runs when someone drops or picks the hero
    switch(mode)
    {
        //if the hero is added
        case SH_HERO_ADD:
        {
            //it is true that client has the hero
            gHasSuperPower[id] = true
        }
        //if the hero is dropped
        case SH_HERO_DROP:
        {
            //it is false that the client has the hero
            gHasSuperPower[id] = false
        }
    }
}  
public plugin_init()
{
    //the code you already made should be here
    //Be sure to set the cvars as the first thing in your plugin
    //you now add a cvar for armor:
    new pcvarArmor = register_cvar("super_armor", "4500")
    
    //and now you set the hero power. Remember this should be after you create the hero with sh_create_hero!
    //with this native I set the armor accordingly to the cvar super_armor. The "0" before pcvarArmor is the health.
    //and since we did not add any health power we write 0
    sh_set_hero_hpap(gheroID, 0, pcvarArmor)    
}  
{
    //the code you already made should be here
    //Be sure to set the cvars as the first thing in your plugin
    //you now add a cvar for speed:
    new pcvarSpeed = register_cvar("super_speed", "4500")
    
    //and now you set the hero power. Remember this should be after you create the hero with sh_create_hero!
    //with this native I set the hero speed accordingly to the speed cvar
    sh_set_hero_speed(gHeroID, pcvarSpeed)
    //this works just like the gravity native so I wont explain this just write it
    //sh_set_hero_speed(gHeroID, pcvarSpeed, {CSW_M4A1}, 1)
}  
{
    //the code you already made should be here
    //Be sure to set the cvars as the first thing in your plugin
    //you now add a cvar for multiplier:
    new pcvarMult = register_cvar("super_mult", "5")
    
    //and now you set the hero power. Remember this should be after you create the hero with sh_create_hero!
    //with this native I set the hero multiplier accordingly to the multiplier cvar
    sh_set_hero_dmgmult(gHeroID, pcvarMult, CSW_M4A1)
}  
new const gSuperPlayer[] = "models/player/super/super.mdl"

public sh_hero_init(id, heroID, mode)
{
    //you should now know what should be going here
    
    //now we actually have to use the switch (mode) part in the init.
    switch (mode)
    {
        //remember what this does?
        case SH_HERO_ADD:
        {
            //Remember what this does?
            gHasSuperPower[id] = true
            //this is what you should add
            //this means that we are going to set the model in the super_morph and not here since that will create allot of confusion
            //remember this is only if the user picks the hero this runs
            super_morph(id)
        }
        //remember what this does?
        case SH_HERO_DROP:
        {
            //remember what this does?
            gHasSuperPower[id] = false
            //this is also new.
            //If the client has the hero and then drops it, we want to take his playermodel from him so we go to super_unmorph and do that there
            //same here this only runs when the user drops the hero
            super_unmorph(id)
        }
    }
}

//we need to precache the playermodel before we can use it (this means the client has to download it or he will not be able to see it
public plugin_precache()
{
    //remember to use the function precache_model for models
    precache_model(gSuperPlayer) //I already told where the playermodel is located, so all I have to do is just write the global variable
}

//this runs each time a player is spawning but you probably figured that one out by the name
public sh_client_spawn(id)
{
    //first we check if the user has the hero or not
    if (gHasSuperPower[id])
    {
        //then we can go and set the playermodel
        super_morph(id)
    }
}

//it is here where we set the playermodel for the player
super_morph(id)
{
    //remember that after the id you have to write the filename witch has to be the model. In this case super.mdl is our model. Do not write .mdl after the filename
    cs_set_user_model(id, "super")
}

//it is here where we take off the playermodel if a user dropped the hero
super_unmorph(id)
{
    //yeah, we just reset the playermodel to the original one
    cs_reset_user_model(id)
}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ ansicpg1251\\ deff0\\ deflang1026{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ f0\\ fs16 \n\\ par }
*/
martop5hng 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 05:13.


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