Raised This Month: $ Target: $400
 0% 

Server crash with loop


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Pattinho
Member
Join Date: Dec 2007
Old 05-10-2012 , 08:48   Re: Server crash with loop
#1

Why do you use a while loop ? Because if you just wanna ask one person with it, it makes no sense.

Last edited by Pattinho; 05-10-2012 at 08:51.
Pattinho is offline
jasondoyle
Member
Join Date: Dec 2009
Old 05-10-2012 , 08:59   Re: Server crash with loop
#2

Quote:
Originally Posted by Pattinho View Post
Why do you use a while loop ? Because if you just wanna ask one person with it, it makes no sense.
Well the idea is to keep each players ex_interp set to 0.01. If a player is on the server they have agreed to be monitored.

Would it work better if I tried a "for" loop?
jasondoyle is offline
Diegorkable
Veteran Member
Join Date: Jun 2011
Old 05-10-2012 , 09:04   Re: Server crash with loop
#3

Quote:
Originally Posted by jasondoyle View Post
Well the idea is to keep each players ex_interp set to 0.01. If a player is on the server they have agreed to be monitored.

Would it work better if I tried a "for" loop?
It's better if you register a forward. think that each loop is occuring at every possible milisecond (I dont really know the times but it's very fast), so this is killing the server's CPU, making it crash. A forward will be called with a delay. Try to find the right forward to call that and make sure that if player agreed that his settings will be saved, it will be kept in a boolean array (true:agreed, false:did not agree).
__________________
My Projects:

Auto-Mix (Pug): 100%

Joined the Military (a soldier now) - Inactive
Diegorkable is offline
jasondoyle
Member
Join Date: Dec 2009
Old 05-10-2012 , 09:11   Re: Server crash with loop
#4

Quote:
Originally Posted by Diegorkable View Post
It's better if you register a forward. think that each loop is occuring at every possible milisecond (I dont really know the times but it's very fast), so this is killing the server's CPU, making it crash. A forward will be called with a delay. Try to find the right forward to call that and make sure that if player agreed that his settings will be saved, it will be kept in a boolean array (true:agreed, false:did not agree).
I tried to user a "for" loop and it almost works, it is only changing the command when the trigger an event(spawn, take damage etc).

PHP Code:
public ClientCommands(id){
    new 
y;
    if(
is_user_alive(id)){ 
        
y=1;
        }else{
        
y=0;
    }
    for (
y=1y==1y+-){
        
client_cmd(id"ex_interp ^"0.01^"0.01");
        
client_print(idprint_chat"Your ex_interp has been changed to 0.01");
    }
    return 
PLUGIN_HANDLED;

I would like to try use a forword but I have no idea how, could you link me to a tutorial or anything?
jasondoyle is offline
Closed Thread



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 00:22.


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