Thread: [Arreglo]XP MoD
View Single Post
TheShootSpeed
Member
Join Date: Nov 2011
Old 01-04-2012 , 16:20   Re: [Arreglo]XP MoD
#14

Quote:
Originally Posted by Chaato View Post
Bueno, despues de leer tu mensaje, supuse que querias que lo haga yo -.-'
Aqui te lo dejo, aunque tira 4 warning, que ni los vi, porque son de otra cosa no de este tema del say ^^.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#include <cstrike>
#include <colorchat>
#include <engine>
#include <hamsandwich>
#include <fun>
#include <fakemeta>



#define PLUGIN    "lalalla"
#define AUTHOR    "DarkGL"
#define VERSION    "0.1"

new player_xp[33];
new 
player_xp_all[33];
new 
level[33];

new 
rangi[][256]={
    
"Nivel 1",
    
"Nivel 2",
    
"Nivel 3",
    
"Nivel 4",
    
"Nivel 5",
    
"Nivel 6",
    
"Nivel 7",
    
"Nivel 8",
    
"Nivel 9",
    
"Nivel 10",
    
"Nivel 11",
    
"Nivel 12",
    
"Nivel 13",
    
"Nivel 14",
    
"Nivel 15"
}

new 
exp[]={
    
1000,
    
2000,
    
3000,
    
4000,
    
5000,
    
6000,
    
7000,
    
8000,
    
9000,
    
10000,
    
12000,
    
14000,
    
16000,
    
18000,
    
20000,
    
22000,
    
24000,
    
28000,
    
9999999999
}


new 
zapis;


new 
msgtext;

new 
pcvar_exp_round,pcvar_exp_kill_ct,pcvar_exp_kill_tt,pcvar_exp_level,pcvar_exp_hs,pcvar_hud;



public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("Koniec_Rundy"2"1=Round_End")
    
register_concmd("add_exp","addexp",ADMIN_BAN,"dodaje expa nick i ile")
    
register_event("DeathMsg""DeathMsg""a")
    
pcvar_exp_round register_cvar("bb_exp_round","50");
    
pcvar_exp_kill_ct register_cvar("bb_exp_kill_ct","20");
    
pcvar_exp_kill_tt register_cvar("bb_exp_kill_tt","10");
    
pcvar_exp_level register_cvar("bb_exp_level","40");
    
pcvar_exp_hs register_cvar("bb_exp_hs","5");
    
pcvar_hud register_cvar("bb_hud","0");
    
zapis nvault_open("xpd")
    
register_event("ResetHUD","ShowHUD""b");
    
msgtext get_user_msgid("StatusText");
    
register_clcmd("say","sayhandle");
    
    
}

public 
plugin_precache(){
    
precache_sound("darkgl/bb/gained_level.wav");
}

public 
plugin_end(){
    
nvault_close(zapis);
}
public 
sayhandleiPlayer )
{
    new 
sz_MessageWrited 192 ]
    
    
// Guardamos lo que escribió el usuario.
    
read_args sz_MessageWritedcharsmax sz_MessageWrited ) )
    
    
// Si no escribió nada, no mostramos nada.
    
if ( equal sz_MessageWrited"" ) )
    {
        return 
PLUGIN_HANDLED_MAIN
    
}
    
    new 
sz_UserName 32 ]
    
    
// Obtenemos el nombre del usuario.
    
get_user_name iPlayersz_UserNamecharsmax sz_UserName ) )
    
    
// Si el nivel es menor que 0 o mayor que 14 no mostramos tag.
    // Puesto que solo hay 15 tags disponibles.
    
if ( level iPlayer ] < || level iPlayer ] > 14 )
    {
        switch( 
cs_get_user_teamiPlayer ) )
        {
            case 
CS_TEAM_SPECTATORColorChat0GREY"%s^1: %s"sz_UserNamesz_MessageWrited )
            case 
CS_TEAM_UNASSIGNEDColorChat0GREY"%s^1: %s"sz_UserNamesz_MessageWrited )
            case 
CS_TEAM_CTColorChat0BLUE"%s^1: %s"sz_UserNamesz_MessageWrited )
            case 
CS_TEAM_TColorChat0RED"%s^1: %s"sz_UserNamesz_MessageWrited )
        }
    }
    
    else
    {
        switch( 
cs_get_user_teamiPlayer ) )
        {
            case 
CS_TEAM_SPECTATORColorChat0GREY"^4[%s]^3 %s^1: %s"rangi level iPlayer ] ], sz_UserNamesz_MessageWrited )
            case 
CS_TEAM_UNASSIGNEDColorChat0GREY"^4[%s]^3 %s^1: %s"rangi level iPlayer ] ], sz_UserNamesz_MessageWrited )
            case 
CS_TEAM_CTColorChat0BLUE"^4[%s]^3 %s^1: %s"rangi level iPlayer ] ], sz_UserNamesz_MessageWrited )
            case 
CS_TEAM_TColorChat0RED"^4[%s]^3 %s^1: %s"rangi level iPlayer ] ], sz_UserNamesz_MessageWrited )
        }
    }  
    
    return 
PLUGIN_HANDLED_MAIN
}





public 
Koniec_Rundy(){
    for(new 
1;i<33;i++){
        if(
is_user_alive(i) && cs_get_user_team(i) == CS_TEAM_CT){
            
DajExp(i,get_pcvar_num(pcvar_exp_round));
            
ColorChat(i,GREEN,"^x03 Ganaste %d por sobrevivir la ronda",get_pcvar_num(pcvar_exp_round));
            
        }
    }
}

public 
addexp(idlevelcid){
    if(!
cmd_access(idlevelcid3)){
        return 
PLUGIN_HANDLED;
    }
    new 
arg1[33];
    new 
arg2[10];
    
read_argv(1,arg1,32);
    
read_argv(2,arg2,9);
    new 
player cmd_target(idarg10);
    
remove_quotes(arg2);
    new 
exp str_to_num(arg2);
    if(
exp != && exp ){
        
OdejmijExp(player,exp);
    }
    else if(
exp != && exp ){
        
DajExp(player,exp);
    }
    return 
PLUGIN_HANDLED;
}

public 
OdejmijExp(id,ile){
    
player_xp[id]-=ile;
    
player_xp_all[id]-=ile;
    
level[id]=0;
    while(
true){
        if(
player_xp_all[id] >= exp[level[id]]){
            
level[id]++;
            
//set_hudmessage(random_num(0,255), random_num(0,255),random_num(0,255), -1.0, -1.0, 0, 6.0, 5.0, 0.0, 0.0, -1)
            //show_hudmessage(id,"Awansowales na kolejny level (%s)",rangi[level[id]]);
            //ColorChat(0,GREEN,"^x03 Awansowal do rangi ^x01 %s gratki :D",rangi[level[id]]);
        
}
        else
        {
            break;
        }
    }
}

public 
DajExp(id,ile){
    
player_xp[id]+=ile;
    
player_xp_all[id]+=ile;
    new 
name[64];
    
get_user_name(id,name,63);
    while(
true){
        if(
player_xp_all[id] >= exp[level[id]] && sizeof(rangi) > level[id]){
            
level[id]++;
            
ColorChat(0,GREEN,"[JB] ^x03%s subio a ^x01 %s ^x03",name,rangi[level[id]]);
            
emit_sound(id,CHAN_VOICE,"darkgl/bb/gained_level.wav"VOL_NORMATTN_NORM0PITCH_NORM)
        }
        else
        {
            break;
        }
    }
}


public 
client_connect(id){
    
    
player_xp[id] = 0;
    
player_xp_all[id] = 0;
    
wczytaj_exp(id);
}

public 
client_disconnect(id){
    
zapisz_exp(id);
}

public 
wczytaj_exp(id){
    new 
vaultkey[64],vaultdata[512];
    
    new 
authid[64];
    
get_user_authid(id,authid,63);
    
format(vaultkey,63,"%s",authid);
    
nvault_get(zapis,vaultkey,vaultdata,511);
    
replace_all(vaultdata,256,"#"," ");
    new 
jeden[100],dwa[100]
    
parse(vaultdata,jeden,99,dwa,99)
    
player_xp[id] = str_to_num(jeden);
    
player_xp_all[id] = str_to_num(dwa);
    
    while(
true){
        if(
player_xp_all[id] >= exp[level[id]] && sizeof(rangi) > level[id]){
            
level[id]++;
        }
        else
        {
            break;
        }
    }
}

public 
zapisz_exp(id){
    new 
vaultkey[64],vaultdata[512];
    
    new 
authid[64];
    
get_user_authid(id,authid,63);
    
format(vaultkey,63,"%s",authid);
    
format(vaultdata,511,"%d#%d",player_xp[id],player_xp_all[id]);
    
nvault_set(zapis,vaultkey,vaultdata)
}

public 
ShowHUD(id)  { 
    if(
is_user_alive(id)){
        new 
HUD[128];
        
        
format(HUD127,"[%s] Exp actual: %d | Exp todal: %d",rangi[level[id]],player_xp[id],player_xp_all[id]);
        if(
get_pcvar_num(pcvar_hud) == ){
            
message_begin(MSG_ONEmsgtext, {0,0,0}, id);
            
write_byte(0);
            
write_string(HUD); 
            
message_end();
            return 
PLUGIN_CONTINUE;
        }
        else
        {
            
set_hudmessage(255000.020.6306.015.0)
            
show_hudmessage(id"%s",HUD)
        }
    }
    return 
PLUGIN_CONTINUE;
}



public 
DeathMsg()
{
    new 
kid read_data(1)    //zabojca
    
    
new vid read_data(2)    // ofiara
    
    
new hs read_data(3)    // ofiara
    
    
if(cs_get_user_team(kid)==CS_TEAM_CT && cs_get_user_team(vid)==CS_TEAM_T){
        
DajExp(kid,get_pcvar_num(pcvar_exp_kill_tt));
        
        new 
name[64];
        
get_user_name(vid,name,charsmax(name));
        
ColorChat(kid,TEAM_COLOR,"Ganaste %d por matar a %s",get_pcvar_num(pcvar_exp_kill_tt),name)
        if(
hs == 1){
            
DajExp(kid,get_pcvar_num(pcvar_exp_hs));
            
ColorChat(kid,TEAM_COLOR,"Ganaste %d por hacer hs",get_pcvar_num(pcvar_exp_hs))
        }
        
    }    
    else if(
cs_get_user_team(kid)==CS_TEAM_T && cs_get_user_team(vid)==CS_TEAM_CT){
        
DajExp(kid,get_pcvar_num(pcvar_exp_kill_ct));
        new 
name[64];
        
get_user_name(vid,name,charsmax(name));
        
ColorChat(kid,TEAM_COLOR,"Ganaste %d por matar a %s",get_pcvar_num(pcvar_exp_kill_ct),name)
        if(
hs == 1){
            
DajExp(kid,get_pcvar_num(pcvar_exp_hs));
            
ColorChat(kid,TEAM_COLOR,"Ganaste %d por hacer hs",get_pcvar_num(pcvar_exp_hs))
        }
    }    

Los warnings, son
* while(true){ ( Son 3 de esos, no se tiene sentido eso significaria "Mientras(verdadero)" osea, no tiene ningun sentido "
* Y el otro es que nunca usaste "pcvar_exp_level"

;).
Ya tengo el plugin corriendo perfectamente solo que una cosa que el admin chat coloro y este plugin no son eso porque salen 2 mensajes en vez de 1 sale:

[Lv1 n00b] TheShootSpeed: Hola [En color normal]
y otro
TheShootSpeed: Hola [En verde]

Podriais hacerme para que los admines le salgan en verde lo he intentado pero nada :S

EDIT: La unica solucion que le vi fue unir los 2 plugin pero no funca tampoco :S le dejo el amx Color msa:

PHP Code:
 #include <amxmodx>
#include <amxmisc>

#define PLUGIN         "Admin Chat Colors"
#define VERSION     "2.0"
#define AUTHOR         "Arion"

#define ACCESS_LEVEL    ADMIN_CHAT
#define ADMIN_LISTEN    ADMIN_BAN

new message[192]
new 
sayText
new teamInfo
new maxPlayers

new g_MessageColor
new g_NameColor
new g_AdminListen

new strName[191]
new 
strText[191]
new 
alive[11]

public 
plugin_init()
{
    
register_plugin (PLUGINVERSIONAUTHOR)
    
    
g_MessageColor register_cvar ("amx_color""2"// Message colors: [1] Default Yellow, [2] Green, [3] White, [4] Blue, [5] Red

    
g_NameColor register_cvar ("amx_namecolor""6"// Name colors: [1] Default Yellow, [2] Green, [3] White, [4] Blue, [5] Red, [6] Team-color
    
    
g_AdminListen register_cvar ("amx_listen""0"// Set whether admins see or not all messages (Alive, dead and team-only)
    
    
    
sayText get_user_msgid ("SayText")
    
teamInfo get_user_msgid ("TeamInfo")
    
maxPlayers get_maxplayers()
    
    
    
register_message (sayText"avoid_duplicated")
    
    
register_clcmd ("amx_color""set_color"ACCESS_LEVEL"<color>")
    
register_clcmd ("amx_namecolor""set_name_color"ACCESS_LEVEL"<color>")
    
register_clcmd ("amx_listen""set_listen"ACCESS_LEVEL"<1 | 0>")
    
    
register_clcmd ("say""hook_say")
    
register_clcmd ("say_team""hook_teamsay")
}


public 
avoid_duplicated (msgIdmsgDestreceiver)
{
    return 
PLUGIN_HANDLED
}


public 
hook_say(id)
{
    
read_args (message191)
    
remove_quotes (message)
    
    
replace_all(message,63,"%"," ")
    
    if (
message[0] == '@' || message[0] == '/' || message[0] == '!' || equal (message"")) // Ignores Admin Hud Messages, Admin Slash commands, 
                                                   // Gungame commands and empty messages
        
return PLUGIN_CONTINUE

        
    
new name[32]
    
get_user_name (idname31)
    
    new 
bool:admin false
    
    
if (get_user_flags(id) & ACCESS_LEVEL)
        
admin true
        
    
    
new isAlive
    
    
if (is_user_alive (id))
        {
            
isAlive 1
            alive 
"^x01"
        
}
    else
        {
            
isAlive 0
            alive 
"^x01*DEAD* "
        
}
    
    static 
color[10]
    

    
    if (
admin)
        {
            
// Name
            
switch (get_pcvar_num (g_NameColor))
                {
                    case 
1:
                        
format (strName191"%s%s"alivename)

                    case 
2:
                        
format (strName191"%s^x04%s"alivename)
                        
                    case 
3:
                        {
                            
color "SPECTATOR"
                            
format (strName191"%s^x03%s"alivename)
                        }
                        
                    case 
4:
                        {
                            
color "CT"
                            
format (strName191"%s^x03%s"alivename)
                        }

                    case 
5:
                        {
                            
color "TERRORIST"
                            
format (strName191"%s^x03%s"alivename)
                        }
                    
                    case 
6:
                        {
                            
get_user_team (idcolor9)
                                
                            
format (strName191"%s^x03%s"alivename)
                        }
                }
            
            
            
// Message
            
switch (get_pcvar_num (g_MessageColor))
                {
                    case 
1:    // Yellow
                        
format (strText191"%s"message)
                        
                    case 
2:    // Green
                        
format (strText191"^x04%s"message)
                        
                    case 
3:    // White
                        
{
                            
copy (color9"SPECTATOR")
                            
format (strText191"^x03%s"message)
                        }

                    case 
4:    // Blue
                        
{
                            
copy (color9"CT")
                            
format (strText191"^x03%s"message)
                        }
                        
                    case 
5:    // Red
                        
{
                            
copy (color9"TERRORIST")
                            
format (strText191"^x03%s"message)
                        }
                }
        }
    
    else     
// Player is not admin. Team-color name : Yellow message
        
{
            
get_user_team (idcolor9)
            
            
format (strName191"%s^x03%s"alivename)
            
            
format (strText191"%s"message)
        }

    
format (message191"%s^x01 :  %s"strNamestrText)
            
    
sendMessage (colorisAlive)    // Sends the colored message
    
    
return PLUGIN_CONTINUE
}


public 
hook_teamsay(id)
{
    new 
playerTeam get_user_team(id)
    new 
playerTeamName[19]
    
    switch (
playerTeam// Team names which appear on team-only messages
        
{
            case 
1:
                
copy (playerTeamName11"Terrorists")
                
            case 
2:
                
copy (playerTeamName18"Counter-Terrorists")
                
            default:
                
copy (playerTeamName9"Spectator")
        }
        
    
read_args (message191)
    
remove_quotes (message)
    
    
replace_all(message,63,"%"," ")
    
    if (
message[0] == '@' || message[0] == '/' || message[0] == '!' || equal (message"")) // Ignores Admin Hud Messages, Admin Slash commands, 
                                                   // Gungame commands and empty messages
        
return PLUGIN_CONTINUE

        
    
new name[32]
    
get_user_name (idname31)
    
    new 
bool:admin false
    
    
if (get_user_flags(id) & ACCESS_LEVEL)
        
admin true
        
    
    
new isAlive
    
    
if (is_user_alive (id))
        {
            
isAlive 1
            alive 
"^x01"
        
}
    else
        {
            
isAlive 0
            alive 
"^x01*DEAD* "
        
}
    
    static 
color[10]
    

    
    if (
admin)
        {
            
// Name
            
switch (get_pcvar_num (g_NameColor))
                {
                    case 
1:
                        
format (strName191"%s(%s) %s"aliveplayerTeamNamename)

                    case 
2:
                        
format (strName191"%s(%s) ^x04%s"aliveplayerTeamNamename)
                        
                    case 
3:
                        {
                            
color "SPECTATOR"
                            
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
                        }
                        
                    case 
4:
                        {
                            
color "CT"
                            
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
                        }

                    case 
5:
                        {
                            
color "TERRORIST"
                            
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
                        }
                    
                    case 
6:
                        {
                            
get_user_team (idcolor9)
                                
                            
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
                        }
                }
            
            
            
// Message
            
switch (get_pcvar_num (g_MessageColor))
                {
                    case 
1:    // Yellow
                        
format (strText191"%s"message)
                        
                    case 
2:    // Green
                        
format (strText191"^x04%s"message)
                        
                    case 
3:    // White
                        
{
                            
copy (color9"SPECTATOR")
                            
format (strText191"^x03%s"message)
                        }

                    case 
4:    // Blue
                        
{
                            
copy (color9"CT")
                            
format (strText191"^x03%s"message)
                        }
                        
                    case 
5:    // Red
                        
{
                            
copy (color9"TERRORIST")
                            
format (strText191"^x03%s"message)
                        }
                }
        }
    
    else     
// Player is not admin. Team-color name : Yellow message
        
{
            
get_user_team (idcolor9)
            
            
format (strName191"%s(%s) ^x03%s"aliveplayerTeamNamename)
            
            
format (strText191"%s"message)
        }
    
    
format (message191"%s ^x01:  %s"strNamestrText)
    
    
sendTeamMessage (colorisAliveplayerTeam)    // Sends the colored message
    
    
return PLUGIN_CONTINUE    
}


public 
set_color (idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
        
    
new arg[1], newColor
    read_argv 
(1arg1)
    
    
newColor str_to_num (arg)
    
    if (
newColor >= && newColor <= 5)
        {
            
set_cvar_num ("amx_color"newColor)
            
set_pcvar_num (g_MessageColornewColor)
    
            if (
get_pcvar_num (g_NameColor) != &&
                   ((
newColor == &&  get_pcvar_num (g_NameColor) != 3)
                 || (
newColor == &&  get_pcvar_num (g_NameColor) != 4)
                 || (
newColor == &&  get_pcvar_num (g_NameColor) != 5)))
                {
                    
set_cvar_num ("amx_namecolor"2)
                    
set_pcvar_num (g_NameColor2)
                }
        }
        
    return 
PLUGIN_HANDLED
}


public 
set_name_color (idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
        
    
new arg[1], newColor
    read_argv 
(1arg1)
    
    
newColor str_to_num (arg)
    
    if (
newColor >= && newColor <= 6)
        {
            
set_cvar_num ("amx_namecolor"newColor)
            
set_pcvar_num (g_NameColornewColor)
            
            if ((
get_pcvar_num (g_MessageColor) != 1
                
&& ((newColor == &&  get_pcvar_num (g_MessageColor) != 3)
                 || (
newColor == &&  get_pcvar_num (g_MessageColor) != 4)
                 || (
newColor == &&  get_pcvar_num (g_MessageColor) != 5)))
                 || 
get_pcvar_num (g_NameColor) == 6)
                {
                    
set_cvar_num ("amx_color"2)
                    
set_pcvar_num (g_MessageColor2)
                }
        }
    
    return 
PLUGIN_HANDLED
}


public 
set_listen (idlevelcid)
{
    if (!
cmd_access(idlevelcid2))
        return 
PLUGIN_HANDLED
        
    
new arg[1], newListen
    read_argv
(1arg1)
    
    
newListen str_to_num (arg)
    
    
set_cvar_num ("amx_listen"newListen)
    
set_pcvar_num (g_AdminListennewListen)
    
    return 
PLUGIN_HANDLED
}


public 
sendMessage (color[], alive)
{
    new 
teamName[10]
    
    for (new 
player 1player maxPlayersplayer++)
        {
            if (!
is_user_connected(player))
                continue

            if (
alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
                {
                    
get_user_team (playerteamName9)    // Stores user's team name to change back after sending the message
                    
                    
changeTeamInfo (playercolor)        // Changes user's team according to color choosen
                    
                    
writeMessage (playermessage)        // Writes the message on player's chat
                    
                    
changeTeamInfo (playerteamName)    // Changes user's team back to original
                
}
        }
}


public 
sendTeamMessage (color[], aliveplayerTeam)
{
    new 
teamName[10]
    
    for (new 
player 1player maxPlayersplayer++)
        {
            if (!
is_user_connected(player))
                continue

            if (
get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
                {
                    if (
alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN)
                        {
                            
get_user_team (playerteamName9)    // Stores user's team name to change back after sending the message
                            
                            
changeTeamInfo (playercolor)        // Changes user's team according to color choosen
                            
                            
writeMessage (playermessage)        // Writes the message on player's chat
                            
                            
changeTeamInfo (playerteamName)    // Changes user's team back to original
                        
}
                }
        }
}


public 
changeTeamInfo (playerteam[])
{
    
message_begin (MSG_ONEteamInfo_player)    // Tells to to modify teamInfo (Which is responsable for which time player is)
    
write_byte (player)                // Write byte needed
    
write_string (team)                // Changes player's team
    
message_end()                    // Also Needed
}


public 
writeMessage (playermessage[])
{
    
message_begin (MSG_ONEsayText, {000}, player)    // Tells to modify sayText (Which is responsable for writing colored messages)
    
write_byte (player)                    // Write byte needed
    
write_string (message)                    // Effectively write the message, finally, afterall
    
message_end ()                        // Needed as always
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/ 

Last edited by TheShootSpeed; 01-04-2012 at 16:22.
TheShootSpeed is offline