Raised This Month: $ Target: $400
 0% 

give exp when ct or t win


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zombie Player
Member
Join Date: May 2014
Old 06-23-2014 , 17:22   give exp when ct or t win
Reply With Quote #1

please help me in this plugin i need to add to it code when ct or t win give all team who win 1 exp please help me
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fun>
#include <nvault>
#include <hamsandwich>
#define PREFIX "[...]"
new gExp[33], gLvl[33], gSpecs[33];
new 
gCvarKillgCvarHsgCvarSuigCvarWingCvarLoose;
new 
gVault;
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")
 
 
gVault nvault_open("exp")
}
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;
}
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]])
 }
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1053\\ f0\\ fs16 \n\\ par }
*/ 
Zombie Player is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-23-2014 , 19:18   Re: give exp when ct or t win
Reply With Quote #2

First we register the logevents for each team winning:
PHP Code:
    register_logevent("CTwin"6"3=CTs_Win""3=All_Hostages_Rescued")
    
register_logevent("Twin" 6"3=Terrorists_Win""3=Target_Bombed"
Then we loop trough the players in the team in each function, and add their eXP. It's easy:
PHP Code:
public CTwin()
{
    new 
players[32], num
    get_players
(playersnum"eh""CT")
    
    for(new 
inumi++)
    {
        
gExp[players[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[players[i]] += //This is the EXP you give for winning CT team!
    
}

P.S.: As far as you don't understand of pawn, this topic should be in Request section - you want someone to do it for you.
__________________

Last edited by Flick3rR; 06-24-2014 at 08:33.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Zombie Player
Member
Join Date: May 2014
Old 06-24-2014 , 03:31   Re: give exp when ct or t win
Reply With Quote #3

thanks can you set hud message that show any one spec me or spec any player show him please help

show_hudmessage(id, "[%s]Exp: %i Lvl: %i", Specs[gSpecs[id]], gExp[id], gLvl[id])
Zombie Player is offline
...
Junior Member
Join Date: Jun 2014
Old 06-24-2014 , 06:28   Re: give exp when ct or t win
Reply With Quote #4

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
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-24-2014 , 06:25   Re: give exp when ct or t win
Reply With Quote #5

Didn't understand anything? Explain better. Also give me the parameters of "set_hudmessage" that you want - possitions, colors, etc.
__________________

Last edited by Flick3rR; 06-24-2014 at 06:28.
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-24-2014 , 06:32   Re: give exp when ct or t win
Reply With Quote #6

Exactly for that indenting it's better to attach bigger codes as a .sma file. I'm also getting pissed of that indention, but...
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-24-2014 , 06:37   Re: give exp when ct or t win
Reply With Quote #7

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,/* don't start from 0, you have no reason to do this. player will already start with 0 xp. In your way, if player gain any value of xp it will increase in level */
    
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])//you don't need # as a separtor,use just a simple space
    
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])//same here
    
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)
    {
        
//wrong
        
gExp[iAtkr] += get_pcvar_num(gCvarKill)
        
        if(
read_data(3))
        {
            
gExp[iAtkr] += get_pcvar_num(gCvarHs)
        }
        
        
/* Use it like this 
            if ( read_data ( 3 ) )  
                do sth
            else
                do sth
        
        */
    
}
    
    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)

Your code is very bad. Also why are you hooking two time ct win and t win events ? I leaved some comments where you have to change your code to avoid bugs.
HamletEagle is offline
...
Junior Member
Join Date: Jun 2014
Old 06-24-2014 , 06:48   Re: give exp when ct or t win
Reply With Quote #8

I just added hud , its not mine
... is offline
DWIGHTpN
Senior Member
Join Date: Jan 2013
Location: Romania.
Old 06-24-2014 , 07:12   Re: give exp when ct or t win
Reply With Quote #9

PHP Code:
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! 
    


Small mistake: gExp[i] += 1 ->> gExp[players[i]] += 1;

Last edited by DWIGHTpN; 06-24-2014 at 07:13.
DWIGHTpN is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-24-2014 , 08:32   Re: give exp when ct or t win
Reply With Quote #10

Awww, yeah, man! What a dumbass am I. Thanks for noticing.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
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