Русское сообщество по скриптингу

Help adding VIP exp points

Scripting help for english speaking users. While not very active, you still have a chance to get help here.
Правила форума
We cannot maintain english version version of our forum rules, but shortly (it's simple) - Don't be a dick. If you really want to know our rules you should check appropriate thread.

Help adding VIP exp points

Сообщение VenomIvanof » 23 июл 2016, 15:29

Hi can you help me to add more EXP for VIP Users like this:
When VIP User kill player get 5 EXP and when kill with headshot get 10 EXP
When Normal Users kill player get 1 EXP and when kill with headhsot get 3 EXP

here is the code

Код: Выделить всё
#include <amxmodx>
#include <amxmisc>
#include < cstrike >
#include < fun >
#include < hamsandwich >
#include <fun>
#include <nvault>  
#include < csx > 
#include <dhudmessage>


//Define:

#define PLUGIN "Advanced Level Mode for Maina City"
#define VERSION "1.0"
#define AUTHOR "Training Day"

#define MAXLEVELS 9 


//Colorchat:

#if defined _colorchat_included
  #endinput
#endif
#define _colorchat_included

enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    new 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    new 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    static 
bool:saytext_used;
    static 
get_user_msgid_saytext;
    if(!
saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText");
        
saytext_used true;
    }
    
message_begin(typeget_user_msgid_saytext_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    static 
bool:teaminfo_used;
    static 
get_user_msgid_teaminfo;
    if(!
teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo");
        
teaminfo_used true;
    }
    
message_begin(typeget_user_msgid_teaminfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    new 
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
            return 
i;
    }

    return -
1;
}

//Cvars

new PlayerXP[33],PlayerLevel[33]
new 
XP_Kill,XP_Knife,XP_Hs,XP_AWP 
new XP_save 
new XP_plant,XP_defuse,XP_he
new g_vault 
new advertise


//Levels

new const LEVELS[MAXLEVELS] = {


100,
500,
1000,
5000,
10000,
50000,
60000,
90000,
100000
}  

//Plugin_init

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
    
register_clcmd("say /xp" ,"PrintXp"
    
    
register_concmd("amx_givexp" ,"CmdGiveXp",ADMIN_RCON,"Give user EXP")
    
register_concmd("amx_takexp""CmdTakeXp",ADMIN_RCON,"TAK USER EXP")
    
register_concmd("amx_xp" ,"CmdFindXp" ,ADMIN_RCON,"EXP INFO")
    
    
//Ham
    
    
RegisterHamHam_Spawn"player""Playerspawn")
    
    
register_event"DeathMsg""DeathMsg""a" )
    
        
    
    
XP_Kill=register_cvar("xp_kill","20"
    
XP_Hs=register_cvar("xp_hs","40"
    
XP_AWP=register_cvar("xp_awp","15")
    
XP_Knife=register_cvar("xp_knife","50"
    
XP_plant=register_cvar("xp_plant","5")
    
XP_defuse=register_cvar("xp_defuse","5"
    
XP_save=register_cvar("xp_save" ,"1")   
    
XP_he=register_cvar("xp_he","10"
    
advertise=register_cvar("xp_advertise" ,"1"
    
    
    
g_vault=nvault_open("XpClasicMod"//nvault name
    
        
}

          public 
client_putinserver(id) {
          
        if(
get_cvar_num("XP_save")==1) { 
            
LoadXp(id
            
    }
    
        
set_task(10.0,"ClientMsg",id)
        
set_task(1.0"ReminderMsg"0__"b")
        
    
}
    

    public 
client_disconnect(id) {
    
    if(
get_pcvar_num(XP_save)==1)  { 
                        
SaveXp(id)    
                
PlayerXP[id]=0      
                PlayerLevel
[id]=
                                 
    
}
}

 
public 
SaveXp(id)  

     
    new 
name[32]
    
get_user_name(id,name,31
    new 
vaultkey[64],vaultdata[256
 
    
format(vaultkey,63,"%s-XpClasic",name)  
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]) 
    
    
nvault_set(g_vault,vaultkey,vaultdata)  
    return 
PLUGIN_CONTINUE 
}  

public 
LoadXp(id

    new 
name[32]
    
get_user_name(id,name,31
    new 
vaultkey[64],vaultdata[256
    
    
format(vaultkey,63,"%s-XpClasic",name
    
format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id]) 
 
    
nvault_get(g_vault,vaultkey,vaultdata,255
    
replace_all(vaultdata255"#"" "
    new 
playerxp[32], playerlevel[32
    
parse(vaultdataplayerxp31playerlevel31
    
PlayerXP[id] = str_to_num(playerxp
    
PlayerLevel[id] = str_to_num(playerlevel
  
    
    return 
PLUGIN_CONTINUE 
}  


public 
ClientMsg(id) { 
    
    if(
get_pcvar_num(advertise) == 1) {
    
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Maina City ^4Exp System"
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3Make Kills to earn ^4EXP")
    
ColorChat(id,GREY,"^4[^3Maina City^4] ^3With every ^4level^3you will get more ^4extra items")
             }
}



public 
PrintXp(id) {
    
 
ColorChat(idGREY,"You have ^4%i ^3exp and you are level ^4%i ",PlayerXP[id],PlayerLevel[id])
 
set_dhudmessage(2552552550.00.1426.012.0)
 
show_dhudmessage(id"You have ^4%i ^3exp and you are level ^4%i ",PlayerXP[id],PlayerLevel[id])

    
}

public 
CmdGiveXp(id) { 
    
    if( 
get_user_flagsid ) & ADMIN_RCON )
    {
        new 
PlayerToGive32 ], XP32 ]
        
read_argv1,PlayerToGive31 )
        
read_argv2XP31 )
        new 
Player cmd_targetidPlayerToGive)
        if( !
Player ) {
            return 
1
        
}
        
        
        new 
XPtoGive str_to_numXP )
        new 
name32 ], owner32 ]
        
get_user_nameidowner31 )
        
get_user_namePlayername31 )
        
ColorChat(0,GREY,"Admin ^4%s give exp to ^4%s ^4[^3%s exp^4]."owner,name,XP)
        
PlayerXPPlayer ] += XPtoGive
        SaveXp
id )
    }
    else 
    {
        
ColorChatidGREY"^4[^3Maina City^4] ^3You dont have ^4access ^3to this command" )
    }
    return 
0
    
    
    
}

public 
CmdTakeXp(id) { 
    
    if( 
get_user_flagsid ) & ADMIN_RCON )
    {
        new 
PlayerToTake32 ], XP32 ]
        
read_argv1PlayerToTake31 )
        
read_argv2XP31 )
        new 
Player cmd_targetidPlayerToTake)
        if( !
Player ) {
        
        return 
1
     
}
    
        new 
XPtoTake str_to_numXP )
        new 
name32 ], owner32 ]
        
get_user_nameidowner31 )
        
get_user_namePlayername31 )
        
ColorChat(0,GREY,"Admin ^4%s ^3take exp from ^4%s ^4[^3%s exp^4].",owner,name,XP)
        
PlayerXPPlayer ] -= XPtoTake
        SaveXp
id )
    }

    else 
    {
        
ColorChatidGREY"You dont have access to this command." );
    }
    return 
0
    
    
    
}
    
    public 
CmdFindXp(id) { 
        
        if( 
get_user_flagsid ) & ADMIN_RCON)
    {
        new  
Arg132 ]
        
read_argv1Arg131 )
        new 
PlayertoFindcmd_targetidArg1)
        if( !
PlayertoFind ) {
        
    return 
1
    
}
    
    
    
        new  
Name32 ]
        
get_user_nameidName31 )
        
ColorChatidGREY"Player %s are level %i and %i XP."NamePlayerLevelPlayertoFind], PlayerXPPlayertoFind ] )
    }
        else 
    {
        
ColorChatidGREY"^4[^3Maina City^4] ^3You dont have ^4access ^3to this command" )
    }
        return 
0
        
        
        
    
}
    
    
    public 
DeathMsg(iWpnIndex) {
        new 
headshot=read_data(3
        new 
Victim=read_data(2
        new 
victim_name[32
        
get_user_nameVictimvictim_name31 
        new 
weaponHitPointattacker get_user_attackerVictimweaponHitPoint
        
        
        if(
headshot)  {
         
PlayerXP[attacker] += get_pcvar_num(XP_Hs)    
         
ColorChat(attacker,GREY,"You get  %i exp for killing with HeadShot Player %s.",get_pcvar_num(XP_Hs),victim_name)    
    
        }
        
        else {
        
        
        
PlayerXP[attacker ] += get_pcvar_numXP_Kill 
        
ColorChat(attacker,GREY,"You get  %i exp for killing Player:^4 %s. ",get_pcvar_num(XP_Kill),victim_name)
    }
        
        if(
weapon== CSW_KNIFE) {
                            
PlayerXP[attacker] += get_pcvar_num(XP_Knife)  
                            
ColorChat(attacker,GREY,"You get  %i exp for killing Player:^4 %s ^3with knife.",get_pcvar_num(XP_Knife),victim_name)    
        
        }
        
        if(
weapon== CSW_AWP) {
          
PlayerXP[attacker] += get_pcvar_num(XP_AWP)     
          
ColorChat(attacker,GREY,"You get %i exp for killing Player: ^4%s. ^3with ^4AWP",get_pcvar_num(XP_AWP),victim_name)        
        
        }
        
        if( 
iWpnIndex == CSW_HEGRENADE )
    {
                   
PlayerXP[attacker] += get_pcvar_num(XP_he)  
           
ColorChat(attacker,GREY,"You get %i exp for killing Player: %s. with HE Grenade",get_pcvar_num(XP_he),victim_name)        
        
    }
        

    
    
}

public  
Playerspawnid )
{
    
        
        if( ( 
PlayerLevelid] < && ( PlayerXPid ] > LEVELSPlayerLevelid ] ] ) ) )
    
    {
        while( 
PlayerXPid ] > LEVELSPlayerLevelid] ] )
        {
            
PlayerLevelid] += 1
            
            
            ColorChat
(idGREY,"Congratz now you have^4 %i ^3exp and you are Level: ^4%i ",PlayerXP[id],PlayerLevel[id])
        }
    }
    
            
set_task10.0"Player_items"id )
                   
        }
    
    

public 
bomb_plantedplanter 


PlayerXP[planter] += get_pcvar_num(XP_plant
ColorChat(planter,GREY,"You get %i exp for planting the ^4BOMB.",get_pcvar_num(XP_plant))    



public 
bomb_defuseddefuser 


PlayerXP[defuser] += get_pcvar_num(XP_defuse)  
ColorChat(defuser,GREY,"You get ^4%i ^3exp for defusing the ^4BOMB.",get_pcvar_num(XP_defuse))    

}  
      
public 
Player_items(id) {

    if( 
PlayerLevelid ] == ) {
    
ColorChat(id,GREEN,"You are level 1.")
ColorChat(id,GREEN,"You get bla bla.")
give_item(id"weapon_flashbang")
    
    }
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(id,RED,"You are level 2")
    
ColorChat(id,GREEN,"You get bla bla")
    
give_item(id"weapon_flashbang")
    }
    
             
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(id,RED,"You are level 3")
    
ColorChat(id,GREEN,"You get bal bal")
    
give_item(id"weapon_flashbang")
    }
    
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(id,RED,"You are Level 4")
    
ColorChat(id,GREEN,"You get bla bla")
    
give_item(id"weapon_flashbang")
    }
    

    
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(id,RED,"You are Level 5")
    
ColorChat(id,GREEN,"You get bla bla")
    
give_item(id,"weapon_deagle")
    }
        
    else if( 
PlayerLevelid ] == 6) {
    
    
ColorChat(id,RED,"You are Level 6")
    
ColorChat(id,GREEN,"You get bla bla")
    
give_item(id,"weapon_deagle")
    
    }
        
    else if( 
PlayerLevelid ] == ) {
    
    
ColorChat(id,RED,"You are Level 7")
    
ColorChat(id,GREEN,"You get bla bla")
    
give_item(id,"weapon_deagle")
    }

    else if( 
PlayerLevelid ] == ) {
    
    if (
cs_get_user_team(id) == CS_TEAM_T ){    
    
ColorChat(id,RED,"You are Level 8")
    
ColorChat(id,GREEN,"You get bla bla")
    
strip_user_weapons(id);
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE90)
    
give_item(id,"weapon_AK47")
    
cs_set_user_bpammo(idCSW_AK4790)
    
set_user_health(idget_user_health(id) + 5);
    
set_user_armor(idget_user_armor(id) + 50);
    }
    if (
cs_get_user_team(id) == CS_TEAM_CT) {
        
    
ColorChat(id,RED,"You are Level 8")
    
ColorChat(id,GREEN,"You get bla bla")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE90)
    
give_item(id"weapon_m4a1")
    
cs_set_user_bpammo(idCSW_M4A190)
    
set_user_health(idget_user_health(id) + 10);
    
set_user_armor(idget_user_armor(id) + 60);
    }
    
    }

    else if( 
PlayerLevelid ] == ) {
    
    if (
cs_get_user_team(id) == CS_TEAM_CT) {
    
    
ColorChat(id,GREY,"Your Level is^4 9")
    
ColorChat(id,GREY,"Auto reward: Grenade Pack, AWP+Deagle, +20HP, FULL Armor")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE90)
    
give_item(id"weapon_awp")
    
cs_set_user_bpammo(idCSW_AWP30)
    
give_item(id"weapon_hegrenade")
    
cs_set_user_bpammo(idCSW_HEGRENADE3)
    
give_item(id"weapon_flashbang")
    
cs_set_user_bpammo(idCSW_FLASHBANG3)
    
give_item(id"weapon_smokegrenade")
    
cs_set_user_bpammo(idCSW_SMOKEGRENADE1)
    
set_user_health(idget_user_health(id) + 10)
    
set_user_armor(idget_user_armor(id) + 50);
    
    }        
    if (
cs_get_user_team(id) == CS_TEAM_T)  {
    
    
    
ColorChat(id,GREY,"Your Level is^4 9")
    
ColorChat(id,GREY,"Auto reward: Grenade Pack, AWP+Deagle, +20HP, FULL Armor")
    
give_item(id,"weapon_deagle")
    
cs_set_user_bpammo(idCSW_DEAGLE90)
    
give_item(id"weapon_awp")
    
cs_set_user_bpammo(idCSW_AWP30)
    
give_item(id"weapon_hegrenade")
    
cs_set_user_bpammo(idCSW_HEGRENADE3)
    
give_item(id"weapon_flashbang")
    
cs_set_user_bpammo(idCSW_FLASHBANG3)
    
set_user_health(idget_user_health(id) + 10);
    
set_user_armor(idget_user_armor(id) + 50);
    }
    
    
    
}
}  
Аватара пользователя
VenomIvanof
 
Сообщения: 62
Зарегистрирован: 02 апр 2016, 13:26
Благодарил (а): 17 раз.
Поблагодарили: 1 раз.
Языки программирования: Counter-Strike 1.6

Re: Help adding VIP exp points

Сообщение Leonidddd » 23 июл 2016, 16:29

Using will be something like this:
Код: Выделить всё
PlayerXP[attacker] += get_pcvar_num(XP_Hs

------------------------->
Код: Выделить всё
(get_user_flags(attacker) & ADMIN_RCON) ? (PlayerXP[attacker] += get_pcvar_num(XP_Hs)*2) : (PlayerXP[attacker] += get_pcvar_num(XP_Hs)) 

or
Код: Выделить всё
if(get_user_flags(attacker) & ADMIN_RCON) {PlayerXP[attacker] += get_pcvar_num(XP_Hs)*2}else{PlayerXP[attacker] += get_pcvar_num(XP_Hs)} 


Read about get_user_flags and try .
Аватара пользователя
Leonidddd
Модератор
 
Сообщения: 2165
Зарегистрирован: 08 апр 2012, 18:13
Откуда: г. Запорожье
Благодарил (а): 177 раз.
Поблагодарили: 602 раз.
Языки программирования: Counter-Strike 1.6


Вернуться в Scripting

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 1