Raised This Month: $ Target: $400
 0% 

Team wining points in skillpoints plugin


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
semanja
Junior Member
Join Date: Jan 2010
Old 04-21-2012 , 20:29   Team wining points in skillpoints plugin
Reply With Quote #1

hi

I need help to make other points when your team wins give points for team wining and if your team lose you lost points maybe like gathers... i have try make that but its so hard for me xD

sorry for my bad english



PHP Code:
#include <amxmodx>   
#include <amxmisc>   
#include <csx>   
#include <nvault>   
#include <cstrike>   
#include <fun>   
#define Plugin "DOT POINTS/TAG"   
#define Version "1.0"   
#define Author "Mace"   
#define MAXSLOTS 32   
enum Color {   
    
YELLOW 1,   
    
GREEN,   
    
TEAM_COLOR,   
    
GREY,   
    
RED,   
    
BLUE   
}   
new 
TeamName[][] = {   
     
    
"",   
    
"TERRORIST",   
    
"CT",   
    
"SPECTATOR"   
     
}   
new 
kill_pointsdeath_pointstime_points;   
new 
def_pointsboom_points;   
new 
head_pointsknife_pointsnade_pointstk_pointsskill_points;   
new 
TeamInfo,SayText,MaxSlots;   
new 
points[32], vote_choices[3]   
new 
bool:IsConnected[MAXSLOTS 1];   
new 
pCvar_PluginState 
public plugin_init()   
{   
    
register_plugin(PluginVersionAuthor);   
     
    
kill_points register_cvar("PS_kill_points""1");   
    
death_points register_cvar("PS_death_points""1");   
     
    
def_points register_cvar("PS_defusion_points""5");   
    
boom_points register_cvar("PS_boom_points""4");   
     
    
time_points register_cvar("PS_time_points""15");   
    
head_points register_cvar("PS_head_points""2");   
     
    
knife_points register_cvar("PS_knife_points""4");   
    
nade_points register_cvar("PS_nade_points""4");   
     
    
tk_points register_cvar("PS_tk_points""8");   
    
skill_points register_cvar("PS_skill_points""3"); 
     
    
pCvar_PluginState register_cvar("PS_plugin""0"); 
     
    
register_clcmd("say .skill""show_points");   
    
register_clcmd("say !skill""show_points");  
    
register_clcmd("say .top15""show_top15");   
     
    
register_concmd("amx_points""cmd_points"ADMIN_BAN" - <name> <points> Set's someones points");   
    
register_concmd("amx_vote_point""cmd_vote_points"ADMIN_BAN" - <name> <reason> <give/remove> Start's a point vote");   
    
register_concmd("amx_showpoints","cmd_show_points",ADMIN_BAN," - <name> Show points of a player!");   
     
    
TeamInfo get_user_msgid("TeamInfo");   
    
SayText get_user_msgid("SayText");   
    
MaxSlots get_maxplayers();   
}   
public 
cmd_show_points(idlevelcid)   
{   
    if(!
cmd_access(idlevelcid2))   
        return 
PLUGIN_HANDLED;   
     
    new 
arg[32], pname[32]   
    
read_argv(1arg31)   
     
    new 
player cmd_target(idarg8)   
     
    
get_user_name(player,pname,31);   
     
    if(!
player)   
        return 
PLUGIN_HANDLED;   
     
    
client_print(id,print_console,"%s, tens %d skillpoints!",pname,points[player]);   
     
    return 
1;   
}   
public 
cmd_points(idlevelcid)   
{   
    if(!
cmd_access(idlevelcid2))   
        return 
PLUGIN_HANDLED;   
     
    new 
arg1[32], arg2[11], name[32]   
     
    
read_argv(1arg131)   
    
read_argv(2arg210)   
     
    new 
player cmd_target(idarg11)   
     
    if(!
player)   
        return 
PLUGIN_HANDLED;   
     
    
points[player] = str_to_num(arg2)   
     
    
get_user_name(playername31)   
    
client_print(idprint_console,"Successfully set %s skillpoints to %s!"namearg2)   
    
ColorChat(player,GREY,"Admin deu skillpoints a ^x04%s"arg2)   
     
    return 
PLUGIN_HANDLED;   
}   
public 
cmd_vote_points(idlevelcid)   
{   
    if(!
cmd_access(idlevelcid2))   
        return 
PLUGIN_HANDLED;   
     
    new 
arg1[32], arg2[132], arg3[17]   
     
    
read_argv(1arg131)   
    
read_argv(2arg2131)   
    
read_argv(3arg316)   
     
    if(!
equal(arg3"give") && !equal(arg3"remove"))   
    {   
        
client_print(idprint_chat"invalid mode. Valid modes are: give, remove.")   
        return 
PLUGIN_HANDLED;   
    }   
     
    new 
player cmd_target(idarg12)       
    
display_menu(playerarg2arg3)   
     
    return 
PLUGIN_HANDLED;   
}   
public 
save_points(id)   
{   
    new 
valut nvault_open("points")   
     
    if(
valut == INVALID_HANDLE)   
        
set_fail_state("nValut returned invalid handle")   
     
    new 
key[62], value[10], ip[33]   
     
    
//get_user_ip(id, ip, 32, 1);   
    
get_user_authid(idip32);   
     
    
format(key61,"%s-points"ip)   
    
format(value9,"%d"points[id])   
     
    
nvault_set(valutkeyvalue)   
    
nvault_close(valut)       
     
    return 
PLUGIN_CONTINUE;   
}   
public 
load_points(id)   
{   
    new 
valut nvault_open("points")   
     
    if(
valut == INVALID_HANDLE)   
        
set_fail_state("nValut returned invalid handle")   
     
    new 
key[100], ip[33]   
     
    
//get_user_ip(id, ip, 32, 1);   
    
get_user_authid(idip32);   
     
    
formatex(key99,"%s-points"ip)   
     
    
points[id] = nvault_get(valutkey)       
    
nvault_close(valut)   
     
    
points_in_name(id)   
     
    return 
PLUGIN_CONTINUE;   
}   
public 
show_points(id)   
{           
    
ColorChat(idGREEN"[DOT-MIX] Tu tens ^x03%d ^x01skillpoints!"points[id])   
}   
public 
give_time_points(id)   
{           
    if(
cs_get_user_team(id) != CS_TEAM_SPECTATOR)   
    {   
        
points[id] += get_pcvar_num(time_points)   
        
ColorChat(idGREEN"[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints por estares 1h no servidor.",get_pcvar_num(time_points))   
    }   
}   
public 
client_putinserver(id)   
{   
    
set_task(3600.0"give_time_points"id,_,_,"b")   
    
set_task(20.0"advertise"id)   
    
load_points(id)   
}   
public 
client_disconnect(id)   
{   
    
save_points(id)   
}   
public 
client_death(killervictimweaponhitplaceTK)   
{   
    if ( !
get_pcvar_num(pCvar_PluginState) ) 
        return 
PLUGIN_HANDLED 
         
    
if(TK)   
    {   
        
points[killer] -= get_pcvar_num(tk_points)   
        
ColorChat(killerGREEN"[DOT-MIX] Perdeste ^x03%d ^x01skillpoints!"get_pcvar_num(tk_points))   
         
        return 
PLUGIN_CONTINUE   
    
}   
     
    
points[killer] += get_pcvar_num(kill_points)   
    
points[victim] -= get_pcvar_num(death_points)   
    
ColorChat(killerGREEN"[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints!"get_pcvar_num(kill_points))   
    
ColorChat(victimGREEN"[DOT-MIX] Perdeste ^x03%d ^x01skillpoints!"get_pcvar_num(death_points))   
     
    if(
hitplace == HIT_HEAD)   
    {   
        
points[killer] += get_pcvar_num(head_points)   
        
ColorChat(killerGREEN"[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints!"get_pcvar_num(head_points))   
    }   
     
    if(
weapon == CSW_KNIFE)   
    {   
        
points[killer] += get_pcvar_num(knife_points)   
        
ColorChat(killerGREEN "[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints!"get_pcvar_num(knife_points))   
    }   
     
    if(
weapon == CSW_HEGRENADE)   
    {   
        
points[killer] += get_pcvar_num(nade_points)   
        
ColorChat(killerGREEN"[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints!"get_pcvar_num(nade_points))   
    }   
     
    if(
weapon == CSW_KNIFE && hitplace == HIT_HEAD)   
    {   
        
points[killer] += get_pcvar_num(skill_points)   
        
ColorChat(killerGREEN"[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints!"get_pcvar_num(skill_points))   
    }   
     
    return 
PLUGIN_CONTINUE;   
}   
public 
bomb_explode(planter)   
{   
    if ( !
get_pcvar_num(pCvar_PluginState) ) 
        return; 
         
    
points[planter] += get_pcvar_num(boom_points)   
    
ColorChat(planterGREEN"[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints!"get_pcvar_num(boom_points))   
}   
public 
bomb_defused(defuser)   
{   
    if ( !
get_pcvar_num(pCvar_PluginState) ) 
        return; 
         
    
points[defuser] += get_pcvar_num(def_points)   
    
ColorChat(defuserGREEN"[DOT-MIX] Ganhaste ^x03%d ^x01skillpoints!"get_pcvar_num(def_points))   
}   
public 
show_top15(id)   
{   
    new 
icount;   
    static 
sort[33][2], maxPlayers;   
     
    if(!
maxPlayersmaxPlayers get_maxplayers();   
     
    for(
i=1;i<=maxPlayers;i++)   
    {   
        
sort[count][0] = i;   
        
sort[count][1] = points[i];   
        
count++;   
    }   
     
    
SortCustom2D(sort,count,"stats_custom_compare");   
     
    new 
motd[1024], len       
     
    len 
format(motd1023,"<body bgcolor=#000000><font color=#FFB000><pre>")   
    
len += format(motd[len], 1023-len,"%2s %-22.22s %6s^n""#""Nick""SkillPoints")   
     
    static 
name[32]       
    for(new 
015a++)   
    {   
        
get_user_name(sort[a][0], name31)           
        
len += format(motd[len], 1023-len,"%2d %-22.22s %6d^n"1namesort[a][1])   
    }   
     
    
len += format(motd[len], 1023-len,"</body></font></pre>")   
    
show_motd(idmotd"SkillTOPs:")   
     
    return 
PLUGIN_CONTINUE;   
}   
public 
stats_custom_compare(elem1[],elem2[])   
{   
    if(
elem1[1] > elem2[1]) return -1;   
    else if(
elem1[1] < elem2[1]) return 1;   
         
    return 
0;   
}   
public 
display_menu(idreason[], mode[])   
{   
    new 
temp[56], name[32]   
     
    
get_user_name(idname31)   
     
    if(
equal(mode"give"))   
        
format(temp55"\rGive %s a point because %s?"namereason)   
    else if(
equal(mode"remove"))   
        
format(temp55"\rRemove a point from %s because %s?"namereason)   
     
    new 
menu menu_create(temp"menu_handler")   
     
    
menu_additem(menu"\wSim""1"0)   
    
menu_additem(menu"\wNao""2"0)   
     
    for(new 
1get_playersnum(); i++)   
        
menu_display(imenu0)   
     
    
set_task(30.0"finish_vote"idmode16)   
}   
public 
finish_vote(idmode[])   
{   
    
client_print(0print_chat"Voting over...")   
     
    if(
vote_choices[1] > vote_choices[2])   
    {   
        if(
equal(mode"give"))   
        {               
            
points[id]++   
             
            
client_print(0print_chat"Choise ^"yes^" has won the vote!")   
            
client_print(idprint_chat"You have been given a point")   
        }   
        else if(
equal(mode"remove"))   
        {   
            
points[id]--   
             
            
client_print(0print_chat"Choise ^"yes^" has won the vote!")   
            
client_print(idprint_chat"You have lost a point")   
        }   
    }   
     
    else if(
vote_choices[1] < vote_choices[2])   
    {   
        if(
equal(mode"give"))   
        {           
            
client_print(0print_chat"Choise ^"no^" has won the vote!")   
            
client_print(idprint_chat"Sorry, no point for you! =)")   
        }   
        else if(
equal(mode"remove"))   
        {           
            
client_print(0print_chat"Choise ^"no^" has won the vote!")   
            
client_print(idprint_chat"You where lucky and didn't lose any points")   
        }   
    }   
     
    for(new 
1get_playersnum(); i++)   
        
menu_cancel(i)   
     
    return 
PLUGIN_CONTINUE;   
}   
public 
menu_handler(idmenuitem)   
{   
    if (
item == MENU_EXIT)   
    {   
        
menu_destroy(menu)   
        return 
PLUGIN_HANDLED   
    
}   
     
    new 
data[6], name[32]   
    new 
accesscallback   
     
    menu_item_getinfo
(menuitemaccessdata5__callback)   
     
    new 
key str_to_num(data)   
    
get_user_name(idname31)   
     
    
vote_choices[key]++   
    
client_print(0print_chat,"%s voted on %s"namevote_choices[key] == "yes":"no")   
     
    
menu_cancel(id)   
     
    return 
PLUGIN_HANDLED;   
}   
public 
advertise(id)   
{   
    
set_hudmessage(0,25500.300.8516.06.0);   
    
show_hudmessage(id,"Bem vindo a DOT-MIX! Escreve .skill/!skill .top15.^nTu tens: %d skillpoints!",points[id])   
}   
stock ColorChat(idColor:type, const msg[], any:...)   
{   
    static 
message[256];   
    switch(
type)   
    {       
        case 
YELLOW:   
        {   
            
message[0] = 0x01;   
        }   
        case 
GREEN:   
        {   
            
message[0] = 0x04;   
        }   
        default: {   
            
message[0] = 0x03;   
        }   
    }   
    
vformat(message[1], 251msg4);   
    
message[192] = '^0';   
    new 
teamColorChangeindexMSG_Type;   
    if(!
id)   
    {   
        
index FindPlayer();   
        
MSG_Type MSG_ALL;   
        } else {   
        
MSG_Type MSG_ONE;   
        
index id;   
    }   
    
team get_user_team(index);    
    
ColorChange ColorSelection(indexMSG_Typetype);   
    
ShowColorMessage(indexMSG_Typemessage);   
    if(
ColorChange)   
    {   
        
Team_Info(indexMSG_TypeTeamName[team]);   
    }   
}   
stock ShowColorMessage(idtypemessage[])   
{   
    
message_begin(typeSayText_id);   
    
write_byte(id)     
    
write_string(message);   
    
message_end();    
}   
stock Team_Info(idtypeteam[])   
{   
    
message_begin(typeTeamInfo_id);   
    
write_byte(id);   
    
write_string(team);   
    
message_end();   
    return 
1;   
}   
stock 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;   
}   
stock FindPlayer()   
{   
    new 
= -1;   
    while(
<= MaxSlots)   
    {   
        if(
IsConnected[++i])   
        {   
            return 
i;   
        }   
    }   
    return -
1;   
}     

stock points_in_name(id)    
{    
    new 
szName[32]    
    
get_user_name(idszNamecharsmax(szName))    
    new 
iLen strlen(szName)    
     
    
/* Finds and removes "<####>" */    
    
new iPos iLen 1    
    
if( szName[iPos] == '>' )    
    {    
        for( new 
16i++)    
        {    
            if( 
szName[iPos i] == '<' )    
            {    
                
iLen iPos i    
                szName
[iLen] = '^0'    
                
break    
            }    
        }    
    }    
     
    
format(szName[iLen], charsmax(szName) - iLenszName[iLen-1] == ' ' "<%d>" " <%d>"points[id])    
    
set_user_info(id"name"szName)    

semanja is offline
 



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 07:50.


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