@request limit

greenieken

New member
Messages
90
Points
0
Github
greenieken
Emulator
Hi. Is there a way to put a delay when using @request like 1 @request per minute? Thanks!

 
You could make @request only usable by group id 99 (admin) and create a custom command (with bindatcmd()) in which you put your extra checks and call the real @request with atcommand()

 
Last edited by a moderator:
You could make @request only usable by group id 99 (admin) and create a custom command (with bindatcmd()) in which you put your extra checks and call the real @request with atcommand()
Could you make one for me please? Coz I honestly dont know how to do it.

 
- script @request 32767,{
OnCall:
if (gettimetick(2) <= @COMMAND_LOCK[getnpcid(0)] && !has_permission(PERM_RECEIVE_REQUESTS)) {
dispbottom(sprintf("You must wait at least %i seconds to call this command again.", .delay));
} else {
@COMMAND_LOCK[getnpcid(0)] = gettimetick(2) + .delay; // update the lock
atcommand("@request " + implode(.@atcmd_parameters$[0], " ")); // call the true command
}
end;

OnInit:
.delay = 10; // number of seconds to wait in between calls
bindatcmd("request", strnpcinfo(NPC_NAME) + "::OnCall", 99, 99, 0); // bind the custom atcommand
add_group_command("request", 0, true, false); // allow group 0 to use the custom atcommand
add_group_command("request", 1, true, false); // allow group 1 to use the custom atcommand
add_group_command("request", 2, true, false); // allow group 2 to use the custom atcommand
add_group_command("request", 3, true, false); // allow group 3 to use the custom atcommand
add_group_command("request", 4, true, false); // allow group 4 to use the custom atcommand
add_group_command("request", 10, true, false); // allow group 10 to use the custom atcommand
// ^ add or remove groups to match your groups.conf
}



In the OnInit section change .delay to the amount of seconds to wait and add your groups to the add_group_command() lines if any is missing.
Any group that has the "receive_requests" permission will bypass the delay entirely.

Relevant documentation:

 
Last edited by a moderator:
- script @request 32767,{
OnCall:
if (gettimetick(2) <= @COMMAND_LOCK[getnpcid(0)] && !has_permission(PERM_RECEIVE_REQUESTS)) {
dispbottom(sprintf("You must wait at least %i seconds to call this command again.", .delay));
} else {
@COMMAND_LOCK[getnpcid(0)] = gettimetick(2) + .delay; // update the lock
atcommand("@request " + implode(.@atcmd_parameters$[0], " ")); // call the true command
}
end;

OnInit:
.delay = 10; // number of seconds to wait in between calls
bindatcmd("request", strnpcinfo(NPC_NAME) + "::OnCall", 99, 99, 0); // bind the custom atcommand
add_group_command("request", 0, true, false); // allow group 0 to use the custom atcommand
add_group_command("request", 1, true, false); // allow group 1 to use the custom atcommand
add_group_command("request", 2, true, false); // allow group 2 to use the custom atcommand
add_group_command("request", 3, true, false); // allow group 3 to use the custom atcommand
add_group_command("request", 4, true, false); // allow group 4 to use the custom atcommand
add_group_command("request", 10, true, false); // allow group 10 to use the custom atcommand
// ^ add or remove groups to match your groups.conf
}



In the OnInit section change .delay to the amount of seconds to wait and add your groups to the add_group_command() lines if any is missing.
Any group that has the "receive_requests" permission will bypass the delay entirely.

Relevant documentation:

Thanks! Will try this

 
Back
Top