Arrest command and Rape command bugged
#1

My arrest command doesn't work, when someone is has a wanted level over 3, and I type /arrest ID, i get no response, no text in the chatbox or anything.

ARREST CMD:
Код:
CMD:arrest(playerid, params[])
{
	new string1[200], string2[200], string3[200], CopName[24], CriminalName[24], CriminalID;

	if(gTeam[playerid] != POL && gTeam[playerid] != SECSRV && gTeam[playerid] != ARMY && gTeam[playerid] != SWAT) return SendClientMessage(playerid, COLOR_RED, "You are not a Law Enforcement Officer!");

	if(sscanf(params, "u", CriminalID)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /arrest [ID]");
	if(CriminalID == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot arrest yourself, how is that possible?!");
	if(GetDistanceBetweenPlayers(playerid, CriminalID) > 5)
	{
		if(GetPlayerWantedLevel(CriminalID) >= 3)
		{
	        SetTimerEx("UnjailTimer", 120000, false, "i", CriminalID);

			isJailed[playerid] = 1;

			GetPlayerName(playerid, CopName, 24);
			GetPlayerName(CriminalID, CriminalName, 24);

			format(string1, 200, "Police Officer %s has arrested %s!", CopName, CriminalName);
			format(string2, 200, "You have been arrested by Police Officer %s!", CopName);
			format(string3, 200, "Good job, Officer! You have arrested %s!", CriminalName);

			SendClientMessageToAll(COLOR_YELLOW, string1);
			SendClientMessage(CriminalID, COLOR_ORANGE, string2);
			SendClientMessage(playerid, COLOR_GREEN, string3);
			SendClientMessage(playerid, COLOR_GREEN, "You have earned +3 score and $5000");

			SetPlayerPos(CriminalID, 197.6661,173.8179,1003.0234);
            SetPlayerInterior(CriminalID, 3);

			SetPlayerScore(playerid, GetPlayerScore(playerid)+3);
            GivePlayerMoney(playerid, 5000);
		}
		else
		{
			SendClientMessage(playerid, COLOR_RED, "That player is not wanted!");
		}
	}
	return 1;
}
For the Rape command, both the rapist and the victim get a disease.

RAPE CMD:
Код:
CMD:rape(playerid, params[])
{
	new string[128], string2[128], string3[128], RapistName[24], VictimName[24], targetid;
	
	if(gTeam[playerid] == POL || gTeam[playerid] == SECSRV || gTeam[playerid] == ARMY || gTeam[playerid] == SWAT) return SendClientMessage(playerid, COLOR_RED, "You are a Law Enforcement Officer, you cannot rape someone!");
	
	if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /rape [ID]");
	{
	    if(GetDistanceBetweenPlayers(playerid, targetid) < 5)
	    {
	        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "That player is not connected.");
	        if(targetid == playerid) return SendClientMessage(playerid, COLOR_RED, "You cannot rape yourself!");
	        
	        GetPlayerName(playerid, RapistName, 24);
	        GetPlayerName(targetid, VictimName, 24);
	        
			new rand = random(sizeof(DiseaseNames));
			pInfo[playerid][Diseases] = rand;
			switch(rand)
			{
			    case 0: SendClientMessage(playerid, COLOR_GREY, "You are lucky this time, you didn't get any STDs!");
			    case 1: SendClientMessage(playerid, COLOR_GREY, "You received an HIV. Go to the hospital, quickly to get it cured.");
			    case 2: SendClientMessage(playerid, COLOR_GREY, "You received Syphilis. Go to the hospital, quickly to get it cured.");
			    case 3: SendClientMessage(playerid, COLOR_GREY, "You received the Crazy Chicken Flu. Go to the hospital, quickly to get it cured.");
			    case 4: SendClientMessage(playerid, COLOR_GREY, "You received Mad Cow Disease. Go to the hospital, quickly to get it cured.");
			}
			
			format(string, 128, "You raped %s and gave him %s!", VictimName, DiseaseNames[rand]);
			format(string2, 128, "%s has raped you and given you %s!",RapistName, DiseaseNames[rand]);
			format(string3, 128, "%s has raped %s and infected him with %s!", RapistName, VictimName, DiseaseNames[rand]);
			
			SendClientMessage(playerid, COLOR_PINK, string);
			SendClientMessage(targetid, COLOR_ORANGE, string2);
			SendClientMessageToAll(COLOR_YELLOW, string3);
		}
	}
	return 1;
}
Reply
#2

Arrest command: Look this:
pawn Код:
if(GetPlayerWantedLevel(CriminalID) >= 3)

Rape:
pawn Код:
pInfo[playerid][Diseases] = rand;
// No, this: ->
pInfo[targetid][Diseases] = rand;

// and not:
switch(rand)
{
    case 0: SendClientMessage(playerid, COLOR_GREY, "You are lucky this time, you didn't get any STDs!");
    case 1: SendClientMessage(playerid, COLOR_GREY, "You received an HIV. Go to the hospital, quickly to get it cured.");
    case 2: SendClientMessage(playerid, COLOR_GREY, "You received Syphilis. Go to the hospital, quickly to get it cured.");
    case 3: SendClientMessage(playerid, COLOR_GREY, "You received the Crazy Chicken Flu. Go to the hospital, quickly to get it cured.");
    case 4: SendClientMessage(playerid, COLOR_GREY, "You received Mad Cow Disease. Go to the hospital, quickly to get it cured.");
}

// but this:
switch(rand)
{
    case 0: SendClientMessage(targetid, COLOR_GREY, "You are lucky this time, you didn't get any STDs!");
    case 1: SendClientMessage(targetid, COLOR_GREY, "You received an HIV. Go to the hospital, quickly to get it cured.");
    case 2: SendClientMessage(targetid, COLOR_GREY, "You received Syphilis. Go to the hospital, quickly to get it cured.");
    case 3: SendClientMessage(targetid, COLOR_GREY, "You received the Crazy Chicken Flu. Go to the hospital, quickly to get it cured.");
    case 4: SendClientMessage(targetid, COLOR_GREY, "You received Mad Cow Disease. Go to the hospital, quickly to get it cured.");
}
Reply
#3

Thanks. But can anyone fix the arrest command?
Reply
#4

I've taken note of how I was using GetPlayerWantedLevel in the wrong way, and now I can't figure out how to make it the right way.

I got some errors:


Код:
C:\Users\X\Desktop\X\gamemodes\X.pwn(1019) : warning 219: local variable "WantedLevel" shadows a variable at a preceding level
C:\Users\X\Desktop\X\gamemodes\X.pwn(1020) : error 022: must be lvalue (non-constant)
C:\Users\X\Desktop\X\gamemodes\X.pwn(1021) : warning 213: tag mismatch
C:\Users\X\Desktop\X\gamemodes\X.pwn(1021) : warning 205: redundant code: constant expression is zero
C:\Users\X\Desktop\X\gamemodes\X.pwn(1019) : warning 203: symbol is never used: "WantedLevel"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
Lines:
Код:
1019:	 new WantedLevel;
1020: WantedLevel = GetPlayerWantedLevel(CriminalID);
1021: if(!WantedLevel >= 3) return SendClientMessage(playerid, COLOR_RED, "That player does not have a Wanted Level above 3.");
Thank you for the help.
Reply
#5

we can help you with arrest command but not rape because that's offensive
Reply
#6

Try this:
pawn Код:
new WantedLvl;
WantedLvl = GetPlayerWantedLevel(CriminalID);
if(WantedLvl < 3) return SendClientMessage(playerid, COLOR_RED, "That player does not have a Wanted Level above or equal 3.");
Reply
#7

Quote:
Originally Posted by awsomedude
Посмотреть сообщение
Try this:
pawn Код:
new WantedLvl;
WantedLvl = GetPlayerWantedLevel(CriminalID);
if(!WantedLvl >= 3) return SendClientMessage(playerid, COLOR_RED, "That player does not have a Wanted Level above 3.");
I got a tag mismatch on the if(!WantedLvl ....
Reply
#8

remove the ! like this if(WantedLvl >= 3)
Reply
#9

pawn Код:
if(GetPlayerWantedLevel(CriminalID >= 1 && GetPlayerWantedLevel(CriminalID) <= 6)
Use this for the arrest command.

By the way, The idea of disease is amzing , Good luck.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)