Raised This Month: $ Target: $400
 0% 

[Resolved] Code works on random players only?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-30-2006 , 10:34   [Resolved] Code works on random players only?
Reply With Quote #1

Hey again everyone, another problem @_@. The code i'm about to post below will only work on some players. It is supposed to work for everyone that touches it.

Code:
public toucherStartFunc(pToucher, pTouched) {     new id = pTouched;     if(!timerUse[id]) {         client_cmd(id, "speak fvox/boop");         hour[id] = 0.0;         minute[id] = 0.0;         second[id] = 1.0;         set_hudmessage(200, 100, 0, -1.0, -5.0, 0, 0.0, 500000.9, 0.0, 0.0, 4);         show_hudmessage(id, "00:00:01");         set_task(1.0, "timerCount", 1, "", 0, "b");     }     timerUse[id] = true;         return PLUGIN_CONTINUE; } public timerCount(id) {     second[id] += 1.0         if(second[id] == 60.0) {         second[id] = 0.0         minute[id] += 1.0     }         if(minute[id] == 60.0) {         minute[id] = 0.0         hour[id] += 1.0     }         new strHour[3];     new strMinute[3];     new strSecond[3];         float_to_str(hour[id], strHour, 2);     float_to_str(minute[id], strMinute, 2);     float_to_str(second[id], strSecond, 2);         switch(hour[id]) {         case 0.0: strHour = "00";         case 1.0: strHour = "01";         case 2.0: strHour = "02";         case 3.0: strHour = "03";         case 4.0: strHour = "04";         case 5.0: strHour = "05";         case 6.0: strHour = "06";         case 7.0: strHour = "07";         case 8.0: strHour = "08";         case 9.0: strHour = "09";     }         switch(minute[id]) {         case 0.0: strMinute = "00";         case 1.0: strMinute = "01";         case 2.0: strMinute = "02";         case 3.0: strMinute = "03";         case 4.0: strMinute = "04";         case 5.0: strMinute = "05";         case 6.0: strMinute = "06";         case 7.0: strMinute = "07";         case 8.0: strMinute = "08";         case 9.0: strMinute = "09";     }         switch(second[id]) {         case 0.0: strSecond = "00";         case 1.0: strSecond = "01";         case 2.0: strSecond = "02";         case 3.0: strSecond = "03";         case 4.0: strSecond = "04";         case 5.0: strSecond = "05";         case 6.0: strSecond = "06";         case 7.0: strSecond = "07";         case 8.0: strSecond = "08";         case 9.0: strSecond = "09";     }         set_hudmessage(200, 100, 0, -1.0, -5.0, 0, 0.0, 500000.9, 0.0, 0.0, 4);     show_hudmessage(id, "%s:%s:%s", strHour, strMinute, strSecond);         return PLUGIN_CONTINUE; }

Please help me fix this

Last edited by hlstriker; 11-30-2006 at 12:42. Reason: Resolved
hlstriker is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2006 , 11:03   Re: Code works on random players only?
Reply With Quote #2

public timerCount(id)this id is a task id
public timerCount(taskid)
so you set_task(1.0, "timerCount", 1, "", 0, "b")
only player #1 will take effect
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-30-2006 , 12:05   Re: Code works on random players only?
Reply With Quote #3

Now all the ids in my timerCount() don't work, how do I pass the id down there?
hlstriker is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2006 , 12:09   Re: Code works on random players only?
Reply With Quote #4

set_task(1.0, "timerCount", id, "", 0, "b")
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2006 , 12:15   Re: Code works on random players only?
Reply With Quote #5

why not use integar
Code:
public timerCount(id) {     second[id] ++     new h,m,s     h = second[id] / 3600     m = (second[id] % 3600) / 60     s = (second[id] % 3600) % 60     set_hudmessage(200, 100, 0, -1.0, -5.0, 0, 0.0, 500000.9, 0.0, 0.0, 4);     show_hudmessage(id, "%02d:%02d:%02d", h,m,s);         return PLUGIN_CONTINUE; }
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>

Last edited by jim_yang; 11-30-2006 at 12:21.
jim_yang is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-30-2006 , 12:22   Re: Code works on random players only?
Reply With Quote #6

I didn't know you could put stuff in between the %s %d %f. Thanks that saves tons of time!

Also... about the set_task i'm still a bit confused. You said the 3rd argument is to pass variables, and others tell me its the set the tasks id.
hlstriker is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2006 , 12:25   Re: Code works on random players only?
Reply With Quote #7

set_task(1.0,"function",taskid)
then it pass taskid to your function
public function(taskid)
{
}

id is just a name. you can name it whatever you like
public client_connect(player)
{
}
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>

Last edited by jim_yang; 11-30-2006 at 12:27.
jim_yang is offline
hlstriker
Green Gaben
Join Date: Mar 2006
Location: OH-IO!
Old 11-30-2006 , 12:32   Re: Code works on random players only?
Reply With Quote #8

Ok just one more question about the format you made...
Code:
show_hudmessage(id, "%02d:%02d:%02d", h,m,s);

Where it is "%02d" what does that 2 represent?
hlstriker is offline
jim_yang
Veteran Member
Join Date: Aug 2006
Old 11-30-2006 , 12:35   Re: Code works on random players only?
Reply With Quote #9

1-9 print 01-09
10-99 print 10-99
__________________
Project : CSDM all in one - 99%
<team balancer#no round end#entity remover#quake sounds#fake full#maps management menu#players punishment menu#no team flash#colored flashbang#grenade trails#HE effect#spawn protection#weapon arena#weapon upgrade#auto join#no weapon drop#one name>
jim_yang 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 07:01.


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