Help to remove a parameter
#1

Hi guys, I have this command for sending players to jail:

PHP код:
dcmd_jail(playeridparams[])
{
  new 
jailedidtimestring[128];
  if(
sscanf(params"ud"jailedidtime)) return SendClientMessage(playerid, -1"/jail [id] [minutes]");
  if(
jailedid == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_RED"Player is not online.");
  if(
Jailed[playerid] == true) return SendClientMessage(playeridCOLOR_RED"The player is already jailed");
  
Jailed[playerid]=true;
  
SetTimerEx("Unjailtime"60000 timefalse"d"jailedid);
  
format(stringsizeof(string), "%s has been jailed"GetPlayerNameEx(jailedid));
  
SendClientMessageToAll(COLOR_REDstring);
  
SetPlayerPos(jailedid, -27.14552321.164824.3034);
  
SetPlayerInterior(jailedid0);
  
SendClientMessage(jailedidCOLOR_RED"YOU ARE JAILED!!");
  return 
1;

I want to remove the parameter "minute" and thus only be "/jail id" for a time of 1 minute fixed.

Here is the rest of the code:


PHP код:
new bool:Jailed[MAX_PLAYERS]; 
PHP код:
forward Unjailtime(playerid);
public 
Unjailtime(playerid)
{
  new 
string[128];
  
Jailed[playerid] = false;
  
SetPlayerPos(playerid, -20.88892334.466324.1406);
  
SetPlayerInterior(playerid0);
  
format(stringsizeof(string), "%s is free"GetPlayerNameEx(playerid));
  
SendClientMessageToAll(COLOR_ORANGEstring);
  return 
1;

Thanks for all the help, regards!
Reply
#2

Код:
dcmd_jail(playerid, params[]) 
{ 
  new jailedid, string[128]; 
  if(sscanf(params, "u", jailedid)) return SendClientMessage(playerid, -1, "/jail [id]"); 
  if(jailedid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "Player is not online."); 
  if(Jailed[playerid] == true) return SendClientMessage(playerid, COLOR_RED, "The player is already jailed"); 
  Jailed[playerid]=true; 
  SetTimerEx("Unjailtime", 60000, false, "d", jailedid); 
  format(string, sizeof(string), "%s has been jailed", GetPlayerNameEx(jailedid)); 
  SendClientMessageToAll(COLOR_RED, string); 
  SetPlayerPos(jailedid, -27.1455, 2321.1648, 24.3034); 
  SetPlayerInterior(jailedid, 0); 
  SendClientMessage(jailedid, COLOR_RED, "YOU ARE JAILED!!"); 
  return 1; 
}
For 1 minutes
Reply
#3

you should read about sscanf and command processors

https://sampwiki.blast.hk/wiki/Fast_Commands
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)