Raised This Month: $ Target: $400
 0% 

give exp when ct or t win


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
...
Junior Member
Join Date: Jun 2014
Old 06-24-2014 , 06:28   Re: give exp when ct or t win
Reply With Quote #1

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <colorchat>
#include <fun>
#include <nvault>
#include <hamsandwich>
#define PREFIX "[...]"
#define HUD_TASK 2454527

    
    
new gExp[33], gLvl[33], gSpecs[33];
    new 
gCvarKillgCvarHsgCvarSuigCvarWingCvarLoose;
    new 
gVault sync
    
new const Specs[][] =
    {
     
"Newbie",
     
"Regular",
     
"ModeRate",
     
"Semi-Pro",
     
"OptiMax"
    
}
    new const 
Levels[] =
    {
     
0,
     
25,
     
50,
     
75,
     
100,
     
125,
     
150,
     
175,
     
200,
     
235,
     
270,
     
310,
     
350,
     
375,
     
400,
     
425,
     
450,
     
485,
     
520,
     
555,
     
600
    
}
    new const 
CTWin[][] =
    {
     
"2=%!MRAD_ctwin",
     
"2=%!MRAD_BOMBDEF",
     
"2=%!MRAD_rescued"
    
}
    public 
plugin_init()
    {
     
register_plugin("Exp-Mod""1.0""Rtk.Esc")
     
     
register_event"DeathMsg""DeathEvent""a" )
     
register_event"SendAudio""TwinEvent""a""2=%!MRAD_terwin" )
     for(new 
isizeof(CTWin); i++)
      
register_event"SendAudio""CwinEvent""a"CTWin[i] )
     
RegisterHamHam_Spawn"player""HamSpawnEvent")
     
     
gCvarKill  register_cvar("exp_kill",     "20")
     
gCvarHs    register_cvar("exp_headshot","10")
     
gCvarSui   register_cvar("exp_suicide""10")
     
gCvarWin   register_cvar("exp_win",     "10")
     
gCvarLoose register_cvar("exp_loose",   "5")
     
     
register_clcmd("say /xp""showExp")
     
register_clcmd("say /info""showInfo")
     
register_logevent("CTwin"6"3=CTs_Win""3=All_Hostages_Rescued")
     
register_logevent("Twin" 6"3=Terrorists_Win""3=Target_Bombed"
     
gVault nvault_open("exp")
     
sync CreateHudSyncObj()
    }
    public 
SaveExp(id)
    {
     new 
SteamID[35]
     
get_user_authid(idSteamID34)
     
     new 
vaultkey[64],vaultdata[256]
     
format(vaultkey63"%s-Mod"SteamID)
     
format(vaultdata255"%i#%i#%i#"gExp[id], gLvl[id], gSpecs[id])
     
nvault_set(gVaultvaultkeyvaultdata)
     
     return 
PLUGIN_CONTINUE
    
}
    public 
LoadExpid )
    {
     new 
SteamID[35]
     
get_user_authid(idSteamID34)
     
     new 
vaultkey[64],vaultdata[256]
     
format(vaultkey63"%s-Mod"SteamID)
     
format(vaultdata255"%i#%i#%i#"gExp[id], gLvl[id], gSpecs[id])
     
nvault_get(gVault,vaultkey,vaultdata,255)
     
     
replace_all(vaultdata255"#"" ")
     new 
exp[32], lvl[32], specs[32]
     
     
parse(vaultdataexp31lvl31specs31)
     
     
gExp[id] = str_to_num(exp)
     
gLvl[id] = str_to_num(lvl)
     
gSpecs[id] = str_to_num(specs)
     
     return 
PLUGIN_CONTINUE;
    }
    public 
client_authorized(id)
    {
     
LoadExp(id)
    }
    public 
client_disconnect(id)
    {
     
SaveExp(id)
     
gExp[id] = 0;
     
gLvl[id] = 0;
     
gSpecs[id] = 0;
     
remove_task(id+HUD_TASK)
    }
    public 
DeathEvent()
    {
     new 
iAtkr read_data(1)
     new 
iVict read_data(2)
     new 
iSuic read_data(0)
     new 
AtkrTeam get_user_team(iAtkr)
     new 
VictTeam get_user_team(iVict)
     
     if(
is_user_bot(iAtkr) || AtkrTeam == VictTeam)
     {
      return 
PLUGIN_HANDLED;
     }
     
     if(
iSuic)
     {
      
gExp[iSuic] -= get_pcvar_num(gCvarSui)
      
SaveExp(iSuic)
      return 
PLUGIN_HANDLED;
     }
     
     if(
AtkrTeam != VictTeam)
     {
      
gExp[iAtkr] += get_pcvar_num(gCvarKill)
      
      if(
read_data(3))
      {
       
gExp[iAtkr] += get_pcvar_num(gCvarHs)
      }
     }
     while(
gExp[iAtkr] >= Levels[gLvl[iAtkr]])
     {
      
gLvl[iAtkr] += 1;
      
ColorChat(iAtkrGREEN"%sCongratulations! You grew to level %i!"PREFIXgLvl[iAtkr]);
      if(
gLvl[iAtkr] == || 10 || 15 || 20)
      {
       
rankUp(iAtkr);
      }
     }
     
SaveExp(iAtkr)
     return 
PLUGIN_CONTINUE;
    }
    public 
TwinEvent( )
    {
     for ( new 
id 1id <= 32; ++id )
     {
      if(
get_user_team(id) == )
      {
       
gExp[id] -= get_pcvar_num(gCvarLoose)
       
SaveExp(id)
       return 
PLUGIN_HANDLED;
      }
      if( 
get_user_team id ) == )
      {
       
gExp[id] += get_pcvar_numgCvarWin )
       
       while( 
gExp[id] >= Levels[gLvl[id]] )
       {
        
gLvl[id] += 1;
        
ColorChat(idGREEN"%sCongratulations! You grew to level %i!"PREFIXgLvl[id]);
        if(
gLvl[id] == || 10 || 15 || 20)
        {
         
rankUp(id);
        }
        
SaveExpid );
       }
      }
     }
     return 
PLUGIN_HANDLED;
    }
    public 
CwinEvent( )
    {
     for ( new 
id 1id <= 32; ++id )
     {
      if(
get_user_team(id) == )
      {
       
gExp[id] -= get_pcvar_num(gCvarLoose)
       
SaveExp(id)
       return 
PLUGIN_HANDLED;
      }
      if( 
get_user_team id ) == )
      {
       
gExp[id] += get_pcvar_numgCvarWin )
       
       while( 
gExp[id] >= Levels[gLvl[id]] )
       {
        
gLvl[id] += 1;
        
ColorChat(idGREEN"%sCongratulations! You grew to level %i!"PREFIXgLvl[id]);
        if(
gLvl[id] == || 10 || 15 || 20)
        {
         
rankUp(id);
        }
        
SaveExpid );
       }
      }
     }
     return 
PLUGIN_HANDLED;
    }
    public 
HamSpawnEvent(id)
    {
         if(
gLvl[id] >= 5)
            
set_user_health(id105)
         if(
gLvl[id] >= 8)
            
set_user_health(id110)
         if(
gLvl[id] >= 12)
            
set_user_health(id120)
         if(
gLvl[id] >= 15)
            
set_user_health(id130)
         if(
gLvl[id] >= 18)
         {
              
set_user_health(id135)
              
give_item(id"weapon_hegrenade")
         }
         if(
gLvl[id] >= 21)
         {
              
set_user_health(id140);
              
give_item(id"weapon_hegrenade");
              
give_item(id"weapon_awp");
         }
    }
     
    public 
showExp(id)
    {
         
set_hudmessage(255000.010.1706.012.0)
         
show_hudmessage(id"[%s]Exp: %i Lvl: %i"Specs[gSpecs[id]], gExp[id], gLvl[id])
    }
    public 
showInfo(id)
    {
         
set_hudmessage(255000.010.1706.012.0)
         
show_hudmessage(id"[%s]Exp:%i/%i Lvl: %i"Specs[gSpecs[id]], gExp[id], Levels[gLvl[id] + 1], gLvl[id])
    }
    public 
rankUp(id)
    { 
     if(
gLvl[id] == 5)
     {
          
gSpecs[id] = 1;
          
ColorChat(idGREEN"%sYou grew to %s"PREFIXSpecs[gSpecs[id]])
     }
     if(
gLvl[id] == 10)
     {
          
gSpecs[id] = 2;
          
ColorChat(idGREEN"%sYou grew to %s"PREFIXSpecs[gSpecs[id]])
     }
     if(
gLvl[id] == 15)
     {
          
gSpecs[id] = 3;
          
ColorChat(idGREEN"%sYou grew to %s"PREFIXSpecs[gSpecs[id]])
     }
     if(
gLvl[id] == 20)
     {
          
gSpecs[id] = 4;
          
ColorChat(idGREEN"%sYou grew to %s"PREFIXSpecs[gSpecs[id]])
     }
    }
    
    public 
CTwin()
    {
        new 
players[32], num
        get_players
(playersnum"eh""CT")
        
        for(new 
inumi++)
        {
        
gExp[i] += //This is the EXP you give for winning CT team!
        
}
    }
    
    public 
Twin()
    {
        new 
players[32], num
        get_players
(playersnum"eh""TERRORIST")
        
        for(new 
inumi++)
        {
        
gExp[i] += //This is the EXP you give for winning CT team!
        
}
    }  
    
    
    public 
client_putinserver(id)
    {
        if(!
is_user_bot(id))
            
set_task(1.0,"show_exp",id+HUD_TASK,_,_,"b")
    }
    
        
    
    public 
show_exp(index)
    {
        new 
player index HUD_TASK
        
static data[128]
        
        if(!
is_user_alive(player))
        {
            
player pev(player,pev_iuser2)
            
            if(!
is_user_alive(player))
                
formatex(data,charsmax(data),"Please spectate someone")
                
            else
            {    
                
                static 
name[32]
                
get_user_name(player,name,charsmax(name))
                
formatex(data,charsmax(data),"[NAME]:- %s | Exp - %d | Level - %d",name,gExp[player],gLvl[player])
                
            }
            
        }
        else
            
formatex(data,charsmax(data),"Your stats :- Exp - %d | Level - %d",gExp[player],gLvl[player])
            
        
set_hudmessage(02552550.020.8906.01.10.00.0, -1)
        
ShowSyncHudMsg(index-HUD_TASK,sync,data)
    } 
Added permanent hud and the above suggested code. Please indent your code , and use switch cases. You can optimise ur code much more.
... 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 21:14.


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