Jump to content
  • 0

How do I add 20 seconds before I can send a message again in this code?


c4striker

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  5
  • Reputation:   0
  • Joined:  12/12/18
  • Last Seen:  

How can I add 20 seconds before I can send a message again in this code?

-    script    map    -1,{

OnWhisperglobal:
if( getgroupid() < 5 ) end;
announce ""+strcharinfo(0)+": "+@whispervar0$,bc_map;

end;

}

-    script    global    -1,{

OnWhisperglobal:
if( getgroupid() < 5 ) end;
announce ""+strcharinfo(0)+": "+@whispervar0$,bc_all;

end;

}

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  63
  • Topics Per Day:  0.02
  • Content Count:  1016
  • Reputation:   191
  • Joined:  11/27/14
  • Last Seen:  

Add gettimetick(2)

Try the code below

-    script    global    -1,{
    
OnInit:
    setarray .@LastWhisperTime[0], 0; // Initialize an array to store the last whisper time

OnWhisperglobal:
    if (getgroupid() < 5) end; // Allow only players with group ID 5 and above to use this command
    if (.@LastWhisperTime[getcharid(0)] + 20 > gettimetick(2)) {
        // If the time since the last whisper is less than 20 seconds, prevent another whisper
        dispbottom "You need to wait " + (.@LastWhisperTime[getcharid(0)] + 20 - gettimetick(2)) + " seconds before sending another message.";
        end;
    }
    // Update the last whisper time to the current time
    .@LastWhisperTime[getcharid(0)] = gettimetick(2);
    // Announce the message
    announce ""+strcharinfo(0)+": "+@whispervar0$,bc_all;

end;

}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...