Raised This Month: $51 Target: $400
 12% 

Client Cmd with index 0 = Index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DavidJr
Senior Member
Join Date: Apr 2012
Old 02-01-2014 , 23:20   Client Cmd with index 0 = Index out of bounds
Reply With Quote #1

Sorry for this funny question :p

PHP Code:
new headshotSound[3][] = {
    
"spk player/headshot1.wav",
    
"spk player/headshot2.wav",
    
"spk player/headshot3.wav"
}

public 
plugin_init()
{
    
register_event("DeathMsg""event_DeathMsg_Pre""a");
}

public 
event_DeathMsg()
{
    
client_cmd(0headshotSound[random_num(0sizeof headshotSound)])

I want to send headshot sounds to all players with client_print way but sometimes gives index out of bounds. Using get_players returns index out of bounds either.
__________________
What are you looking for here?

Last edited by DavidJr; 02-01-2014 at 23:21.
DavidJr is offline
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 02-02-2014 , 04:29   Re: Client Cmd with index 0 = Index out of bounds
Reply With Quote #2

PHP Code:
client_cmd(0headshotSound[random_num(0sizeof headshotSound)]) 
->

PHP Code:
client_cmd(0headshotSound[random_num(0sizeof headshotSound 1)]) 
mottzi is offline
Send a message via MSN to mottzi
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-02-2014 , 04:32   Re: Client Cmd with index 0 = Index out of bounds
Reply With Quote #3

or
PHP Code:
headshotSound[random(sizeof headshotSound)] 
Also, ther is a typo on the code you shown : event_DeathMsg_Pre
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-02-2014 at 04:33.
ConnorMcLeod is offline
DavidJr
Senior Member
Join Date: Apr 2012
Old 02-02-2014 , 05:45   Re: Client Cmd with index 0 = Index out of bounds
Reply With Quote #4

Okay, thank you both of you ;)
__________________
What are you looking for here?
DavidJr is offline
Reply



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 11:58.


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