/contract bug.
#1

So, I've been using this code for a while now, and it's been working fine, but I updated my script a few days ago and ever since, it does this:
http://imgur.com/RAmRy,gAWN4

This is the code for /contract:
pawn Код:
CMD:contract(playerid, params[]) {
    new
        target[MAX_PLAYER_NAME],
        targetid,
        price,
        contracter[MAX_PLAYER_NAME],
        msg[128],
        reason[128];
    if(sscanf(params, "uds", targetid, price, reason)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /contract [playerid] [price] [reason]");
   
    else if(price < 50000 || price > 1000000) {
    return SendClientMessage(playerid, COLOR_GREY, "Invalid price specified!");
    }
    else if(playerVariables[playerid][pMoney] < price) {
    return SendClientMessage(playerid, COLOR_GREY, "Not enough money!");
    }
    else if(playerVariables[targetid][pContracted] == 1) {
    return SendClientMessage(playerid, COLOR_GREY, "Unable to submit a contract at this time!");
    }
    else if(price >= 50000 && price < 1000000 && playerVariables[playerid][pMoney] >= price) {
    GetPlayerName(playerid, contracter, sizeof contracter);
    GetPlayerName(targetid, target, sizeof target);
    format(msg, sizeof(msg), "[CONTRACT] You have contracted %s for $%i. (Reason: %s)", target, price, reason);
    SendClientMessage(playerid, COLOR_SMS, msg);
    playerVariables[playerid][pMoney] -= price;
    playerVariables[targetid][pContracted] = 1;
    playerVariables[targetid][pHitPrice] = price;
    foreach(Player, x) {
    if(playerVariables[x][pGroup] == 5) {
    new
        assigner[MAX_PLAYER_NAME];
    GetPlayerName(playerid, assigner, sizeof assigner);
    format(msg, sizeof(msg), "[CONTRACT] %s has contracted %s for $%i. || /recievehit [id]", assigner, playerVariables[targetid][pHitPrice]);
    SendClientMessage(x, COLOR_SMS, msg);
    }
    }
    }
    return 1;
}
and the code for /recievehit:
pawn Код:
CMD:recievehit(playerid, params[]) {
    new
        target[MAX_PLAYER_NAME],
        targetid,
        msg[128],
        name[MAX_PLAYER_NAME];
    if(playerVariables[playerid][pGroup] == 5) {
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /recievehit [id]");
   
    else if(playerVariables[targetid][pContracted] == 0) {
    return SendClientMessage(playerid, COLOR_GREY, "That user does not have a contract on them at this time!");
    }
    else if(playerVariables[targetid][pContracted] == 1)
    {
    GetPlayerName(targetid, target, sizeof target);
    GetPlayerName(playerid, name, sizeof name);
    format(msg, sizeof(msg), "[CONTRACT]"EMBED_WHITE" You have taken the contract on %s.", target);
    SendClientMessage(playerid, COLOR_LIGHTRED, msg);
    playerVariables[playerid][pAssignedTo] = targetid;
    playerVariables[targetid][pToDie] = 1;
    foreach(Player, x) {
    if(playerVariables[x][pGroup] == 5) {
    format(msg, sizeof(msg), "[HIT RECIEVED] Hitman %s has taken the hit on %s!", name, target);
    SendClientMessage(x, COLOR_LIGHTRED, msg);
    }
    }
    }
    }
    return 1;
}
Reply
#2

Ok Try this,this will work
Код:
CMD:contract(playerid, params[])
{
	if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't place contracts while in cuffs.");
	if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't place contracts while in jail.");

	new string[128], giveplayerid, moneys, detail[32];
	if(sscanf(params, "uds[32]", giveplayerid, moneys, detail)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /contract [playerid] [amount] [details]");

	if( moneys < 50000 || moneys > 1000000)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You can't place contracts that are less than $50,000 or more than $1,000,000.");
		return 1;
	}
	else if((moneys < 100000 || moneys > 1000000) && IsACop(giveplayerid))
	{
		SendClientMessageEx(playerid, COLOR_GREY, "The minimum hit amount for a law enforcement officer is $100,000.");
		return 1;
	}
	if(PlayerInfo[playerid][pLevel] < 3)
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You must be level 3 to place a contract.");
		return 1;
	}
	if(PlayerInfo[giveplayerid][pConnectTime] < 5)
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You can not place contracts on players with less than 5 playing hours.");
		return 1;
	}
	if (IsPlayerConnected(giveplayerid))
	{
		if( PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pMember] == 8 )
		{
			SendClientMessageEx( playerid, COLOR_GREY, "You can't place contracts as a hitman." );
		}
		else
		{
			if(giveplayerid != INVALID_PLAYER_ID)
			{
				if( moneys >= 1000001 )
				{
					SendClientMessageEx( playerid, COLOR_GREY, "The maximum contract price is $1,000,000!" );
					return 1;
				}

				if( PlayerInfo[giveplayerid][pHeadValue] >= 1000000 )
				{
					SendClientMessageEx( playerid, COLOR_GREY, "That player has the maximum on their head." );
					return 1;
				}
				if(moneys + PlayerInfo[giveplayerid][pHeadValue] >= 1000001 )
				{
					SendClientMessageEx( playerid, COLOR_GREY, "That player has the maximum on their head." );
					return 1;
				}

				if(giveplayerid == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "You can't contract yourself."); return 1; }
				new playermoney = GetPlayerCash(playerid);
				if (moneys > 0 && playermoney >= moneys)
				{
					if(strlen(detail) > 32) return SendClientMessageEx(playerid, COLOR_GRAD1, "Contract details may not be longer than 32 characters in length.");
					GivePlayerCash(playerid, (0 - moneys));
					PlayerInfo[giveplayerid][pHeadValue]+=moneys;
					strmid(PlayerInfo[giveplayerid][pContractBy], GetPlayerNameEx(playerid), 0, strlen(GetPlayerNameEx(playerid)), MAX_PLAYER_NAME);
					strmid(PlayerInfo[giveplayerid][pContractDetail], detail, 0, strlen(detail), 32);
					format(string, sizeof(string), "%s has placed a contract on %s for $%d, details: %s.",GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), moneys, detail);
					SendFamilyMessage(8, COLOR_YELLOW, string);
					format(string, sizeof(string), "* You placed a contract on %s for $%d, details: %s.",GetPlayerNameEx(giveplayerid), moneys, detail);
					SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
					new year, month,day;
					new hour,minuite,second;
					getdate(year, month, day);
					gettime(hour,minuite,second);
					format(string, sizeof(string), "<< %s has placed a contract on %s for $%d, details: %s (%d-%d-%d)(%d:%d) >>",GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid),moneys,detail,month,day,year,hour,minuite);
					Log("logs/contracts.log", string);
					format(string, sizeof(string), "%s has placed a contract on %s for $%d, details: %s.",GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), moneys, detail);
					ABroadCast(COLOR_YELLOW,string,4);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				}
				else
				{
					SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have enough money for this.");
				}
			}
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	return 1;
}
And For The /recievehit
Код:
CMD:recievehit(playerid, params[])
{
	if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
	{
		new string[128], targetid;
		if(sscanf(params, "u", targetid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /recievehit [targetid]");

		if(IsPlayerConnected(targetid))
		{
			if(GoChase[playerid] < 999)
			{
				SendClientMessageEx(playerid, COLOR_GREY, "   You are already busy with another contract!");
				return 1;
			}
			if(GotHit[targetid] == 1)
			{
				SendClientMessageEx(playerid, COLOR_GREY, "   Another hitman has already assigned this target!");
				return 1;
			}
			if(PlayerInfo[targetid][pHeadValue] == 0)
			{
				SendClientMessageEx(playerid, COLOR_GREY, "   That target doesn't have a contract on them!");
				return 1;
			}
			format(string, sizeof(string), "* You have offered yourself a contract to kill %s. (type /accept contract)", GetPlayerNameEx(targetid));
			SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
			HitOffer[playerid] = playerid;
			HitToGet[playerid] = targetid;
			return 1;
		}
		else
		{
			SendClientMessageEx(playerid, COLOR_GREY, "   The contracted person is offline, use /contracts!");
			return 1;
		}
	}
	return 1;
}
Reply
#3

Ok Try this,this will work
Код:
CMD:contract(playerid, params[])
{
	if(PlayerCuffed[playerid] != 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't place contracts while in cuffs.");
	if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessageEx(playerid, COLOR_GREY, "You can't place contracts while in jail.");

	new string[128], giveplayerid, moneys, detail[32];
	if(sscanf(params, "uds[32]", giveplayerid, moneys, detail)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /contract [playerid] [amount] [details]");

	if( moneys < 50000 || moneys > 1000000)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You can't place contracts that are less than $50,000 or more than $1,000,000.");
		return 1;
	}
	else if((moneys < 100000 || moneys > 1000000) && IsACop(giveplayerid))
	{
		SendClientMessageEx(playerid, COLOR_GREY, "The minimum hit amount for a law enforcement officer is $100,000.");
		return 1;
	}
	if(PlayerInfo[playerid][pLevel] < 3)
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You must be level 3 to place a contract.");
		return 1;
	}
	if(PlayerInfo[giveplayerid][pConnectTime] < 5)
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "You can not place contracts on players with less than 5 playing hours.");
		return 1;
	}
	if (IsPlayerConnected(giveplayerid))
	{
		if( PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pMember] == 8 )
		{
			SendClientMessageEx( playerid, COLOR_GREY, "You can't place contracts as a hitman." );
		}
		else
		{
			if(giveplayerid != INVALID_PLAYER_ID)
			{
				if( moneys >= 1000001 )
				{
					SendClientMessageEx( playerid, COLOR_GREY, "The maximum contract price is $1,000,000!" );
					return 1;
				}

				if( PlayerInfo[giveplayerid][pHeadValue] >= 1000000 )
				{
					SendClientMessageEx( playerid, COLOR_GREY, "That player has the maximum on their head." );
					return 1;
				}
				if(moneys + PlayerInfo[giveplayerid][pHeadValue] >= 1000001 )
				{
					SendClientMessageEx( playerid, COLOR_GREY, "That player has the maximum on their head." );
					return 1;
				}

				if(giveplayerid == playerid) { SendClientMessageEx(playerid, COLOR_GREY, "You can't contract yourself."); return 1; }
				new playermoney = GetPlayerCash(playerid);
				if (moneys > 0 && playermoney >= moneys)
				{
					if(strlen(detail) > 32) return SendClientMessageEx(playerid, COLOR_GRAD1, "Contract details may not be longer than 32 characters in length.");
					GivePlayerCash(playerid, (0 - moneys));
					PlayerInfo[giveplayerid][pHeadValue]+=moneys;
					strmid(PlayerInfo[giveplayerid][pContractBy], GetPlayerNameEx(playerid), 0, strlen(GetPlayerNameEx(playerid)), MAX_PLAYER_NAME);
					strmid(PlayerInfo[giveplayerid][pContractDetail], detail, 0, strlen(detail), 32);
					format(string, sizeof(string), "%s has placed a contract on %s for $%d, details: %s.",GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), moneys, detail);
					SendFamilyMessage(8, COLOR_YELLOW, string);
					format(string, sizeof(string), "* You placed a contract on %s for $%d, details: %s.",GetPlayerNameEx(giveplayerid), moneys, detail);
					SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
					new year, month,day;
					new hour,minuite,second;
					getdate(year, month, day);
					gettime(hour,minuite,second);
					format(string, sizeof(string), "<< %s has placed a contract on %s for $%d, details: %s (%d-%d-%d)(%d:%d) >>",GetPlayerNameEx(playerid),GetPlayerNameEx(giveplayerid),moneys,detail,month,day,year,hour,minuite);
					Log("logs/contracts.log", string);
					format(string, sizeof(string), "%s has placed a contract on %s for $%d, details: %s.",GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), moneys, detail);
					ABroadCast(COLOR_YELLOW,string,4);
					PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
				}
				else
				{
					SendClientMessageEx(playerid, COLOR_GRAD1, "You don't have enough money for this.");
				}
			}
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	return 1;
}
And For The /recievehit
Код:
CMD:recievehit(playerid, params[])
{
	if(PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pLeader] == 8)
	{
		new string[128], targetid;
		if(sscanf(params, "u", targetid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /recievehit [targetid]");

		if(IsPlayerConnected(targetid))
		{
			if(GoChase[playerid] < 999)
			{
				SendClientMessageEx(playerid, COLOR_GREY, "   You are already busy with another contract!");
				return 1;
			}
			if(GotHit[targetid] == 1)
			{
				SendClientMessageEx(playerid, COLOR_GREY, "   Another hitman has already assigned this target!");
				return 1;
			}
			if(PlayerInfo[targetid][pHeadValue] == 0)
			{
				SendClientMessageEx(playerid, COLOR_GREY, "   That target doesn't have a contract on them!");
				return 1;
			}
			format(string, sizeof(string), "* You have offered yourself a contract to kill %s. (type /accept contract)", GetPlayerNameEx(targetid));
			SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
			HitOffer[playerid] = playerid;
			HitToGet[playerid] = targetid;
			return 1;
		}
		else
		{
			SendClientMessageEx(playerid, COLOR_GREY, "   The contracted person is offline, use /contracts!");
			return 1;
		}
	}
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)