AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Skin shop just for Humans.. (https://forums.alliedmods.net/showthread.php?t=321186)

Myshu 01-28-2020 17:20

Skin shop just for Humans..
 
Hi.

Can somebody help me to do this plugin to work just for humans?

Code:

#pragma tabsize 0

#include <amxmodx>
#include <fvault>
#include <hamsandwich>
#include <zombieplague>

//modelele se pun in /models/player/nume_model/nume_model.mdl
new const Models[][] = {//numele la modele
        "Joker",
        "Billy",
        "SpecialForces",

        "Jason"
}

new model1[33],model2[33],model3[33],model4[33], model5[33]


#define NUME_SKIN_1 "Joker"
#define PRET_SKIN_1 2000

#define NUME_SKIN_2 "Billy"
#define PRET_SKIN_2 4000

#define NUME_SKIN_3 "SpecialForces"
#define PRET_SKIN_3 6000


#define NUME_SKIN_4 "Jason"
#define PRET_SKIN_4 8000




new const g_vault_name[] = "SkinShop";
new authid[33],data[128];


public plugin_init() {
          register_plugin("skin_zombie", "1.0", "Rainq & Levin")
        //register_clcmd("say","SayFC")
        //register_clcmd("say_team","SayFC")
       
        register_clcmd("say /buyskin","SkinSHOP")
        register_clcmd("say_team /buyskin","SkinSHOP")

        RegisterHam(Ham_Spawn, "player", "fwHamPlayerSpawnPost")
}

public plugin_precache()
{
        new szBuffer[ 128 ]
        for( new i; i < sizeof Models; i++ )
        {
                formatex( szBuffer, charsmax( szBuffer ), "models/player/%s/%s.mdl", Models[ i ], Models[ i ] )
                precache_model( szBuffer )
               
                // Support modelT.mdl files
                //V1
                replace(szBuffer, charsmax(szBuffer), ".mdl", "T.mdl")
                if(file_exists(szBuffer))        precache_model(szBuffer)
               
                //V2
                /*formatex(szBuffer, charsmax(szBuffer), "models/player/%s/%sT.mdl", Models[ i ], Models[ i ])
                if (file_exists(szBuffer)) precache_model(szBuffer)*/
        }
}

public client_putinserver(plr)        if( !is_user_hltv(plr) || !is_user_bot(plr) )        LoadExp(plr);

public fwHamPlayerSpawnPost(id)        set_task(1.0,"SM",id)

public SM(id)
{
        if(is_user_alive(id)&&!zp_get_user_zombie(id))
        {
                if(model1[id]==1&&model2[id]==1&&model3[id]==1&&
                model4[id]==1 && model5[id]==1)        zp_override_user_model( id, Models[ random_num( 0, charsmax( Models ) ) ] )
                       
                /*else if(model1[id]==1&&model2[id]==1)        zp_override_user_model( id, Models[ random_num( 0, 1 ) ] )
                else if(model2[id]==1&&model3[id]==1)        zp_override_user_model( id, Models[ random_num( 1, 2 ) ] )
                else if(model1[id]==1&&model3[id]==1)        zp_override_user_model( id, Models[ 0 ],1 )*/
                else if(model1[id]==1)        zp_override_user_model( id, Models[ 0 ] )
                else if(model2[id]==1)        zp_override_user_model( id, Models[ 1 ] )
                else if(model3[id]==1)        zp_override_user_model( id, Models[ 2 ] )
                       
                else if(model4[id]==1)        zp_override_user_model( id, Models[ 3 ] )
        }
}

public client_disconnect(plr)
{
        SaveExp(plr);
       
        model1[plr] = 0;
        model2[plr] = 0;
        model3[plr] = 0;
               
        model4[plr] = 0;
}

public zp_user_humanized_post(id, survivor)        SM(id)

public SayFC(id)
{
        new args[ 192 ]
        read_args( args, charsmax( args ) )
        remove_quotes( args )
       
        if( contain( args, "skin" ) != -1 )        client_print( id, print_chat, "Vrei sa ai propriu skin? Scrie /skin si poti cumpara propriu skin cu ammo!" )
}

public SkinSHOP(id)
{
        if(get_user_team(id)!=ZP_TEAM_HUMAN||zp_get_user_zombie(id))
        {
                //client_print(id,print_chat,"Trebuie sa fii om pentru a avea acces la Skinuri.")
                return PLUGIN_HANDLED
        }

        new form[512]
        new gMenu = menu_create( "ZM.CSPOWER.RO # Skin", "thisContent" );
       
        if(model1[id]!=1)        formatex(form,charsmax(form),"\r%s -\y %d\r ammo [NU DETII]",NUME_SKIN_1,PRET_SKIN_1)
        else        formatex(form,charsmax(form),"\r%s -\y [INVENTAR]",NUME_SKIN_1)
        menu_additem( gMenu, form, "1");
       
        if(model2[id]!=1)        formatex(form,charsmax(form),"\r%s -\y %d\r ammo [NU DETII]",NUME_SKIN_2,PRET_SKIN_2)
        else        formatex(form,charsmax(form),"\r%s -\y [INVENTAR]",NUME_SKIN_2)
        menu_additem( gMenu, form, "2");
       
        if(model3[id]!=1)        formatex(form,charsmax(form),"\r%s -\y %d\r ammo [NU DETII]",NUME_SKIN_3,PRET_SKIN_3)
        else        formatex(form,charsmax(form),"\r%s -\y [INVENTAR]",NUME_SKIN_3)
        menu_additem( gMenu, form, "3");
       
       
        if(model4[id]!=1)        formatex(form,charsmax(form),"\r%s -\y %d\r ammo [NU DETII]",NUME_SKIN_4,PRET_SKIN_4)
        else        formatex(form,charsmax(form),"\r%s -\y [INVENTAR]",NUME_SKIN_4)
        menu_additem( gMenu, form, "4");
       
        //menu_setprop( gMenu, MPROP_EXIT, MEXIT_ALL );
        menu_display( id, gMenu );
       
        return PLUGIN_CONTINUE
}

public thisContent( id, Menu, Item )
{
        if( Item < 0 )        return 0;
       
        if( !is_user_alive( id ) )
        {
                //client_print( id, print_chat, "Trebuie sa fii in viata pentru a-ti seta un Skin!" )
                return 0
        }
       
        new Key[ 3 ];
        new Access, CallBack;
        menu_item_getinfo( Menu, Item, Access, Key, 2, _, _, CallBack );
        new isKey = str_to_num( Key );
        switch( isKey )
        {
                case 1:
                {
                        if(model1[id]==1)
                        {
                                //client_print( id, print_chat, "Felicitari! Ti-ai setat %s.", NUME_SKIN_1 )
                       
                                zp_override_user_model(id,Models[ 0 ],1)
                       
                                return PLUGIN_HANDLED
                        }
                       
                        if( zp_get_user_ammo_packs( id ) < PRET_SKIN_1 )
                        {
                                //client_print( id, print_chat, "Nu ai suficient ammo." )
                                return PLUGIN_HANDLED
                        }
                       
                        zp_set_user_ammo_packs( id, zp_get_user_ammo_packs( id ) - PRET_SKIN_1 )
                        //client_print( id, print_chat, "Felicitari! Ai achizitionat %s pentru %d pachete ammo", NUME_SKIN_1, PRET_SKIN_1 )
                       
                        zp_override_user_model(id,Models[ 0 ],1)
                       
                        model1[ id ] = 1
                }
                case 2:
                {
                        if(model2[id]==1)
                        {
                                //client_print( id, print_chat, "Felicitari! Ti-ai setat %s.", NUME_SKIN_2 )
                       
                                zp_override_user_model(id,Models[ 1 ],1)
                       
                                return PLUGIN_HANDLED
                        }
                       
                        if( zp_get_user_ammo_packs( id ) < PRET_SKIN_2 )
                        {
                                //client_print( id, print_chat, "Nu ai suficient ammo." )
                                return PLUGIN_HANDLED
                        }
                       
                        zp_set_user_ammo_packs( id, zp_get_user_ammo_packs( id ) - PRET_SKIN_2 )
                        //client_print( id, print_chat, "Felicitari! Ai achizitionat %s pentru %d pachete ammo", NUME_SKIN_2, PRET_SKIN_2 )
                       
                        zp_override_user_model(id,Models[ 1 ],1)
                       
                        model2[ id ] = 1
                }
                case 3:
                {
                        if(model3[id]==1)
                        {
                                //client_print( id, print_chat, "Felicitari! Ti-ai setat %s.", NUME_SKIN_3 )
                       
                                zp_override_user_model(id,Models[ 2 ],1)
                       
                                return PLUGIN_HANDLED
                        }
                       
                        if( zp_get_user_ammo_packs( id ) < PRET_SKIN_3 )
                        {
                                //client_print( id, print_chat, "Nu ai suficient ammo." )
                                return PLUGIN_HANDLED
                        }
                       
                        zp_set_user_ammo_packs( id, zp_get_user_ammo_packs( id ) - PRET_SKIN_3 )
                        //client_print( id, print_chat, "Felicitari! Ai achizitionat %s pentru %d pachete ammo", NUME_SKIN_3, PRET_SKIN_3 )
                       
                        zp_override_user_model(id,Models[ 2 ],1)
                       
                        model3[ id ] = 1
                }
               
                case 4:
                {
                        if(model4[id]==1)
                        {
                                //client_print( id, print_chat, "Felicitari! Ti-ai setat %s.", NUME_SKIN_4 )
                       
                                zp_override_user_model(id,Models[ 3 ],1)
                       
                                return PLUGIN_HANDLED
                        }
                       
                        if( zp_get_user_ammo_packs( id ) < PRET_SKIN_4 )
                        {
                                //client_print( id, print_chat, "Nu ai suficient ammo." )
                                return PLUGIN_HANDLED
                        }
                       
                        zp_set_user_ammo_packs( id, zp_get_user_ammo_packs( id ) - PRET_SKIN_4 )
                        //client_print( id, print_chat, "Felicitari! Ai achizitionat %s pentru %d pachete ammo", NUME_SKIN_4, PRET_SKIN_4 )
                       
                        zp_override_user_model(id,Models[ 3 ],1)
                       
                        model4[ id ] = 1
                }
        }
       
        return 1;
}

LoadExp(plr)
{
    get_user_name(plr, authid, sizeof(authid) - 1);
   
    new szModel1[5],szModel2[5],szModel3[5], szModel4[5], szModel5[5]
    if( fvault_get_data(g_vault_name, authid, data, sizeof(data) - 1) )
    {
                parse(data,szModel1,charsmax(szModel1),szModel2,charsmax(szModel2),szModel3,charsmax(szModel3) ,szModel4,charsmax(szModel4),szModel5,charsmax(szModel5))
   
                model1[plr] = str_to_num(szModel1);
                model2[plr] = str_to_num(szModel2);
                model3[plr] = str_to_num(szModel3);
               
                model4[plr] = str_to_num(szModel4);
    }
    else
    {
                model1[plr] = 0;
                model2[plr] = 0;
                model3[plr] = 0;
               
                model4[plr] = 0;
    }
}
SaveExp(plr)
{
    get_user_name(plr, authid, sizeof(authid) - 1);
   
    formatex( data, sizeof( data ) - 1, "%d %d %d %d %d", model1[plr],model2[plr],model3[plr] ,model4[plr],model5[plr]);
   
    fvault_set_data(g_vault_name, authid, data);
}


OciXCrom 01-28-2020 20:32

Re: Skin shop just for Humans..
 
if(zp_get_user_zombie(id)) return

As simple as that.

Myshu 01-29-2020 08:24

Re: Skin shop just for Humans..
 
Quote:

Originally Posted by OciXCrom (Post 2682016)
if(zp_get_user_zombie(id)) return

As simple as that.

I need to change where i find those? : if(is_user_alive(id)&&!zp_get_user_zombie(id) )?

OciXCrom 01-29-2020 08:46

Re: Skin shop just for Humans..
 
Obviously in the beginning of the function that opens the menu, instead of these 2 cheks that make no sense:

Code:
if(get_user_team(id)!=ZP_TEAM_HUMAN||zp_get_user_zombie(id))

"ZP_TEAM_HUMAN" is not a valid "get_user_team" return value, nor is "|" the same as "||".

Myshu 01-29-2020 18:15

Re: Skin shop just for Humans..
 
When i add this : if(zp_get_user_zombie(id)) return i get this errors.

\c_zombie.sma(118) : warning 209: function "SkinSHOP" should return a value
\c_zombie.sma(120) : error 078: function uses both "return" and "return <value>"
\c_zombie.sma(123) : warning 225: unreachable code
\c_zombie.sma(146) : error 078: function uses both "return" and "return <value>"

But when i add if(zp_get_user_zombie(id)) without "return" i can compile it, is there a problem when "return is missin" or this: return PLUGIN_HANDLED will work as return?

OciXCrom 01-29-2020 20:24

Re: Skin shop just for Humans..
 
Add a return value like the warning says...

Myshu 01-30-2020 08:36

Re: Skin shop just for Humans..
 
Should look like this right? : if(zp_get_user_zombie(id)) return 1;

Plugin was compiled but i get one error: c_zombie.sma(122) : warning 225: unreachable code

at 122 line is this: new form[512]

and /buyskin doesn't work anymore :-?

ZaX 01-31-2020 02:28

Re: Skin shop just for Humans..
 
Show your code
Im sure you did the return value outside the statement "braces {}"


All times are GMT -4. The time now is 02:44.

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