Bugged placehit Command
#1

Hello everyone, my placehit command is bugged. I will try to explain.
When ''PLAYER A'' placed a hit on ''PLAYER B'', and ''PLAYER A'' killed ''PLAYER B'', ''PLAYER A'' gets the money of the hit. (It's not refund!) and player A gets profit, lol

Here is my placehit command
Quote:
Код:
dcmd_placehit(playerid, params[])
{
    new amount, ID;
    if (sscanf(params, "dd", ID, amount)) {
	SendClientMessage(playerid, COLOR_ERROR, "USAGE: /placehit [ID] [amount]");
    } else if (amount > 0) {
	if (IsPlayerConnected(ID)) {
	    if (gTeam[playerid] != COP && gTeam[playerid] != SWAT && gTeam[playerid] != FBI && gTeam[playerid] != ARMY) {
		if (GetPlayerMoney(playerid) >= amount) {
		    if (antispam[playerid] == 0) {
			hit[ID] = amount;
			hiter[ID] = playerid;
			new string[256];
			format(string, sizeof(string), ">> You have placed a hit on %s (%i) for $%i", ReturnPlayerName(ID), ID, amount);
			SendClientMessage(playerid, COLOR_MSG, string);
			format(string, sizeof(string), "[HIT PLACED] %s (%i) has placed a hit on %s (%i) for $%i", ReturnPlayerName(playerid), playerid, ReturnPlayerName(ID), ID, amount);
			SendClientMessageToAll(COLOR_MSG, string);
			antispam[playerid] = 1;
			SetTimerEx("antispamtimer", ANTISPAM_TIME * 1000, false, "d", playerid);
		    } else
			SendClientMessage(playerid, COLOR_ERROR, "Please wait before placing another hit!");
		} else
		    SendClientMessage(playerid, COLOR_ERROR, "You do not have enough money!");
	    } else
		SendClientMessage(playerid, COLOR_ERROR, "You can't hit a player because of your skill/class!");
	} else
	    SendClientMessage(playerid, COLOR_ERROR, "This player is not connected!");
    } else
	SendClientMessage(playerid, COLOR_ERROR, "Minimum amount to hit a person with is $1!");
    return 1;
}
Reply
#2

Bump
Reply
#3

Bump
Reply
#4

Perhaps you could use an indentation style which actually makes code more readable, as opposed to that atrocity.
Reply
#5

Placing a hit doesn't matter.
You must use the OnPlayerDeath for this.
example code since I don't know your variables:
Код:
		if(PlayerStat[playerid][pBounty] >= 1)
		{
			if(IsPlayerConnected(killerid))
			{
				if(PlayerStat[killerid][OnHit] == 1)
				{
				    new string[128];
					new takemoney = PlayerStat[playerid][pBounty] * 3 / 4;
					GiveMoney(killerid, takemoney);
					GiveMoney(playerid, -takemoney);
					format(string,128,"Hitman %s has completed his job on %s and claimed the bounty which is $%d.", GetICName(killerid), GetICName(playerid), PlayerStat[playerid][pBounty] / 2);
					SendHitmanMessage(playerid, COLOR_DARKRED, string);
					format(string,128,"A Hitman Member was sent after you, and eventually finished his job, you lost $%d as a result.",takemoney);
					SCM(playerid, COLOR_DARKRED, string);
					PlayerStat[playerid][pBounty] = 0;
					PlayerStat[killerid][OnHit] = 0;
				}
			}
		}
That's pretty much how it should look like, good luck!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)