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-24-2014 , 09:32   Re: give exp when ct or t win
Reply With Quote #1

thank you guys all but not work code i need 2 things 1 remove the code for give ct and t exp when they win and add yours i need give exp for who not dead when the round end give all who not dead exp 2 when some one spec me show him info my exp and level set message ShowSyncHudMsg to be updated every 30 sec please help me
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[] =
{
    
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)


Last edited by Zombie Player; 06-24-2014 at 09:32.
Zombie Player is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-24-2014 , 09:42   Re: give exp when ct or t win
Reply With Quote #2

Ahh, man.... First decide what you exactly want, and there make people do something.
Won't give ready code that time - will just explain you.
Hook logevent for round end, with all it's conditions.
Then simply loop trough the alive players and set their XP.

For that HUD. There are many plugin with this feature, you better take a look somewhere (mostly in other XP plugins). But it's not that hard. Make a global task with flag "b". Then loop trough alive players, show their hud. Then loop trough dead players, get the user they are spectating, check if they are spectating someone at all, and then show their HUD with the info of the spectated guy.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Zombie Player
Member
Join Date: May 2014
Old 06-24-2014 , 10:02   Re: give exp when ct or t win
Reply With Quote #3

you see first code what you can do on it give exp for who not dead and when some one spec me show him my exp and level this all i need to add to it and i fail do it if you know help me
Zombie Player is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-24-2014 , 11:10   Re: give exp when ct or t win
Reply With Quote #4

If you can't do this, just post in the Requests section. Here is the section, where people search help for things that they will do, not someone else to do it for them. So, you can't expect ready codes here.
__________________
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