Dcmd (/command id)
#6

Here is my code:
Код:
dcmd_rob(playerid,params[])
{
	new string[128];
	new ID;
	if(sscanf(params, "u", ID))
	{
	    SendClientMessage(playerid,COLOR_RED,"USAGE: /rob (Player Name/ID)");
	    return 1;
	}
    if(IsSpawned[playerid] != 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You must be alive and spawned in order to be able to use this command.");
	    return 1;
	}

	if(InAdminMode[ID] == 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You cannot use this command on this player because they are in Administrator mode.");
	    return 1;
	}
	if(IsKidnapped[playerid] == 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You are kidnapped. You cannot use this command.");
	    return 1;
	}
	if(gTeam[playerid] != TEAM_CONARTIST&&gTeam[playerid] != TEAM_PICKPOCKET)
	{
	    SendClientMessage(playerid,COLOR_RED,"Only Con Artist And Pickpocket Can Rob Players.");
	    return 1;
	}
	if(!IsPlayerConnected(ID))
	{
	    format(string,sizeof(string),"The player ID (%d) is not connected to the server. You cannot rob them",ID);
	    SendClientMessage(playerid,COLOR_RED,string);
	    return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) > 4)
	{
	    format(string,sizeof(string),"%s(%d) is too far away. You cannot reach him to rob him.",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_RED,string);
	    return 1;
	}
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
	{
	    SendClientMessage(playerid,COLOR_RED,"You cannot rob someone while in a vehicle. Exit the vehicle first.");
	    return 1;
	}
	if(GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
	{
	    SendClientMessage(playerid,COLOR_RED,"You cannot rob someone while they are in a vehicle. Get them to exit the vehicle first.");
	    return 1;
	}
	if(playerid == ID)
	{
	    SendClientMessage(playerid,COLOR_RED,"You cannot rob yourself!");
	    return 1;
	}
	if(IsSpawned[ID] != 1)
	{
	    format(string,sizeof(string),"%s(%d) is not spawned. You cannot rob dead people ..",PlayerName(ID),ID);
	    SendClientMessage(playerid,COLOR_RED,string);
	    return 1;
	}

	if(AttemptedToRobRecently[playerid] >= 1)
	{
		SendClientMessage(playerid,COLOR_RED,"You are too tired from your last rob attempt. Please wait before robbing again.");
		return 1;
	}
	if(HasRobbedRecently[playerid] >= 1)
	{
	    SendClientMessage(playerid,COLOR_RED,"You are too tired from the last person you robbed. Please wait before robbing again.");
	    return 1;
	}
	if(GetPlayerMoney(ID) <= 0)
	{
	    SendClientMessage(playerid,COLOR_RED,"That player has no money in their pockets. What would be the point in robbing them?");
	    return 1;
	}
	new crand = random(100);
	if(crand <= 30 && gTeam[playerid] == TEAM_CONARTIST)
	{
	    format(string,sizeof(string),"You failed to rob %s(%d). ",PlayerName(ID),ID);
		AttemptedToRobRecently[playerid] =35;
		return 1;
	}
	if(crand <= 65 && gTeam[playerid] == TEAM_PICKPOCKET)
	{
	    format(string,sizeof(string),"You have robbed $%d from %s(%d). Careful they dont come after you!",PlayerName(ID),ID);
		AttemptedToRobRecently[playerid] =35;
		return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) <= 4 && crand > 70&& gTeam[playerid] == TEAM_CONARTIST)
	{
	    new current_zone = player_zone[playerid];
	    new RobMoney = floatround( floatmul( GetPlayerMoney(ID), 0.25 ), floatround_ceil );
		GivePlayerMoney(playerid, RobMoney);
		GivePlayerMoney(ID, -RobMoney);
	    SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Player Robbed_]]");
	    format(string,sizeof(string),"You have robbed $%d from %s(%d). Careful they dont come after you!",RobMoney,PlayerName(ID),ID);
		SendClientMessage(playerid,COLOR_LIGHTBLUE,string);

		SetPlayerWantedLevel(playerid,2);
		HasRobbedRecently[playerid] =60;
		IncreasePlayerScore(playerid,3);

	    format(string,sizeof(string),"There is $%d robbed from you by %s(%d).",RobMoney,PlayerName(playerid),playerid);
		SendClientMessage(ID,COLOR_RED,string);


		format(string,sizeof(string),"[POLICE RADIO] Robbery: %s(%d) has robbed $%d from %s(%d). Location: %s.",PlayerName(playerid),playerid,RobMoney,PlayerName(ID),ID,zones[current_zone][zone_name]);
		SendClientMessageToAllCops(string);
		return 1;
	}
	if(GetDistanceBetweenPlayers(playerid,ID) <= 4 && crand > 35&& gTeam[playerid] == TEAM_PICKPOCKET)
	{
	    new current_zone = player_zone[playerid];
	    new RobMoney = floatround( floatmul( GetPlayerMoney(ID), 0.38 ), floatround_ceil );
		GivePlayerMoney(playerid, RobMoney);
		GivePlayerMoney(ID, -RobMoney);
	    SendClientMessage(playerid,COLOR_DEADCONNECT,"[[_Player Robbed_]]");
	    format(string,sizeof(string),"You have robbed $%d from %s(%d). Careful they dont come after you!",RobMoney,PlayerName(ID),ID);
		SendClientMessage(playerid,COLOR_RED,string);

		SetPlayerWantedLevel(playerid,2);
		HasRobbedRecently[playerid] =60;
		IncreasePlayerScore(playerid,3);

	    format(string,sizeof(string),"You have had $%d robbed from you by %s(%d).",RobMoney,PlayerName(playerid),playerid);
		SendClientMessage(ID,COLOR_RED,string);


		format(string,sizeof(string),"[POLICE RADIO] Robbery: %s(%d) has robbed $%d from %s(%d). Location: %s.",PlayerName(playerid),playerid,RobMoney,PlayerName(ID),ID,zones[current_zone][zone_name]);
		SendClientMessageToAllCops(string);
		return 1;
	}
	return 1;
}
Pls help
Reply


Messages In This Thread
Dcmd (/command id) - by Admigo - 21.03.2012, 21:20
Re: Dcmd (/command id) - by Soulbad - 21.03.2012, 21:23
Re: Dcmd (/command id) - by Bogdan1992 - 21.03.2012, 21:24
Re: Dcmd (/command id) - by _Shade. - 21.03.2012, 21:24
Re: Dcmd (/command id) - by Tanush123 - 21.03.2012, 21:24
Re: Dcmd (/command id) - by Admigo - 22.03.2012, 14:50
Re: Dcmd (/command id) - by Bogdan1992 - 22.03.2012, 14:53
Re: Dcmd (/command id) - by Admigo - 22.03.2012, 15:24
Re: Dcmd (/command id) - by Laronic - 22.03.2012, 15:26
Re: Dcmd (/command id) - by RicaNiel - 22.03.2012, 15:27

Forum Jump:


Users browsing this thread: 1 Guest(s)