Raised This Month: $32 Target: $400
 8% 

Player Skins Pick


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghostz0r
Senior Member
Join Date: Dec 2012
Old 03-21-2018 , 13:14   Player Skins Pick
Reply With Quote #1

Hello dear friends, i just maked some plugin to my server, vip players can pick model to self, so, can someone help me to make check to player team & save type with steamid?

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <fun>

public plugin_init()
{

    
register_clcmd("say /vmodels","My_Menu",ADMIN_LEVEL_H,"Menu")
}
public 
plugin_precache()
{
    
// Change your models here.
    
engfunc(EngFunc_PrecacheModel"models/player/type1_ct/type1_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type1_t/type1_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type2_ct/type2_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type2_t/type2_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type3_ct/type3_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type3_t/type3_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type4_ct/type4_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type4_t/type4_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type5_ct/type5_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type5_t/type5_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type2_t/type2_tT.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type3_t/type3_tT.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type4_t/type4_tT.mdl")

}
public 
My_Menu(id)
{
    new 
i_Menu menu_create("\rКакую модель хотите?""menu_handler")


    
menu_additem(i_Menu"\wType 1""1"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 2""2"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 3""3"ADMIN_LEVEL_H)   
    
menu_additem(i_Menu"\wType 4""4"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 5""5"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 6""6"ADMIN_RCON)
    
menu_additem(i_Menu"\wType 7""7"ADMIN_LEVEL_D)
        
    
menu_setprop(i_MenuMPROP_EXITMEXIT_ALL)

    
menu_display(idi_Menu0)
 }

public 
menu_handler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        
        return 
PLUGIN_HANDLED
    
}

    new 
s_Data[6], s_Name[64], i_Accessi_Callback

    menu_item_getinfo
(menuitemi_Accesss_Datacharsmax(s_Data), s_Namecharsmax(s_Name), i_Callback)

    new 
i_Key str_to_num(s_Data)

    switch(
i_Key)
    {
                case 
1/* Item 1*/
                
{
if (
get_user_teamid ) == CS_TEAM_T

cs_set_user_model(id"type1_t")
}
if ( 
get_user_teamid ) == CS_TEAM_CT 

cs_set_user_model(id"type1_ct")
}        
client_print(id,print_chat"You picked #1")
 }
                case 
2/* Item 2*/
                
{
if (
get_user_teamid ) == CS_TEAM_T

cs_set_user_model(id"type2_t")
}
if ( 
get_user_teamid ) == CS_TEAM_CT 

cs_set_user_model(id"type2_ct")
}        
client_print(id,print_chat"You picked #2")
                }
                case 
3:/* Item 3*/
                
{
if (
get_user_teamid ) == CS_TEAM_T

cs_set_user_model(id"type3_t")
}
if ( 
get_user_teamid ) == CS_TEAM_CT 

cs_set_user_model(id"type3_ct")
}        
client_print(id,print_chat"You picked #3")
}
                case 
4/* Item 4*/
                
{
 if (
get_user_teamid ) == CS_TEAM_T

cs_set_user_model(id"type4_t")
}
if ( 
get_user_teamid ) == CS_TEAM_CT 

cs_set_user_model(id"type4_ct")
}        
client_print(id,print_chat"You picked #4")
                }
                case 
5/* Item 1*/
                
{
if (
get_user_teamid ) == CS_TEAM_T

cs_set_user_model(id"type5_t")
}
if ( 
get_user_teamid ) == CS_TEAM_CT 

cs_set_user_model(id"type5_ct")
}       
client_print(id,print_chat"You picked #5")
}
                case 
6:
                {
                
client_print(id,print_chat"You picked #6")        
                }
                case 
7:
                {
                
client_print(id,print_chat"You picked #7")        
                }
        }
    
// Destroy menu
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
 

code is here, thanks!

Last edited by ghostz0r; 03-21-2018 at 13:15.
ghostz0r is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 03-21-2018 , 14:22   Re: Player Skins Pick
Reply With Quote #2

checking player team:
Code:
/* enum CsTeams {     CS_TEAM_UNASSIGNED = 0,     CS_TEAM_T          = 1,     CS_TEAM_CT         = 2,     CS_TEAM_SPECTATOR  = 3, }; */ if(get_user_team(id) == 1){     return//or execute particular code. //you could use CS_TEAM_T instead of 1 for readability purposes, but I don't know if you have //included the cstrike. In which case: simply uncomment that enum block of code and put it //somewhere globally on top of the plugin . }
about the saving part... I feel like this has been explained too many times already. Do some search. If you have failed. Post us what you have tried and we will help. It can be done either by nvault, mysql, or simple txt file.

edit....
Please indent your code properly. It will be way easier for you and us to understand it.
__________________
retired chump

Last edited by DjSoftero; 03-21-2018 at 14:23.
DjSoftero is offline
ghostz0r
Senior Member
Join Date: Dec 2012
Old 03-22-2018 , 11:32   Re: Player Skins Pick
Reply With Quote #3

Quote:
Originally Posted by DjSoftero View Post
checking player team:
Code:
/* enum CsTeams {     CS_TEAM_UNASSIGNED = 0,     CS_TEAM_T          = 1,     CS_TEAM_CT         = 2,     CS_TEAM_SPECTATOR  = 3, }; */ if(get_user_team(id) == 1){     return//or execute particular code. //you could use CS_TEAM_T instead of 1 for readability purposes, but I don't know if you have //included the cstrike. In which case: simply uncomment that enum block of code and put it //somewhere globally on top of the plugin . }
about the saving part... I feel like this has been explained too many times already. Do some search. If you have failed. Post us what you have tried and we will help. It can be done either by nvault, mysql, or simple txt file.

edit....
Please indent your code properly. It will be way easier for you and us to understand it.
thanks a lot, i just readed forum, i think nvault is way to save skins, but how i can do it? i just added nvault saving etc, so ,how i can save, give skin to players from/to nvault?

here is code what i try=D

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <cstrike>
#include <fun>


new const PLUGIN[] = "Skin System";
new const 
VERSION[] = "1.0";
new const 
AUTHOR[] = "Ghost";

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);
    
register_cvar(PLUGINAUTHORFCVAR_SERVER);

    
register_clcmd("say /vmodels","My_Menu",ADMIN_LEVEL_H,"Menu")
}
public 
plugin_cfg()
{
    
//Open our vault and have g_Vault store the handle.
    
g_Vault nvault_open"skins_vault" );

    
//Make the plugin error if vault did not successfully open
    
if ( g_Vault == INVALID_HANDLE )
        
set_fail_state"Error opening nVault" );

    
//This will remove all entries in the vault that are 5+ (or cvar+) days old at server-start
    //or map-change
    
nvault_pruneg_Vault get_systime() - ( 86400 get_pcvar_numg_pExpireDays ) ) );
}
public 
plugin_end()
{
    
//Close the vault when the plugin ends (map change\server shutdown\restart)
    
nvault_closeg_Vault );
}

public 
client_authorized(id)
{
    
//Get the connecting users authid and store it in our global string array so it
    //will not need to be retrieved every time we want to do an nvault transaction.
    
get_user_authidid g_szAuthID[id] , charsmaxg_szAuthID[] ) );
}
public 
plugin_precache()
{
    
// Change your models here.
    
engfunc(EngFunc_PrecacheModel"models/player/type1_ct/type1_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type1_t/type1_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type2_ct/type2_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type2_t/type2_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type3_ct/type3_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type3_t/type3_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type4_ct/type4_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type4_t/type4_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type5_ct/type5_ct.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type5_t/type5_t.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type2_t/type2_tT.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type3_t/type3_tT.mdl")
    
engfunc(EngFunc_PrecacheModel"models/player/type4_t/type4_tT.mdl")

}
public 
cmdSaveSkin(id)
{
    
//Save a single item into the value of the entry.
    //Example: STEAM_0:0:1234 16000

    
new szSkin[7];        //Data holder for the money amount
    
new szKey[40];        //Key used to save money "STEAM_0:0:1234MONEY"

    
formatexszKey charsmaxszKey ) , "%sSKIN" g_szAuthID[id] );
    
formatexszSkin charsmaxszSkin ) , "%d" cs_get_user_money(id) );
    
    
nvault_setg_Vault szKey szSkin );

    
client_printid print_chat "* Data saved" );
}

public 
cmdGetSkin(id)
{
    
//Retrieve a single item from vault
    //Example: STEAM_0:0:1234 16000

    
new szKey[40];
    
formatexszKey charsmaxszKey ) , "%sS" g_szAuthID[id] );
    new 
iSkin nvault_getg_Vault szKey );

    
//If our money key was found, set the users money to the value we read from vault and
    //delete the key so the player will not get the same money again.
    
if ( iSkin )
    {
        
cs_set_user_moneyid iSkin );
        
nvault_removeg_Vault szKey );

        
client_printid print_chat "* Your money was loaded from vault: $%d" iSkin );
    }
    else
    {
        
client_printid print_chat "* You have no money entry in vault." );
    }
}

public 
My_Menu(id)
{
    new 
i_Menu menu_create("\rКакую модель хотите?""menu_handler")


    
menu_additem(i_Menu"\wType 1""1"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 2""2"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 3""3"ADMIN_LEVEL_H)   
    
menu_additem(i_Menu"\wType 4""4"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 5""5"ADMIN_LEVEL_H)
    
menu_additem(i_Menu"\wType 6""6"ADMIN_LEVEL_D)
    
menu_additem(i_Menu"\wType 7""7"ADMIN_LEVEL_D)
        
    
menu_setprop(i_MenuMPROP_EXITMEXIT_ALL)

    
menu_display(idi_Menu0)
 }

public 
menu_handler(idmenuitem)
{
    if (
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        
        return 
PLUGIN_HANDLED
    
}

    new 
s_Data[6], s_Name[64], i_Accessi_Callback

    menu_item_getinfo
(menuitemi_Accesss_Datacharsmax(s_Data), s_Namecharsmax(s_Name), i_Callback)

    new 
i_Key str_to_num(s_Data)

    switch(
i_Key)
    {
        case 
1/* Item 1*/
        
{
            if (
get_user_team(id) == 1)
                { 
            
cs_set_user_model(id"type1_t")
                }
            if (
get_user_team(id) == 2)
                { 
            
cs_set_user_model(id"type1_ct")
                }        
            
client_print(id,print_chat"You picked #1")
        }
        case 
2/* Item 2*/
        
{
            if (
get_user_team(id) == 1)
                { 
            
cs_set_user_model(id"type2_t")
                }
            if (
get_user_team(id) == 2
                { 
            
cs_set_user_model(id"type2_ct")
                }        
            
client_print(id,print_chat"You picked #2")
        }
        case 
3:/* Item 3*/
        
{
            if (
get_user_team(id) == 1)
                { 
            
cs_set_user_model(id"type3_t")
                }
            if (
get_user_team(id) == 2
                { 
            
cs_set_user_model(id"type3_ct")
                }        
            
client_print(id,print_chat"You picked #3")
        }
        case 
4/* Item 4*/
        
{
            if (
get_user_team(id) == 1)
                {
            
cs_set_user_model(id"type4_t")
                }
            if (
get_user_team(id) == 2
                { 
            
cs_set_user_model(id"type4_ct")
                }        
            
client_print(id,print_chat"You picked #4")
        }
        case 
5/* Item 5*/
        
{
            if (
get_user_team(id) == 1)
                { 
            
cs_set_user_model(id"type5_t")
                }
            if (
get_user_team(id) == 2
                { 
            
cs_set_user_model(id"type5_ct")
                }       
            
client_print(id,print_chat"You picked #5")
        }
        case 
6/* Item 6*/
        
{
            if (
get_user_team(id) == 1)
                { 
            
cs_set_user_model(id"type5_t")
                }
            if (
get_user_team(id) == 2
                { 
            
cs_set_user_model(id"type5_ct")
                }       
            
client_print(id,print_chat"You Picked Special Skin #1")
        }
        case 
7/* Item 7*/
        
{
            if (
get_user_team(id) == 1)
                { 
            
cs_set_user_model(id"type5_t")
                }
            if (
get_user_team(id) == 2
                { 
            
cs_set_user_model(id"type5_ct")
                }       
            
client_print(id,print_chat"You Picked Special Skin #2")
        }
    }
    
// Destroy menu
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
 


Last edited by ghostz0r; 03-22-2018 at 11:36.
ghostz0r is offline
DjSoftero
Veteran Member
Join Date: Nov 2014
Location: Lithuania
Old 03-22-2018 , 13:32   Re: Player Skins Pick
Reply With Quote #4

Start by including <nvault> library. Afterwards, you will see, that g_Vault doesn't exist, so create it globally. After doing so, yet another error will pop up on the line 32(for me at least) which is:
Code:
nvault_prune( g_Vault , 0 , get_systime() - ( 86400 * get_pcvar_num( g_pExpireDays ) ) );
it tries to get data from g_pExpireDays cvar, but it doesn't exist either, so you should create it again and declare it's value to an integer number like 5.

To be honest, I think you should go back to basics and slowly work your way up to this, as it is quite a complex task if you ask me, or wait for someone patient enough to explain how things work. Ofcourse someone could just do it for you.
__________________
retired chump

Last edited by DjSoftero; 03-22-2018 at 13:38.
DjSoftero is offline
Reply



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 00:29.


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