Help with /contract.
#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


Messages In This Thread
Help with /contract. - by Laure - 08.11.2012, 09:45
Re: Help with /contract. - by xtr3mepWnaGe - 08.11.2012, 10:59
Re: Help with /contract. - by Laure - 08.11.2012, 11:18
Re: Help with /contract. - by xMCx - 08.11.2012, 11:23
Re: Help with /contract. - by Laure - 08.11.2012, 11:43

Forum Jump:


Users browsing this thread: 2 Guest(s)