| Blockland Forums > Modification Help |
| ServerCmd Delay |
| << < (2/5) > >> |
| Jasa1:
--- Quote from: infiniteLoop on July 27, 2011, 07:01:37 PM ---It should look something like this --- Code: ---function serverCmdSomeCommand(%client) { %time = getSimTime(); if(%client.lastTimeSomeCommand $= "") { %client.lastTimeSomeCommand = %time; } if(%time - %client.lastTimeSomeCommand > 5000) { //your code here %client.lastTimeSomeCommand = %time; } else { messageClient(%client,'',"You can't use this command right now."); } } --- End code --- This should work.. --- End quote --- --- Code: ---function servercmdstuff(%client) { if(%client.lastcommand <= $Sim::Time+10) { messageclient(%client,'',"You must wait 10 seconds before using this command again."); %client.lastcommand = $Sim::Time; } } --- End code --- Would that work too? |
| infiniteLoop:
--- Quote from: otto-san on July 27, 2011, 07:02:17 PM --- --- Code: ---function serverCmdDoSomething(%client) { if(%client.somethingCooldown) return; //stuff %client.somethingCooldown = 1; schedule(5000,0,cooledDown,%client); } function cooledDown(%obj) { %obj.somethingCooldown = 0; } --- End code --- something like that but there's probably a better way to do it, i don't know if that works or not Warning - while you were typing a new reply has been posted. You may wish to review your post. ah i see --- End quote --- Yes, this is another way to do it. |
| infiniteLoop:
--- Quote from: Jasa1 on July 27, 2011, 07:03:07 PM --- --- Code: ---function servercmdstuff(%client) { if(%client.lastcommand <= $Sim::Time+10) { messageclient(%client,'',"You must wait 10 seconds before using this command again."); %client.lastcommand = $Sim::Time; } } --- End code --- Would that work too? --- End quote --- No, sime time isn't actual seconds.. It is milliseconds |
| Headcrab Zombie:
I actually made a support script a while ago, where you just added a single function call with arguments of the function name, number of arguments in the function, number of times allowed to be used, reset time, and an optional callback, a function that would execute (with the proper %client passed to it, of course) if the client has used the function too many times. For example, the following code (if you have the script, of course) would make suiciding not be able to be used more than 5 times a minute, and it would tell the user "You can't Self Delete that often!" if they try to do it more --- Code: ---registerTimeRestrictedCommand("Self Delete",5,60,0,"handleSelf DeleteSpam"); function handleSelf DeleteSpam(%client) { messageClient(%client,'','You can't Self Delete that often!'); } --- End code --- |
| Jasa1:
--- Code: ---function servercmdstuff(%client) { if(%client.lastcommand < $Sim::Time-10000) { //Dostuff %client.lastcommand = $Sim::Time; } else { messageclient(%client,'',"You must wait 10 seconds before using this command again."); } } --- End code --- Would that work? If not tell me what's wrong |
| Navigation |
| Message Index |
| Next page |
| Previous page |