/ajail
#1

Hey guys, I need help with this /ajail command - I want it so that I can add a reason instead of just putting them in /ajail and also so that everyone on the server can see that the person has been /ajailed and the reason why

Код:
 	if(strcmp(cmd, "/ajail", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] /ajail [playerid] [minutes]");
				return 1;
			}
			new playa;
			new money;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			money = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 2)
			{
			  if(IsPlayerConnected(playa))
			  {
			    if(playa != INVALID_PLAYER_ID)
			    {
						format(string, sizeof(string), "You jailed %s.", GetPlayerNameEx(playa));
						SendClientMessage(playerid, COLOR_LIGHTYELLOW2, string);
						format(string, sizeof(string), "You where jailed by %s for %d minutes.", GetPlayerNameEx(playerid),money);
						SendClientMessage(playa, COLOR_LIGHTYELLOW2, string);

						ResetPlayerWeapons(playa);
						WantedPoints[playa] = 0;
						PlayerInfo[playa][pJailed] = 1;
						PlayerInfo[playa][pJailTime] = money*60;
						SetPlayerInterior(playa, 6);
						SetPlayerPos(playa, 264.6288,77.5742,1001.0391);
						SetPlayerVirtualWorld(playerid,2);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] Your not an administrator.");
			}
		}
		return 1;
	}
Many thanks,
Sam.
Reply
#2

Add that one
pawn Код:
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] [minuted] [reason]");
                            return 1;
                        }
and then just make a string
pawn Код:
format(string, sizeof(string), "%s was jailed by Administrator %s, reason: %s", giveplayer, sendername, (result));
SendClientMessageToAll(COLOR_LIGHTRED, string);
Reply
#3

Erm.. Where do i add it
Reply
#4

Quote:
Originally Posted by samdudes01
Erm.. Where do i add it
above

pawn Код:
format(string, sizeof(string), "You jailed %s.", GetPlayerNameEx(playa));
Reply
#5

Quote:

C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : error 017: undefined symbol "giveplayer"
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : error 017: undefined symbol "giveplayer"
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Im not sure if i did it right:
Код:
 	if(strcmp(cmd, "/ajail", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[USAGE:] /ajail [playerid] [minutes]");
				return 1;
			}
			new playa;
			new money;
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			money = strval(tmp);
			if (PlayerInfo[playerid][pAdmin] >= 2)
			{
			  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] [minuted] [reason]");
							return 1;
						}
						format(string, sizeof(string), "%s was jailed by Administrator %s, reason: %s", giveplayer, sendername, (result));
						SendClientMessageToAll(COLOR_LIGHTRED, string);

						ResetPlayerWeapons(playa);
						WantedPoints[playa] = 0;
						PlayerInfo[playa][pJailed] = 1;
						PlayerInfo[playa][pJailTime] = money*60;
						SetPlayerInterior(playa, 6);
						SetPlayerPos(playa, 264.6288,77.5742,1001.0391);
						SetPlayerVirtualWorld(playerid,2);
					}
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_LIGHTYELLOW2, "[ERROR:] Your not an administrator.");
			}
		}
		return 1;
	}
Reply
#6

Your trying to use the players name

pawn Код:
new playa;
playa = ReturnUser(tmp);
change to

pawn Код:
playa = strval(tmp);
make a other varible to store the players name in
Reply
#7

Quote:

C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : error 017: undefined symbol "giveplayer"
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : error 017: undefined symbol "giveplayer"
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12257) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#8

Quote:
Originally Posted by hoodline
Your trying to use the players name

pawn Код:
new playa;
playa = ReturnUser(tmp);
change to

pawn Код:
playa = strval(tmp);
make a other varible to store the players name in
the first one will use either playername or playerid, not only id. So its better. The problem is on
pawn Код:
new giveplayer[MAX_PLAYER_NAME];
add this before GetPlayerName
Reply
#9

Quote:

C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12259) : error 017: undefined symbol "sendername"
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12259) : error 017: undefined symbol "sendername"
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12259) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Family\My Documents\SAMP server\CRP\gamemodes\crp.pwn(12259) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

lol, what am i doing wrong
Reply
#10

lol now you need a
pawn Код:
new sendername[MAX_PLAYER_NAME];
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)