AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Code to edit :) (https://forums.alliedmods.net/showthread.php?t=63662)

wojtex 11-26-2007 12:49

Code to edit :)
 
What's wrog with this code, can you edit it(+karma)

Code:

new const g_sounds[][] =
{
"voi/elo.wav",
"voi/siema.wav",
"voi/siemano.wav"
}
 
new const g_teamattack_sounds[][] =
{
"tk1.wav",
"tk2.wav",
"tk3.wav",
"tk4.wav"
}
 
new const g_attack_sounds[][]=
{       
"voi/wqrw5.wav",
"voi/wqrw4.wav",
"voi/wqrw2.wav", 
"voi/wqrw3.wav",
"voi/wqrw6.wav",
"voi/wqrw7.wav",
"voi/wqrw8.wav",
"voi/wqrw1.wav",
"voi/taunt5.wav",
"voi/taunt2.wav",
"voi/taunt4.wav",
"voi/taunt3.wav",
"voi/taunt1.wav",
"voi/okurwa.wav"
}
 
new g_maxplayers
 
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
 
register_clcmd("say elo",  "say_elo_handle")
register_clcmd("say siema", "say_siema_handle")
register_clcmd("say siemano",  "say_siemano_handle")
 
g_maxplayers = get_maxplayers() + 1
}
 
public plugin_precache()
{   
for(new i = 0; i < sizeof g_sounds; i++)
{   
if(!precache_sound(g_sounds[i]))
{
log_amx("Error: Could not precache (%s) plugin stopped."
 
g_sounds[i])
pause("ad")
}
 
for(new i = 0; i < sizeof g_teamattack_sounds; i++)
{
if(!precache_sound(g_teamattack_sounds[i]))
{
log_amx("Error: Could not precache (%s), plugin stopped.",
 
g_teamattack_sounds[i])
pause("ad")
}
 
for(new i = 0; i < sizeof g_attack_sounds; i++)
{
if(!precache_sound(g_atac_sounds[i]))
{
log_amx("Error: Could not precache (%s), plugin stopped.",
 
g_atac_sounds[i])
pause("ad")
}
 
 
public say_elo_handle(id,0)
{
play_sound(id, 0)
}
 
public say_siema_handle(id,1)
{
play_sound(id, 1)
}
 
public say_siemano_handle(id,2)
{
play_sound(id, 2)
}
 
public play_sounds(id, soundid)
{
static buffer[64]
 
format(buffer, 63, "sound/ %s", g_sounds[soundid])
 
if(is_user_alive(id))
{
for(new i = 0; i < g_maxplayers; i++)
{
if(is_user_connected(i))
{
console_cmd(id, "spk %s", buffer)
}
 
}
else
{
for(new i = 0; i < g_maxplayers; i++)
{
if(is_user_connected(i) && !is_user_alive(i))
{
console_cmd(id, "spk %s", buffer)
}
 
}
return PLUGIN_HANDLED
}
 
public client_damage (attacker, victim, damage, wpnindex, hitplace, TA, atac)
{
if(TA
if(attack
emit_sound(victim, CHAN_VOICE, g_teamattack_sounds[random_num(0, sizeof
 
g_teamattack_sounds - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}
emit_sound(victim, CHAN_VOICE, g_attack_sound[random_num(0, sizeof
 
g_atac_sound - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
}


RaYden 11-26-2007 14:06

Re: Code to edit :)
 
1 Attachment(s)
omg I have no idea how u damaged that code so badly
I have posted a fix ... haven't tested it tho
MAKE SURE U HAVE THE SOUND FILES IN THE CORRECT FOLDERS OTHERWISE IT WILL NOT WORK !!! >.<

wojtex 11-26-2007 14:28

Re: Code to edit :)
 
Its not my plugin it is my friends :D + karma

Lee 11-26-2007 17:47

Re: Code to edit :)
 
Code:
public play_sound( soundid) { static buffer[64],player[32],playersnum   format(buffer, 63, "sound/ %s", g_sounds[soundid])   get_players(player,playersnum,"c") for(new i = 0; i < playersnum; i++) {     if(is_user_connected(i))     {         console_cmd(player[i], "spk %s", buffer)     } } return PLUGIN_HANDLED }

RaYden 11-27-2007 03:01

Re: Code to edit :)
 
yes there was a lot of pointless stuff in that script ... I might have not removed it all

purple_pixie 11-27-2007 06:12

Re: Code to edit :)
 
I think he meant "that should be players[i], and not just i"

EDIT: And now I know how to highlight things in "small" tags .. rock on.

Lee 11-27-2007 08:33

Re: Code to edit :)
 
If the highlighted line used player[i], it would be "pointless". As it stands, it's a bug because player[] won't always contain contiguous user IDs. Also, client_cmd() accepts 0 as its first parameter - so there's no need to use get_players() to determine connected players anyway.

Sn!ff3r 11-27-2007 09:22

Re: Code to edit :)
 
Code:

new const g_sounds[][] =
{
"voi/elo.wav",
"voi/siema.wav",
"voi/siemano.wav"
}
 
new const g_teamattack_sounds[][] =
{
"tk1.wav",
"tk2.wav",
"tk3.wav",
"tk4.wav"
}
 
new const g_attack_sounds[][]=
{       
"voi/wqrw5.wav",
"voi/wqrw4.wav",
"voi/wqrw2.wav", 
"voi/wqrw3.wav",
"voi/wqrw6.wav",
"voi/wqrw7.wav",
"voi/wqrw8.wav",
"voi/wqrw1.wav",
"voi/taunt5.wav",
"voi/taunt2.wav",
"voi/taunt4.wav",
"voi/taunt3.wav",
"voi/taunt1.wav",
"voi/okurwa.wav"

omg noob... sound files have copyrights?
}

[ --<-@ ] Black Rose 11-27-2007 09:25

Re: Code to edit :)
 
Quote:

Originally Posted by Sn!ff3r (Post 557437)
omg noob... sound files have copyrights?
}

Is that a question or do you just suck at english?

purple_pixie 11-27-2007 09:51

Re: Code to edit :)
 
The message started "omg noob" and you think there's a chance he doesn't suck at English :-D


All times are GMT -4. The time now is 11:07.

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