Raised This Month: $ Target: $400
 0% 

Solved random model for parachute


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
itoxicreal
Senior Member
Join Date: Jun 2018
Old 01-07-2022 , 03:49   random model for parachute
#1

Hey so in my parachute model there are submodels, can someone edit the sma so it can use diff parachute models instead of 1 each time someone uses it

Last edited by asherkin; 01-08-2022 at 12:12. Reason: Restore to previous version.
itoxicreal is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-07-2022 , 07:13   Re: random model for parachute
#2

Code:
set_pev(para_ent[id], pev_body, random(number_of_submodels));

Do that after applying the model. Write the number of submodels in the .mdl file inside the random() function.
__________________

Last edited by OciXCrom; 01-07-2022 at 07:13.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
itoxicreal
Senior Member
Join Date: Jun 2018
Old 01-07-2022 , 14:12   Re: random model for parachute
#3

error 088: number of arguments does not match definition
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

new const paramodel[] = "models/parachutes.mdl"

new bool:has_parachute[33], para_ent[33];

enum pcvar
{
    
humans 1,
    
survivors,
    
zombies,
    
nemesis,
    
fallspeed,
    
detach
}

new 
pcvars[pcvar]

public 
plugin_init()
{
    
register_plugin("[ZP] Sub-Plugin: Parachute""1.1""Random1, 93()|29!/<")
    
pcvars[humans] =    register_cvar("zp_parachute_humans""1")
    
pcvars[survivors] =    register_cvar("zp_parachute_survivors""1")
    
pcvars[zombies] =     register_cvar("zp_parachute_zombies""1")
    
pcvars[nemesis] =     register_cvar("zp_parachute_nemesis""1")
    
pcvars[fallspeed] =    register_cvar("zp_parachute_fallspeed""75")
    
pcvars[detach] =    register_cvar("zp_parachute_detach""1")
    
    
register_forward(FM_PlayerPreThink"fw_PreThink")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
}

public 
plugin_precache()
    
engfunc(EngFunc_PrecacheModelparamodel)

public 
client_connect(id)
    
parachute_reset(id)

public 
client_disconnect(id)
    
parachute_reset(id)

parachute_reset(idkeep 0)
{
    if(
para_ent[id] > 0
        if (
pev_valid(para_ent[id])) 
            
engfunc(EngFunc_RemoveEntitypara_ent[id]);
            
set_pev(para_ent[id], pev_bodyrandom(010))//Line 50
    
    
if (!keep)
        
has_parachute[id] = false;
    
    
para_ent[id] = 0
    
    
if (!has_parachute[id])
        
has_parachute[id] = true;
}

// Ham Player Killed Forward
public fw_PlayerKilled(victimattackershouldgib)
{
    
engfunc(EngFunc_RemoveEntitypara_ent[victim]);
    
para_ent[victim] = 0;
}

public 
fw_PreThink(id)
{
    
//Parachute model animation information
    //0 - deploy - 84 frames
    //1 - idle - 39 frames
    //2 - detach - 29 frames
    
    
if (!is_user_alive(id) || !has_parachute[id]
    || !
get_pcvar_num(pcvars[humans]) && !zp_get_user_zombie(id)
    && !
zp_get_user_survivor(id) || !get_pcvar_num(pcvars[survivors])
    && 
zp_get_user_survivor(id)    || !get_pcvar_num(pcvars[zombies])
    && 
zp_get_user_zombie(id) && !zp_get_user_nemesis(id)
    || !
get_pcvar_num(pcvars[nemesis]) && zp_get_user_nemesis(id))
        return;
    
    new 
Float:fallingspeed get_pcvar_float(pcvars[fallspeed]) * -1.0;
    new 
Float:frame;
    
    new 
button pev(idpev_button);
    new 
oldbutton pev(idpev_oldbuttons);
    new 
flags pev(idpev_flags);
    
    if (
para_ent[id] > && (flags FL_ONGROUND))
    {
        if (
get_pcvar_num(pcvars[detach]))
        {
            if (
pev(para_ent[id],pev_sequence) != 2)
            {
                
set_pev(para_ent[id], pev_sequence2);
                
set_pev(para_ent[id], pev_gaitsequence1);
                
set_pev(para_ent[id], pev_frame0.0);
                
set_pev(para_ent[id], pev_fuser10.0);
                
set_pev(para_ent[id], pev_animtime0.0);
                return;
            }
            
            
pev(para_ent[id],pev_fuser1frame);
            
frame += 2.0;
            
set_pev(para_ent[id],pev_fuser1,frame);
            
set_pev(para_ent[id],pev_frame,frame);

            if (
frame 254.0)
            {
                
engfunc(EngFunc_RemoveEntitypara_ent[id]);
                
para_ent[id] = 0;
            }
        }
        else
        {
            
engfunc(EngFunc_RemoveEntitypara_ent[id]);
            
para_ent[id] = 0;
        }
        
        return;
    }

    if (
button IN_USE)
    {

        new 
Float:velocity[3];
        
pev(idpev_velocityvelocity);

        if (
velocity[2] < 0.0)
        {
            if(
para_ent[id] <= 0)
            {
                
para_ent[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                
                if(
para_ent[id] > 0)
                {
                    
set_pev(para_ent[id],pev_classname,"parachute");
                    
set_pev(para_ent[id], pev_aimentid)
                    
set_pev(para_ent[id], pev_ownerid);
                    
set_pev(para_ent[id], pev_movetypeMOVETYPE_FOLLOW);
                    
engfunc(EngFunc_SetModelpara_ent[id], paramodel);
                    
set_pev(para_ent[id], pev_bodyrandom_num(,10))
                    
set_pev(para_ent[id], pev_sequence0);
                    
set_pev(para_ent[id], pev_gaitsequence1);
                    
set_pev(para_ent[id], pev_frame0.0);
                    
set_pev(para_ent[id], pev_fuser10.0);
                }
            }
            
            if (
para_ent[id] > 0)
            {
                
set_pev(idpev_sequence3)
                
set_pev(idpev_gaitsequence1)
                
set_pev(idpev_frame1.0)
                
set_pev(idpev_framerate1.0)

                
velocity[2] = (velocity[2] + 40.0 fallingspeed) ? velocity[2] + 40.0 fallingspeed
                set_pev
(idpev_velocityvelocity)

                if (
pev(para_ent[id],pev_sequence) == 0)
                {

                    
pev(para_ent[id],pev_fuser1frame);
                    
frame += 1.0;
                    
set_pev(para_ent[id],pev_fuser1,frame);
                    
set_pev(para_ent[id],pev_frame,frame);

                    if (
frame 100.0)
                    {
                        
set_pev(para_ent[id], pev_animtime0.0);
                        
set_pev(para_ent[id], pev_framerate0.4);
                        
set_pev(para_ent[id], pev_sequence1);
                        
set_pev(para_ent[id], pev_gaitsequence1);
                        
set_pev(para_ent[id], pev_frame0.0);
                        
set_pev(para_ent[id], pev_fuser10.0);
                    }
                }
            }
        }
        else if (
para_ent[id] > 0)
        {
            
engfunc(EngFunc_RemoveEntitypara_ent[id]);
            
para_ent[id] = 0;
        }
    }
    else if ((
oldbutton IN_USE) && para_ent[id] > 0)
    {
        
engfunc(EngFunc_RemoveEntitypara_ent[id]);
        
para_ent[id] = 0;
    }
}

public 
zp_user_infected_post(idnemesis)
{
    if (!
nemesis && get_pcvar_num(pcvars[zombies])
    || 
nemesis && get_pcvar_num(pcvars[nemesis]))
        return;
    
    
engfunc(EngFunc_RemoveEntitypara_ent[id]);
    
para_ent[id] = 0;
}

public 
zp_user_human_post(idsurvivor)
{
    if (!
survivor && get_pcvar_num(pcvars[humans])
    || 
survivor    && get_pcvar_num(pcvars[survivors]))
        return;
    
    
engfunc(EngFunc_RemoveEntitypara_ent[id]);
    
para_ent[id] = 0;


Last edited by itoxicreal; 01-07-2022 at 14:13.
itoxicreal is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-07-2022 , 14:31   Re: random model for parachute
#4

random() has only 1 parameter as I clearly showed in my example.

If you want 2 parameters, you need to use random_num(). Although if you're starting from index 0, there's no point in doing that as random() already does that.

Also also, why are you applying a submodel after removing the parachute?
__________________

Last edited by OciXCrom; 01-07-2022 at 14:32.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
itoxicreal
Senior Member
Join Date: Jun 2018
Old 01-07-2022 , 14:41   Re: random model for parachute
#5

I dont know where to put it..
can you put it in the right place for me please!
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <zombieplague>

new const paramodel[] = "models/parachutes.mdl"

new bool:has_parachute[33], para_ent[33];

enum pcvar
{
    
humans 1,
    
survivors,
    
zombies,
    
nemesis,
    
fallspeed,
    
detach
}

new 
pcvars[pcvar]

public 
plugin_init()
{
    
register_plugin("[ZP] Sub-Plugin: Parachute""1.1""Random1, 93()|29!/<")
    
pcvars[humans] =    register_cvar("zp_parachute_humans""1")
    
pcvars[survivors] =    register_cvar("zp_parachute_survivors""1")
    
pcvars[zombies] =     register_cvar("zp_parachute_zombies""1")
    
pcvars[nemesis] =     register_cvar("zp_parachute_nemesis""1")
    
pcvars[fallspeed] =    register_cvar("zp_parachute_fallspeed""75")
    
pcvars[detach] =    register_cvar("zp_parachute_detach""1")
    
    
register_forward(FM_PlayerPreThink"fw_PreThink")
    
RegisterHam(Ham_Killed"player""fw_PlayerKilled")
}

public 
plugin_precache()
    
engfunc(EngFunc_PrecacheModelparamodel)

public 
client_connect(id)
    
parachute_reset(id)

public 
client_disconnect(id)
    
parachute_reset(id)

parachute_reset(idkeep 0)
{
    if(
para_ent[id] > 0
        if (
pev_valid(para_ent[id])) 
            
engfunc(EngFunc_RemoveEntitypara_ent[id]);
            
set_pev(para_ent[id], pev_bodyrandom_num(010))
    
    if (!
keep)
        
has_parachute[id] = false;
    
    
para_ent[id] = 0
    
    
if (!has_parachute[id])
        
has_parachute[id] = true;
}

// Ham Player Killed Forward
public fw_PlayerKilled(victimattackershouldgib)
{
    
engfunc(EngFunc_RemoveEntitypara_ent[victim]);
    
para_ent[victim] = 0;
}

public 
fw_PreThink(id)
{
    
//Parachute model animation information
    //0 - deploy - 84 frames
    //1 - idle - 39 frames
    //2 - detach - 29 frames
    
    
if (!is_user_alive(id) || !has_parachute[id]
    || !
get_pcvar_num(pcvars[humans]) && !zp_get_user_zombie(id)
    && !
zp_get_user_survivor(id) || !get_pcvar_num(pcvars[survivors])
    && 
zp_get_user_survivor(id)    || !get_pcvar_num(pcvars[zombies])
    && 
zp_get_user_zombie(id) && !zp_get_user_nemesis(id)
    || !
get_pcvar_num(pcvars[nemesis]) && zp_get_user_nemesis(id))
        return;
    
    new 
Float:fallingspeed get_pcvar_float(pcvars[fallspeed]) * -1.0;
    new 
Float:frame;
    
    new 
button pev(idpev_button);
    new 
oldbutton pev(idpev_oldbuttons);
    new 
flags pev(idpev_flags);
    
    if (
para_ent[id] > && (flags FL_ONGROUND))
    {
        if (
get_pcvar_num(pcvars[detach]))
        {
            if (
pev(para_ent[id],pev_sequence) != 2)
            {
                
set_pev(para_ent[id], pev_sequence2);
                
set_pev(para_ent[id], pev_gaitsequence1);
                
set_pev(para_ent[id], pev_frame0.0);
                
set_pev(para_ent[id], pev_fuser10.0);
                
set_pev(para_ent[id], pev_animtime0.0);
                return;
            }
            
            
pev(para_ent[id],pev_fuser1frame);
            
frame += 2.0;
            
set_pev(para_ent[id],pev_fuser1,frame);
            
set_pev(para_ent[id],pev_frame,frame);

            if (
frame 254.0)
            {
                
engfunc(EngFunc_RemoveEntitypara_ent[id]);
                
para_ent[id] = 0;
            }
        }
        else
        {
            
engfunc(EngFunc_RemoveEntitypara_ent[id]);
            
para_ent[id] = 0;
        }
        
        return;
    }

    if (
button IN_USE)
    {

        new 
Float:velocity[3];
        
pev(idpev_velocityvelocity);

        if (
velocity[2] < 0.0)
        {
            if(
para_ent[id] <= 0)
            {
                
para_ent[id] = engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"));
                
                if(
para_ent[id] > 0)
                {
                    
set_pev(para_ent[id],pev_classname,"parachute");
                    
set_pev(para_ent[id], pev_aimentid)
                    
set_pev(para_ent[id], pev_ownerid);
                    
set_pev(para_ent[id], pev_movetypeMOVETYPE_FOLLOW);
                    
engfunc(EngFunc_SetModelpara_ent[id], paramodel);
                    
set_pev(para_ent[id], pev_bodyrandom_num(,10))
                    
set_pev(para_ent[id], pev_sequence0);
                    
set_pev(para_ent[id], pev_gaitsequence1);
                    
set_pev(para_ent[id], pev_frame0.0);
                    
set_pev(para_ent[id], pev_fuser10.0);
                }
            }
            
            if (
para_ent[id] > 0)
            {
                
set_pev(idpev_sequence3)
                
set_pev(idpev_gaitsequence1)
                
set_pev(idpev_frame1.0)
                
set_pev(idpev_framerate1.0)

                
velocity[2] = (velocity[2] + 40.0 fallingspeed) ? velocity[2] + 40.0 fallingspeed
                set_pev
(idpev_velocityvelocity)

                if (
pev(para_ent[id],pev_sequence) == 0)
                {

                    
pev(para_ent[id],pev_fuser1frame);
                    
frame += 1.0;
                    
set_pev(para_ent[id],pev_fuser1,frame);
                    
set_pev(para_ent[id],pev_frame,frame);

                    if (
frame 100.0)
                    {
                        
set_pev(para_ent[id], pev_animtime0.0);
                        
set_pev(para_ent[id], pev_framerate0.4);
                        
set_pev(para_ent[id], pev_sequence1);
                        
set_pev(para_ent[id], pev_gaitsequence1);
                        
set_pev(para_ent[id], pev_frame0.0);
                        
set_pev(para_ent[id], pev_fuser10.0);
                    }
                }
            }
        }
        else if (
para_ent[id] > 0)
        {
            
engfunc(EngFunc_RemoveEntitypara_ent[id]);
            
para_ent[id] = 0;
        }
    }
    else if ((
oldbutton IN_USE) && para_ent[id] > 0)
    {
        
engfunc(EngFunc_RemoveEntitypara_ent[id]);
        
para_ent[id] = 0;
    }
}

public 
zp_user_infected_post(idnemesis)
{
    if (!
nemesis && get_pcvar_num(pcvars[zombies])
    || 
nemesis && get_pcvar_num(pcvars[nemesis]))
        return;
    
    
engfunc(EngFunc_RemoveEntitypara_ent[id]);
    
para_ent[id] = 0;
}

public 
zp_user_human_post(idsurvivor)
{
    if (!
survivor && get_pcvar_num(pcvars[humans])
    || 
survivor    && get_pcvar_num(pcvars[survivors]))
        return;
    
    
engfunc(EngFunc_RemoveEntitypara_ent[id]);
    
para_ent[id] = 0;


Last edited by itoxicreal; 01-07-2022 at 14:41.
itoxicreal is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-07-2022 , 15:03   Re: random model for parachute
#6

Code:
engfunc(EngFunc_SetModel, para_ent[id], paramodel); set_pev(para_ent[id], pev_body, random_num(0 ,10))

You already put it where it's supposed to be, just do what I said in the other comment.
If you're not willing to try, use the requests section.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Closed Thread



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 11:27.


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