Need little help on /robbus command
#1

i Have done made an /robbus command for robbing an business. But i think its not 100% good because player still can rob their own business or an business which not own by someone. I need help, how to modif this script so player cannot rob their own business, also they cant rob an business which not owner by someone (for sale). Here is the code below :

Code:
CMD:robbus(playerid, params[])
{
	new playername[25], tmp[256], tmp2[256];
 	if (playedtime[playerid][0] < 25) return SendClientMessage2(playerid, COLOR_RED, "Error: You must reach level 25 to use this command.");
    if(dini_Int(AddDirFile(dir_userfiles, playername), "Freeroam") == 1 && dini_Int(AddDirFile(dir_userfiles, playername), "Roleplay") == 0) return SendClientMessage(playerid, COLOR_RED, "Error: Your gameplay state must be roleplay.");
	if (GetPlayerSkin(playerid) != pdfs[playerid] || GetPVarInt(playerid, "podfskin") != -1) return SendClientMessage2(playerid, COLOR_RED, "You are not in a civilian state (/civil).");
 	if (cptype[pdynamiccp[playerid]][0] != CP_TYPE_BUS) return SendClientMessage2(playerid, COLOR_RED, "You must be at a business to rob it!");
    GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
    new year, month, day;
	getdate(year, month, day);
	if (month < 10) year *= 10;
	if (day < 10) month *= 10;
	format(tmp, 9, "%d%d%d", year, month, day);
	new temp1 = strval(tmp);
	if (temp1 == dini_Int(AddDirFile(dir_userfiles, playername), "robbedbus")) return SendClientMessage2(playerid, COLOR_RED, "Your have already robbed a business today.");
	dini_IntSet(AddDirFile(dir_userfiles, playername), "robbedbus", temp1);
	temp1 = MRandom(25001)+5000;
	GivePlayerMoney(playerid, temp1);
	new moneys1 = GetPlayerWantedLevel(playerid);
	if (moneys1 < 4)
	{
		SetPlayerWantedLevel(playerid, 4);
		dini_IntSet(AddDirFile(dir_userfiles, playername), "Wanted", 4);
		SetPVarString(playerid, "WReason", "Business Robery");
	}
	else if (moneys1 != 6)
	{
		SetPlayerWantedLevel(playerid, moneys1+1);
		dini_IntSet(AddDirFile(dir_userfiles, playername), "Wanted", moneys1+1);
		SetPVarString(playerid, "WReason", "Business Robery");
	}
	new rand = MRandom(19)+3;
	for (new i = 0; i < PLAYERS; i++)
	{
		if (!IsPlayerConnected2(i) || GetPVarInt(i, "playerorg") == 0) continue;
		if (IsALaw(i) && GetPlayerWantedLevel(i) == 0) PlayCrimeReportForPlayer(i, playerid, rand);
	}
	format(tmp2, sizeof(tmp2), "~ %s has robbed the business in %s for $%d.", playername, zonenames[playerZone[playerid]][z_name], temp1);
	SendClientMessageToAll2(COLOR_SILVER, tmp2);
	dini_IntSet(AddDirFile(dir_userfiles, playername), "BusRob", dini_Int(AddDirFile(dir_userfiles, playername), "BusRob")+1);
	return 1;
}
Reply
#2

for warning text add "Error: You cannot rob your own business" and "Error: This business is not belong to anyone"
Reply
#3

Why don't you just check the players name on the business and if the player name == "playername" from GetPlayerName (...) then, deny them the permission to rob.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)