Raised This Month: $ Target: $400
 0% 

Solved Timed Command Usage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
PBFliX
Member
Join Date: Apr 2017
Location: United Kingdom
Old 04-12-2017 , 10:21   Timed Command Usage
Reply With Quote #1

Is there any way to limit how often a command can be used, e.g. enabling someone to use /csay once a day for fun.
Any sort of reply would be greatly appreciated. Thanks

Last edited by PBFliX; 04-12-2017 at 12:21.
PBFliX is offline
Koraks
AlliedModders Donor
Join Date: Aug 2016
Location: Poland, Cracow
Old 04-12-2017 , 10:33   Re: Timed Command Usage
Reply With Quote #2

Use cookies ? Save actual time in DB and if player use sm_csay check actual_time - previous_time_use > 86400..
Code:
int previous_use[MAXPLAYERS+1];

/*Save and read use_time in/from DB */

public Action csay(int client, int args)
{
  if(GetTime() - previous_use[client] > 86400)
 {
   previous_use[client] = GetTime();
   /*Do really csay*/
 }
 else
 {
   PrintToChat(client, "U can use /csay once a day");
   return Plugin_Handled;
 }
}
__________________
Donator
Koraks 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 03:11.


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