c4striker Posted June 11, 2024 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 5 Reputation: 0 Joined: 12/12/18 Last Seen: June 18, 2024 Share Posted June 11, 2024 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; } Quote Link to comment Share on other sites More sharing options...
0 Poring King Posted June 11, 2024 Group: Members Topic Count: 63 Topics Per Day: 0.02 Content Count: 1016 Reputation: 191 Joined: 11/27/14 Last Seen: February 15 Share Posted June 11, 2024 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; } Quote Link to comment Share on other sites More sharing options...
Question
c4striker
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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.