Raised This Month: $ Target: $400
 0% 

index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 12-05-2010 , 10:14   index out of bounds
Reply With Quote #1

Hello! I'm trying to do a kz plugin for my self, but i'm having a problem with the timer...

Quote:
public cmd_ShowTime(id) {
if (!is_user_alive(id))
return PLUGIN_HANDLED

if(!g_started[id]) {
ColorChat(id, GREEN, "[KZ] ^1MESSAGE")
return PLUGIN_HANDLED
}

if (ShowTime[id]) {
ShowTime[id] = false
ColorChat(id, GREEN, "[KZ] ^1MESSAGE")
remove_task(id+TASK_ID_SHOWTIME)
return PLUGIN_HANDLED
}

set_task(1.0, "DisplayTime", id+TASK_ID_SHOWTIME, _, _, "b")
ColorChat(id, GREEN, "[KZ] ^1MESSAGE")

return PLUGIN_CONTINUE
}

public DisplayTime(id) {
new tempo[12]

seconds2[id]++
if(seconds2[id] >= 10) {
seconds2[id] = 0
seconds1[id]++
}

if(seconds1[id] >= 6) {
seconds1[id] = 0
minutes2[id]++
}

if(minutes2[id] >= 10) {
minutes2[id] = 0
minutes1[id]++
}

formatex(tempo, 11, "%s%s:%s%s", minutes1[id], minutes2[id], seconds1[id], seconds2[id])

//The location is just for testing
set_hudmessage( 20, 40, 7, 0.9, -1.0, 0, 0.0, 2.0, 0.0, 1.0, -1);
ShowSyncHudMsg(id, tempohud, tempo)


}
I'm receiving the error index out of bounds...
What is happening?

Oh, and there is a better way to do what I want?
fmfs10 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 12-05-2010 , 10:32   Re: index out of bounds
Reply With Quote #2

DisplayTime function is called via set_task with player id + TASK_ID_SHOWTIME as the task id. Then in your DisplayTime function you never subtract the TASK_ID_SHOWTIME to get the player id

PHP Code:
public DisplayTimeid )
{
    
id -= TASK_ID_SHOWTIME;
    
//.... 
__________________
Bugsy is offline
fmfs10
Senior Member
Join Date: Mar 2009
Location: Brasil
Old 12-05-2010 , 10:46   Re: index out of bounds
Reply With Quote #3

OH IT WORKED! THANKS!

I needed to change %s to %d too...


Can you say to me if there is a better way to do this?

And there is a way to remove the c4 timer and make the clock icon appear before the timer?
fmfs10 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:28.


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