AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Sounds + Menus (https://forums.alliedmods.net/showthread.php?t=25966)

Werewolf 03-24-2006 17:12

Sounds + Menus
 
Hello. I'm back :P
I still got some problems with my mod.
Reasons: when I emit sounds it continue to play until you disconnect + lack of ideas.

I tried both emit and the spk etc.
They don't play the sound or they play it until you disconnect, and that is very irritating with my current sounds + when it is a level up it should play a sound but it wont work.

Here is the codes I used for them. + No errors while compiling.
Code:
emit_sound(id, CHAN_AUTO, "mythmod/skilluse.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) <- This one plays until you disconnect. //Other at level up     if(g_PlayerXP[attacker] >= LEVELS[g_PlayerLevel[attacker]])       {           g_PlayerLevel[attacker] += 1           client_print(attacker,print_chat,"[Mythology Mod] Congratulations! You are now level %i!", g_PlayerLevel[attacker])           SaveXP(attacker)           ShowHUD(attacker)           emit_sound(id, CHAN_AUTO, "mythmod/levelup.wav", 1.0, ATTN_NORM, 0, PITCH_NORM) <- This one doesn't work.     }

Here is my second problem on the mod.
This is a menu that doesn't work.
Code:
public DoShopMenu(id, key)     {     new usermoney = cs_get_user_money(id)     new userhealth = get_user_health(id)     switch(key)     {         case 0:         {             if(usermoney < EXTRA_HP_COST)             {             return PLUGIN_HANDLED             }             set_user_health(id, userhealth + EXTRA_HP_AMOUNT)             cs_set_user_money(id, usermoney - EXTRA_HP_COST)             return PLUGIN_CONTINUE         }         case 1:         {             if(usermoney < EXTRA_XP_COST)             { return PLUGIN_HANDLED             }             g_PlayerXP[id] += EXTRA_XP_AMOUNT             cs_set_user_money(id, usermoney - EXTRA_XP_COST)             return PLUGIN_CONTINUE         }         case 2:         {             if(usermoney < EXTRA_SPEED_COST)             {             return PLUGIN_HANDLED             }             set_user_maxspeed(id, EXTRA_SPEED.0)             client_cmd(id, "cl_forwardspeed EXTRA_SPEED")             client_cmd(id, "cl_backspeed EXTRA_SPEED")             client_cmd(id, "cl_sidespeed EXTRA_SPEED")             cs_set_user_money(id, usermoney - EXTRA_SPEED_COST)             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE }

On this menu I don't really know what to do so please help me.

akysiev 03-24-2006 20:37

What is wrapping the emit_sound? Check to see if it is looping via constant function calls such as by set_task.

What exactly is wrong with the menu? Does it not display or does some part of it not function?

Freecode 03-24-2006 21:40

Code:
set_user_maxspeed(id, EXTRA_SPEED.0)             client_cmd(id, "cl_forwardspeed EXTRA_SPEED")             client_cmd(id, "cl_backspeed EXTRA_SPEED")             client_cmd(id, "cl_sidespeed EXTRA_SPEED")

First off. LMAO
Second.
Code:
set_user_maxspeed(id, EXTRA_SPEED.0)
change to
Code:
set_user_maxspeed(id, EXTRA_SPEED * 1.0)
Third.
Code:
client_cmd(id, "cl_forwardspeed EXTRA_SPEED")
change to
Code:
client_cmd(id, "cl_forwardspeed %d", EXTRA_SPEED)
and so for the others

Werewolf 03-25-2006 11:21

It wont remove the money and it doesn't add xp etc.

Freecode 03-25-2006 17:26

Code:
public DoShopMenu(id, key) {     new usermoney = cs_get_user_money(id)     new userhealth = get_user_health(id)     switch(key)     {         case 0:         {             if(usermoney < EXTRA_HP_COST)             {                 return PLUGIN_HANDLED             }                         set_user_health(id, userhealth + EXTRA_HP_AMOUNT)             cs_set_user_money(id, usermoney - EXTRA_HP_COST)             return PLUGIN_CONTINUE         }         case 1:         {             if(usermoney < EXTRA_XP_COST)             {                 return PLUGIN_HANDLED             }                         g_PlayerXP[id] += EXTRA_XP_AMOUNT             cs_set_user_money(id, usermoney - EXTRA_XP_COST)             return PLUGIN_CONTINUE         }         case 2:         {             if(usermoney < EXTRA_SPEED_COST)             {                 return PLUGIN_HANDLED             }                         set_user_maxspeed(id, EXTRA_SPEED * 1.0)             client_cmd(id, "cl_forwardspeed %d",EXTRA_SPEED)             client_cmd(id, "cl_backspeed %d",EXTRA_SPEED)             client_cmd(id, "cl_sidespeed %d",EXTRA_SPEED)             cs_set_user_money(id, usermoney - EXTRA_SPEED_COST)             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE }

Werewolf 03-27-2006 09:35

OK. Here is the code you posted:
Code:
public DoShopMenu(id, key) {     new usermoney = cs_get_user_money(id)     new userhealth = get_user_health(id)     switch(key)     {         case 0:         {             if(usermoney < EXTRA_HP_COST)             {                 return PLUGIN_HANDLED             }                           set_user_health(id, userhealth + EXTRA_HP_AMOUNT)             cs_set_user_money(id, usermoney - EXTRA_HP_COST)             return PLUGIN_CONTINUE         }         case 1:         {             if(usermoney < EXTRA_XP_COST)             {                 return PLUGIN_HANDLED             }                           g_PlayerXP[id] += EXTRA_XP_AMOUNT             cs_set_user_money(id, usermoney - EXTRA_XP_COST)             return PLUGIN_CONTINUE         }         case 2:         {             if(usermoney < EXTRA_SPEED_COST)             {                 return PLUGIN_HANDLED             }                           set_user_maxspeed(id, EXTRA_SPEED * 1.0)             client_cmd(id, "cl_forwardspeed %d",EXTRA_SPEED)             client_cmd(id, "cl_backspeed %d",EXTRA_SPEED)             client_cmd(id, "cl_sidespeed %d",EXTRA_SPEED)             cs_set_user_money(id, usermoney - EXTRA_SPEED_COST)             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE }

Here is my fixed code:
Code:
public DoShopMenu(id, key) {     new usermoney = cs_get_user_money(id)     new userhealth = get_user_health(id)     switch(key)     {         case 0:         {             if(usermoney < EXTRA_HP_COST)             {                 return PLUGIN_HANDLED             }             set_user_health(id, userhealth + EXTRA_HP_AMOUNT)             cs_set_user_money(id, usermoney - EXTRA_HP_COST)             return PLUGIN_CONTINUE         }         case 1:         {             if(usermoney < EXTRA_XP_COST)             {                 return PLUGIN_HANDLED             }             g_PlayerXP[id] += EXTRA_XP_AMOUNT             cs_set_user_money(id, usermoney - EXTRA_XP_COST)             DeathMsg()             return PLUGIN_CONTINUE         }         case 2:         {             if(usermoney < EXTRA_SPEED_COST)             {                 return PLUGIN_HANDLED             }             set_user_maxspeed(id, EXTRA_SPEED * 1.0)             client_cmd(id, "cl_forwardspeed %d", EXTRA_SPEED)             client_cmd(id, "cl_backspeed %d", EXTRA_SPEED)             client_cmd(id, "cl_sidespeed %d", EXTRA_SPEED)             cs_set_user_money(id, usermoney - EXTRA_SPEED_COST)             return PLUGIN_CONTINUE         }     }     return PLUGIN_CONTINUE }


All times are GMT -4. The time now is 16:39.

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