Help with /contract.
#1

The hitman command is not working properly./contract is gone for no use when a hitman use contract on a player it says you already have a contract placed on that player.The Code
Код:
CMD:contract(playerid, params[])
{
	new string[128], playerb, amount;
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /contract [playerid] [amount]");
	if(IsAHitman(playerid)) return SendClientMessage(playerid, COLOR_GREY, "No... just no Motherfucker!");
	if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You must be at least level 3 to make a contract on someone.");
	if(amount < 3000 || amount > 50000) return SendClientMessage(playerid, COLOR_GREY, "Contracts are between $3000 and $50,000.");
	if(PlayerInfo[playerid][pMoney] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much on you at the moment.");
	if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
	if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't contract yourself.");
	if(PlayerInfo[playerb][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You can't contract people under level 3.");
	if(!strcmp(RPN(playerid), PlayerInfo[playerb][pContractBy], false)) return SendClientMessage(playerid, COLOR_GREY, "You have already placed a contract on this player.");
	if(PlayerInfo[playerb][pContract] >= 150000) return SendClientMessage(playerid, COLOR_GREY, "Player has the maximum contract amount on his head already.");
	PlayerInfo[playerb][pContract] += amount;
	format(PlayerInfo[playerb][pContractBy], 32, "%s", RPN(playerid));
	GiveSanzilMoney(playerid, -amount);
	format(string, sizeof(string), "HitmanWarn: %s has placed a contract on %s for $%d.", RPN(playerid), RPN(playerb), amount);
	SendHitmanMessage(COLOR_YELLOW, string);
	SendAdminMessage(COLOR_DARKRED, 3, string);
	Log("logs/contract.log", string);
	return 1;
}
Reply
#2

try this. and +rep if it worked for you.
it has anti-spam.

Код:
if(strcmp(cmd, "/contract", true) == 0)
	{
		if(IsPlayerConnected(playerid))
	   	{
	   	    if( SpamUnmute[playerid] >= 1 )
			{
	    		SendClientMessage(playerid, COLOR_WHITE, "You are muted from submitting this command right now.");
	    		return 1;
			}
			if(PlayerCuffed[playerid] != 0) return SendClientMessage(playerid, COLOR_GREY, "You can't place contracts while in cuffs.");
			if(PlayerInfo[playerid][pJailTime] > 0) return SendClientMessage(playerid, COLOR_GREY, "You can't place contracts while in jail.");
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /contract [player] [amount] [details]");
				return 1;
			}
			giveplayerid = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /contract [player] [amount] [details]");
				return 1;
			}
			moneys = strval(tmp);
			if( moneys < 15000 || moneys > 600000 )
			{
				SendClientMessage(playerid, COLOR_GREY, "You can't place contracts that are less than $15,000 or more than $600,000.");
				return 1;
			}
			else if((moneys < 75000 || moneys > 600000) && IsACop(giveplayerid))
			{
				SendClientMessage(playerid, COLOR_GREY, "The minimum hit amount for a law enforcement officer is $75,000.");
				return 1;
			}
			if(PlayerInfo[playerid][pLevel] < 3)
			{
				SendClientMessage(playerid, COLOR_GRAD1, "You must be level 3 to place a contract.");
				return 1;
			}
			if (IsPlayerConnected(giveplayerid))
			{
			    if( PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pMember] == 8 )
			    {
			        SendClientMessage( playerid, COLOR_GREY, "You can't place contracts as a hitman." );
			    }
			    else
			    {
					if(giveplayerid != INVALID_PLAYER_ID)
					{
					    if( moneys >= 600001 )
					    {
					        SendClientMessage( playerid, COLOR_GREY, "The maximum contract price is $600,000!" );
					        return 1;
					    }

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

						if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "You can't contract yourself."); return 1; }
						playermoney = GetPlayerCash(playerid);
						if (moneys > 0 && playermoney >= moneys)
						{
						    SpamCount[playerid]++;
							if( SpamCount[playerid] == 4 )
							{
        						GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
        						format(string, sizeof(string), "AdmWarning: %s (ID %d) has been muted temporarily for spamming, they tried to spam '%s'", sendername, playerid, cmdtext );
        						ABroadCast( COLOR_YELLOW, string, 1);
        						SetTimerEx("OtherTimerEx", 1000, false, "ii", playerid, TYPE_FLOODPROTECTION);
        						SpamUnmute[playerid] = 10;
        						SpamCount[playerid] = 0;
        						SendClientMessage(playerid, COLOR_WHITE, "You have been muted for 10 seconds, which means you can't submit any new commands/text.");
	    						return 1;
							}
							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_GRAD1, "USAGE: /contract [player] [amount] [details]");
								return 1;
							}
							if(strlen(result) > 32) return SendClientMessage(playerid, COLOR_GRAD1, "Contract details may not be longer than 32 characters in length.");
							GivePlayerCash(playerid, (0 - moneys));
							PlayerInfo[giveplayerid][pHeadValue]+=moneys;
							GetPlayerName(playerid, sendername, sizeof(sendername));
							format(string, sizeof(string), "%s", sendername);
							strmid(PlayerInfo[giveplayerid][pContractBy], string, 0, strlen(string), MAX_PLAYER_NAME);
							strmid(PlayerInfo[giveplayerid][pContractDetail], result, 0, strlen(result), 32);
							giveplayer = GetPlayerNameEx(giveplayerid);
							sendername = GetPlayerNameEx(playerid);
							format(string, sizeof(string), "%s has placed a contract on %s for $%d, details: %s.",sendername, giveplayer, moneys, result);
							SendFamilyMessage(8, COLOR_YELLOW, string);
							format(string, sizeof(string), "* You placed a contract on %s for $%d, details: %s.",giveplayer, moneys, result);
							SendClientMessage(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,result,month,day,year,hour,minuite);
							ContractLog(string);
							format(string, sizeof(string), "%s has placed a contract on %s for $%d, details: %s.",sendername, giveplayer, moneys, result);
							ABroadCast(COLOR_YELLOW,string,4);
							PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
						}
						else
						{
							SendClientMessage(playerid, COLOR_GRAD1, "You don't have enough money for this.");
						}
					}
				}
			}
			else
			{
				format(string, sizeof(string), "%d is not an active player.", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
	return 1;
}
Reply
#3

lol just copying and pasting from a script wont help me sorry.If just mean to copy then i can simply copy from a script and paste into my script but i cant learn what made the problem.Anyway thanks for trying to help.
Reply
#4

try to add a param to show if the player has contract on him or not under enum like
pContracted, then do like
pawn Код:
if(PlayerInfo[playerid][pContracted] == 0){
then in the last
pawn Код:
PlayerInfo[playerid][pContracted] = 1;
or so, hope it helped
Reply
#5

Found the problem.
Код:
CMD:contract(playerid, params[])
{
	new string[128], playerb, amount;
   	if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
	if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /contract [playerid] [amount]");
	if(IsAHitman(playerb)) return SendClientMessage(playerid, COLOR_GREY, "No... just no Motherfucker!"); // This was something creating the problem i had IsAHitman(playerid)) instead of playerb.
	if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You must be at least level 3 to make a contract on someone.");
	if(amount < 3000 || amount > 50000) return SendClientMessage(playerid, COLOR_GREY, "Contracts are between $3000 and $50,000.");
	if(PlayerInfo[playerid][pMoney] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much on you at the moment.");
	if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Player is not connected.");
	if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't contract yourself.");
	if(PlayerInfo[playerb][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You can't contract people under level 3.");
	if(!strcmp(RPN(playerid), PlayerInfo[playerb][pContractBy], false)) return SendClientMessage(playerid, COLOR_GREY, "You have already placed a contract on this player.");
	if(PlayerInfo[playerb][pContract] >= 150000) return SendClientMessage(playerid, COLOR_GREY, "Player has the maximum contract amount on his head already.");
	PlayerInfo[playerb][pContract] += amount;
	format(PlayerInfo[playerb][pContractBy], 32, "%s", RPN(playerid));
	GiveSanzilMoney(playerid, -amount);
	format(string, sizeof(string), "HitmanWarn: %s has placed a contract on %s for $%d.", RPN(playerid), RPN(playerb), amount);
	SendHitmanMessage(COLOR_YELLOW, string);
	SendAdminMessage(COLOR_DARKRED, 3, string);
	Log("logs/contract.log", string);
	return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)