I need a jail command!
#1

Sorry for my English, i am Spanish.

Well, i use that command in my gamemode, but i want to add another step. When i use the command, i have to use that: /ajail [playerid/PartOfName] [time(minutes)] [reason]
And i want to add that: USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason] [points]
When you put the points, it have to quit these points to a account of points that i have created.
I don't know if you understand my post, and y repeat: sorry for my english.
That is the command:
if(strcmp(cmd, "/ajail", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
return 1;
}
new playa;
new money;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
money = strval(tmp);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /ajail [playerid/PartOfName] [time(minutes)] [reason]");
return 1;
}
format(string, sizeof(string), "* You Jailed %s.", giveplayer);
SendClientMessage(playerid, COLOR_LIGHTRED, string);
format(string, sizeof(string), "* You were Jailed by Admin %s.", sendername);
SendClientMessage(playa, COLOR_LIGHTRED, string);
SafeResetPlayerWeapons(playa);
WantedPoints[playa] = 0;
PlayerInfo[playa][pJailed] = 1;
PlayerInfo[playa][pJailTime] = money*60;
SetPlayerInterior(playa, 6);
PlayerInfo[playa][pInt] = 6;
SetPlayerPos(playa, 264.6288,77.5742,1001.0391);
format(string, sizeof(string), "You are jailed for %d minutes. Bail: Unable", money);
SendClientMessage(playa, COLOR_WHITE, string);
format(string, 256, "AdmCmd: %s has been jailed by Admin %s [Reason: %s]", giveplayer, sendername, (result));
BroadCast(COLOR_LIGHTRED,string);
format(string, sizeof(string), "AdmCmd: %s has been Admin-jailed by %s [Reason: %s]", giveplayer, sendername, (result));
printf("%s",string);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
}
}
Reply
#2

Includes: (if you got Compile Error add these includes)
Код:
#include <dudb>
#include <dutils>
Put This Code on Defines
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
#define GetName(%1,%2) new %2[MAX_PLAYER_NAME]; GetPlayerName(%1,%2,MAX_PLAYER_NAME)
Код:
enum PlayerInfo
{
	pAdmin,
	pDeaths,
	pKills
}
new pInfo[MAX_PLAYERS][PlayerInfo];
Put the code after
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
Код:
  dcmd(jail, 0, cmdtext);	
return 0;
}
Код:
dcmd_jail(playerid, params[])
{
	new index = 0;
  tmp2 = strtok(params, index);
	if (pInfo[playerid][pAdmin] == 0)
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
  if(!strlen(tmp2))
	{
	SystemMessage(playerid, "Correct usage: '/jail [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
  giveplayerid = ReturnUser(tmp2);
	if (IsPlayerConnected(giveplayerid))
	{
  format(string, sizeof(string), "You have been jailed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
  SystemMessage(giveplayerid, string);
	JailPlayer(giveplayerid, "");
  format(string, sizeof(string), "Player %s has been jailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
  SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been jailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s jailed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
  }
  	else
  {
	SystemMessage(playerid, "That player is not active.");
	}
  return 1;
}

dcmd_unjail(playerid, params[])
{
	new index = 0;
  tmp2 = strtok(params, index);
	if (pInfo[playerid][pAdmin] == 0)
	{
	SystemMessage(playerid, "You are not Administrator.");
	return 1;
	}
  if(!strlen(tmp2))
	{
	SystemMessage(playerid, "Correct usage: '/unjail [playername] [reason]'");
	return 1;
	}
	new string[MAX_STRING];
	new second, minute, hour, day, month, year;
  giveplayerid = ReturnUser(tmp2);
	if (IsPlayerConnected(giveplayerid))
	{
  format(string, sizeof(string), "You have been unjailed by Administrator %s. (Reason: '%s')", PlayerName(playerid), params);
  SystemMessage(giveplayerid, string);
	UnjailPlayer(giveplayerid, "");
  format(string, sizeof(string), "Player %s has been unjailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
  SystemMessageToAll(string);
	format(string, sizeof(string), "%s has been unjailed by Administrator %s. (Reason: '%s')", PlayerName(giveplayerid), PlayerName(playerid), params);
	print(string);
	gettime(hour, minute, second);
	getdate(year, month, day);
	format(string, sizeof(string), "Player %s unjailed player %s on %d/%d/%d at %d:%d:%d. (Reason: '%s')", PlayerName(playerid), PlayerName(giveplayerid), month, day, year, hour, minute, second, params);
	ServerLog(string);
  }
  	else
  {
	SystemMessage(playerid, "That player is not active.");
	}
  return 1;
}
Reply
#3

Thanks, i am going to try this.
Reply
#4

i have edited the code check it now !!
Reply
#5

It works fine, thanks.
Reply
#6

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)