Making a /rights Command for RP
#1

Hi everyone,
I just wanted to do like /rights command for the cops or other LEO factions so that the officer can read out the Miranda Rights without writing them all over ..
I didn't know which is the right way to do it. Anyway I have came up with this .. But I couldn't fix the errors .. So It's apparently some errors in the code :


Код:
CMD:rights(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new string[256];
    	if (PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 ||
			PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 ||  PlayerInfo[playerid][pMember] == 4 && PlayerInfo[playerid][pDivision] == 2 ||
			(PlayerInfo[playerid][pMember] == 4 && PlayerInfo[playerid][pRank] >= 5) || PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7 ||
			PlayerInfo[playerid][pMember] == 11 || PlayerInfo[playerid][pLeader] == 11 || PlayerInfo[playerid][pMember] == 13 || PlayerInfo[playerid][pLeader] == 13)
		{

        	format(string, sizeof(string), "%s says: You are under arrest; you have the right to remain silent,", GetPlayerName);

        	format(string, sizeof(string), "%s says: anything you say may and will be used against you in a court of law.", GetPlayerName);

        	format(string, sizeof(string), "%s says: You have the right to consult an attorney and to have an attorney present during questioning.", GetPlayerName);

        	format(string, sizeof(string), "%s says: If you cannot afford an attorney, one will be appointed for you by the court.", GetPlayerName);

                format(string, sizeof(string), "%s says: Do you understand each of these rights I have explained to you ?", GetPlayerName);
  		}
  		else return SendClientMessage(playerid, COLOR_WHITE, "You cannot use this command.");
  		ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
   }
   return 1;
}

Please HELP ! I'll Rep+ ^_^

P.S : I'm using the original ProxDetector .. and Yes this is a GF edit ..
Reply
#2

I don't think this is the most efficient way of doing it but it should work I imagine. Try this:

Код:
CMD:rights(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        new string[256];
    	if (PlayerInfo[playerid][pMember] == 3 || PlayerInfo[playerid][pLeader] == 3 || PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 ||
			PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pLeader] == 2 ||  PlayerInfo[playerid][pMember] == 4 && PlayerInfo[playerid][pDivision] == 2 ||
			(PlayerInfo[playerid][pMember] == 4 && PlayerInfo[playerid][pRank] >= 5) || PlayerInfo[playerid][pMember] == 7 || PlayerInfo[playerid][pLeader] == 7 ||
			PlayerInfo[playerid][pMember] == 11 || PlayerInfo[playerid][pLeader] == 11 || PlayerInfo[playerid][pMember] == 13 || PlayerInfo[playerid][pLeader] == 13)
		{
			new pname[20];
			GetPlayerName(playerid,pname,20);
        	format(string, sizeof(string), "%s says: You are under arrest; you have the right to remain silent,",pname);
            ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        	format(string, sizeof(string), "%s says: anything you say may and will be used against you in a court of law.",pname);
            ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        	format(string, sizeof(string), "%s says: You have the right to consult an attorney and to have an attorney present during questioning.",pname);
            ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        	format(string, sizeof(string), "%s says: If you cannot afford an attorney, one will be appointed for you by the court.",pname);
            ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
            format(string, sizeof(string), "%s says: Do you understand each of these rights I have explained to you ?",pname);
            ProxDetector(20.0, playerid, string, COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
  		}
  		else return SendClientMessage(playerid, COLOR_WHITE, "You cannot use this command.");
   }
   return 1;
}
Reply
#3

It compiled with no errors ...
So, is it necessary to set a variable then call it in the format( x,x,x,x,...) ?
Reply
#4

You could use GetPlayerName() within the format() function but it's just cleaner to set the string of pname at the start then reference it from there. Hope that answers your question.
Reply
#5

But I have tried the same way but without the variable (pname) and I get errors ...
I guess the problem was the variable .. anyway Thanks .. Rep+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)