Raised This Month: $ Target: $400
 0% 

Emitting sounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 11-29-2009 , 17:28   Emitting sounds
Reply With Quote #1

Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault>
#define MAXCLASSES 6
new const CLASSES[MAXCLASSES][] = {
    "None",
    "Paladin",
    "Barbarian",
    "Sorceress",
    "Assassin",
    "Amazon"
}
new const LEVELS[15] = {
        0,
    50,
    150,
    300,
    400,
    500,
    750,
    1070,
    1460,
    1910,
    2410,
    3010,
    3710,
    4560,
    5560

}
new PlayerXP[33],PlayerLevel[33],PlayerClass[33]
new XP_Kill,XP_Knife,XP_Hs,SaveXP,g_vault
public plugin_init()
{
    register_plugin("DMod", "1.0", "MALEC321")
 
    register_event("DeathMsg", "eDeath", "a") 
    register_concmd( "amx_takexp", "cmd_take_exp", ADMIN_KICK, "<target> <amount>" ); 
    register_concmd( "amx_givexp", "cmd_give_exp", ADMIN_KICK, "<target> <amount>" );
 

    SaveXP = register_cvar("SaveXP","1")
    XP_Kill=register_cvar("XP_per_kill", "10")
    XP_Hs=register_cvar("XP_hs_bonus","10")
    XP_Knife=register_cvar("XP_knife_bonus","15")
    g_vault = nvault_open("dmod")
 
    register_clcmd("say /dclass", "ChangeClass")
    register_clcmd("say_team /dclass", "ChangeClass")
    register_clcmd("say /myxp", "ShowHud")
    register_clcmd("say_team /myxp", "ShowHud")
}
public eDeath(id) 
{
    new headshot,attacker = read_data( 1 ) 
    new clip, ammo, weapon = get_user_weapon(id,clip,ammo);
 
    PlayerXP[attacker] += get_pcvar_num(XP_Kill)
 
    if(headshot)
    PlayerXP[attacker] += get_pcvar_num(XP_Hs)
 
    if(weapon == CSW_KNIFE)
    PlayerXP[attacker] += get_pcvar_num(XP_Knife)
 
 
    while(PlayerXP[attacker] >= LEVELS[PlayerLevel[attacker]])
    {
      client_print(attacker, print_chat, "[DIABLO] Congratulations! You are a level %i %s!",PlayerLevel[id],CLASSES[PlayerClass[id]])
      PlayerLevel[attacker] += 1
    }
    ShowHud(attacker)
    SaveData(attacker)
}
public ShowHud(id)
{
    set_hudmessage(255, 0, 0, 0.75, 0.01, 0, 6.0, 15.0)
    show_hudmessage(id, "Level: %i^nXP: %i^nClass: %s",PlayerLevel[id],PlayerXP[id],CLASSES[PlayerClass[id]])
}
public ChangeClass(id)
{
    new menu = menu_create("Class Menu" , "Class_Handle");
    menu_additem(menu ,"Paladin", "1" , 0);
    menu_additem(menu ,"Barbarian", "2" , 0);
    menu_additem(menu ,"Sorceress", "3" , 0);
    menu_additem(menu ,"Assassin", "4" , 0);
    menu_additem(menu ,"Amazon", "5", 0);
 
    menu_setprop(menu , MPROP_EXIT , MEXIT_ALL);
 
    menu_display(id , menu , 0);
 
    return PLUGIN_CONTINUE;
}

public cmd_givexp( id, level,cid )
{
     if( ! cmd_access ( id, level, cid, 3 ) )
         return PLUGIN_HANDLED;
 
     new target[32], amount[21], reason[21];
 
     read_argv( 1, target, 31 );
     read_argv(2, amount, 20 );
     read_argv( 3, reason, 20 );
 
     new player = cmd_target( id, target, 8 );
 
     if( ! player ) 
         return PLUGIN_HANDLED;
 
     new admin_name[32], player_name[32];
     get_user_name( id, admin_name, 31 );
     get_user_name( player, player_name, 31 );
 
     new expnum = str_to_num( amount );
 
     PlayerXP[player] += expnum;
 
     switch( get_cvar_num ( "amx_show_activity" ) )
     {
          case 1: client_print( 0, print_chat, "ADMIN: gave %i points for %s.", expnum, player_name );
          case 2: client_print( 0, print_chat, "ADMIN %s: gave %i points for %s.", admin_name, expnum, player_name );
     }
 
     client_print( player, print_chat, "[DIABLO] You received %i points. (Total: %d)", expnum, PlayerXP[player] );
 
     SaveData( id )
 
     return PLUGIN_CONTINUE;
}
 
public cmd_takexp( id, level,cid )
{
    if( ! cmd_access ( id, level, cid, 3 ) )
        return PLUGIN_HANDLED;
 
    new target[32], amount[21], reason[21];
 
    read_argv( 1, target, 31 );
    read_argv( 2, amount, 20 );
    read_argv( 3, reason, 20 );
 
    new player = cmd_target( id, target, 8 );
 
    if( ! player ) 
        return PLUGIN_HANDLED;
 
    new admin_name[32], player_name[32];
    get_user_name( id, admin_name, 31 );
    get_user_name( player, player_name, 31 );
 
    new expnum = str_to_num( amount );
 
    PlayerXP[player] -= expnum;
 
    switch(get_cvar_num("amx_show_activity"))
    {
          case 1: client_print( 0, print_chat, "ADMIN: took %i points from %s.", expnum, player_name );
          case 2: client_print( 0, print_chat, "ADMIN %s: took %i points from %s.", admin_name, expnum, player_name );
     }
     client_print( player, print_chat, "You received %i points. (Total: %d)", expnum, PlayerXP[player] );
     SaveData( id )
     return PLUGIN_CONTINUE;
}

public Class_Handle(id , menu , item) 
{
    if(item == MENU_EXIT) 
    {
 
        menu_destroy(menu);
 
    }
 
    new szCommand[6] , szName[64];
    new access , callback;
 
    menu_item_getinfo(menu , item , access , szCommand , 5 , szName , 63 , callback);
 
    new i = str_to_num(szCommand)
    if(PlayerClass[id] != i)
    {
        PlayerClass[id] = i
        client_print(id,print_chat,"[DIABLO] You are now a %s",CLASSES[i])
    }
    else
    {
        client_print(id,print_chat,"[DIABLO] You are alredy a %s",CLASSES[i])
    }
 
    menu_destroy(menu);
    return PLUGIN_CONTINUE
}
public client_connect(id)
{
    if(get_pcvar_num(SaveXP) == 1)
    {
 
        LoadData(id)
    }
}
public client_disconnect(id)
{
    if(get_pcvar_num(SaveXP) == 1)
    {
 
        SaveData(id)
    }
    PlayerXP[id] = 0
    PlayerLevel[id] = 0
    PlayerClass[id] = 0
}
public SaveData(id)
{
    new AuthID[35]
    get_user_authid(id,AuthID,34)
 
    new vaultkey[64],vaultdata[256]
    format(vaultkey,63,"%s-Mod",AuthID)
    format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
    nvault_set(g_vault,vaultkey,vaultdata)
    return PLUGIN_CONTINUE
}
public LoadData(id)
{
    new AuthID[35]
    get_user_authid(id,AuthID,34)
 
    new vaultkey[64],vaultdata[256]
    format(vaultkey,63,"%s-Mod",AuthID)
    format(vaultdata,255,"%i#%i#",PlayerXP[id],PlayerLevel[id])
    nvault_get(g_vault,vaultkey,vaultdata,255)
 
    replace_all(vaultdata, 255, "#", " ")
 
    new playerxp[32], playerlevel[32]
 
    parse(vaultdata, playerxp, 31, playerlevel, 31)
 
    PlayerXP[id] = str_to_num(playerxp)
    PlayerLevel[id] = str_to_num(playerlevel)
 
    return PLUGIN_CONTINUE
}
How can you make it emit a .wav sound everytime you level?
malec321 is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 11-29-2009 , 19:06   Re: Emitting sounds
Reply With Quote #2

Precache the sound and play it after
Code:
client_print(attacker, print_chat, "[DIABLO] Congratulations! You are a level %i %s!",PlayerLevel[id],CLASSES[PlayerClass[id]])
using emit_sound?
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 11-29-2009 , 19:27   Re: Emitting sounds
Reply With Quote #3

client_print(attacker, print_chat, "[DIABLO] Congratulations! You are a level %i %s!",PlayerLevel[id],CLASSES[PlayerClass[id]])
precache_sound("levelup.wav")

Corrrect?
malec321 is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 11-29-2009 , 19:30   Re: Emitting sounds
Reply With Quote #4

No, precache in plugin_precache and then use emit_sound to emit the sound there.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
malec321
Senior Member
Join Date: May 2009
Location: Los Angeles
Old 11-29-2009 , 19:35   Re: Emitting sounds
Reply With Quote #5

lol i fail i shuda known! =)
malec321 is offline
Reply


Thread Tools
Display Modes

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 13:40.


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