Quick Timer Question.
#1

Hi again,

I am making a mute command, I was wondering how I can transfer the time the admin types in to the actual timer itself.Like for example, admin types /mute 0 30 test, it sets a specific timer for that player and it sets the timer time to what the admin typed.

My code.
pawn Код:
CMD:mute(playerid, params[])
{
  new target;
  new reason;
  new time;
  if(PlayerInfo[playerid][Admin] < 1) return SendClientMessage(playerid,-1,"You are not allowed to use this command");
  if(sscanf(params, "uds[256]",target, time,reason)) return SendClientMessage(playerid, -1,"Usage: /mute [playerid] [time] [reason]");
  if(!IsPlayerConnected(target)) return SendClientMessage(playerid, -1, "This player is not connected!");
  new name[MAX_PLAYER_NAME];
  new targetname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, name,sizeof(name));
  GetPlayerName(target, targetname,sizeof(targetname));
  new str35[200];
  format(str35,sizeof(str35), "%s %s has muted %s for %d seconds. Reason:%s",AdminLevel(playerid),name,targetname,time,reason);
  SetTimerEx("UnMute",false,"d","i",time,targetid);
  return 1;
}
How would I do that? Any suggestions are always helpful!
Reply
#2

You can do it if you have a one second timer in your gamemode if you don't want to fuck with the timers tho.

Like set the var to those seconds for the player and when a second passes you check if the player has the var higher than 1? Also there are some issues in this code the SetTimerEx is wrong you can't do "d","i" you need to do it like "di", bcs its one parameter that declares your stuff.

Also "uds[256]" is wrong 256 cells really? How about 144 (That is the maximum value in the samp chatlog so you can use that).

You can make the function for getting the players name instead of doing that GetPlayerName(pid, var, sizeof(var)); every time...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)