Hello, Please Can Anyone Tell Me How Can i make Random Money in Rob Command According to Player Money carrying in Pocket.
i want to make that. if targetid get money in pocket more than 1m robber get max money 500k and if less than 1m then robber get 4th part of player money.
PHP код:
dcmd_rob(playerid, params[])
{
if (PlayerInfo[playerid][pSpawn] == 1)
{
if (PlayerInfo[playerid][pTeam] == TEAM_CIVILIAN && PlayerInfo[playerid][pVigilante] == 0)
{
new idx,giveplayerid,string[256],tmp[256],amount;
new Houseid = PlayerInfo[playerid][pLastOutSideID];
if (GetPlayerVirtualWorld(playerid) > 0)
{
if (HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_CITYHALL || HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_RPC ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_24_7 ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_BAR ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_AMMUNATION ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_GYM ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_DINER ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_DONUT ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_BANK ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_SEXSHOP ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_BURGERSHOT ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_WELLSTACKED ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_CLUCKINBELL ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_DM_STADIUM ||
HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_DANCE_CLUB)
{
format(string, sizeof(string), "You Cannot Rob Someone Inside %s.",HouseInfo[Houseid][h_HouseIntName]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
}
tmp = strtok(params, idx);
if(!strlen(tmp))
{
new Players;
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerConnected(i) && i != playerid && PlayerInfo[i][pSpawn] == 1 && GetDistanceBetweenPlayers(playerid,i) < 10)
{
Players ++;
if (Players > 0)giveplayerid = i; break;
}
}
if (Players == 0)
return SendClientMessage(playerid, COLOR_ERROR, "No Players Close Enough To Rob.");
}else{
if(!isNumeric(tmp))
{
giveplayerid = ReturnUser(playerid, tmp);
if(giveplayerid == INVALID_PLAYER_ID)
{
return 1;
}
}
else
{
giveplayerid = strval(tmp);
if(!IsPlayerConnected(giveplayerid))
{
format(string, sizeof(string), "%d Is Not A Valid ID.", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
}
}
if(giveplayerid == playerid)
{
SendClientMessage(playerid, COLOR_ERROR, "Are You Stupid? You Cannot Rob Yourself.");
return 1;
}
if(PlayerInfo[playerid][pJailed] == 1 || PlayerInfo[playerid][pAJailed] == 1)
{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command In Jail.");
return 1;
}
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 3) {
format(string, sizeof(string), "%s (%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(giveplayerid))
{
format(string, sizeof(string), "%s (%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) != PLAYER_STATE_ONFOOT)
{
format(string, sizeof(string), "%s (%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) == PLAYER_STATE_ONFOOT)
{
format(string, sizeof(string), "%s (%d) Is Not Close Enough. You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
if(PlayerInfo[playerid][pRobTime] > 0)
{
SendClientMessage(playerid, COLOR_ERROR, "Please Wait Before Attempting To Rob Someone Again.");
return 1;
}
new robattempt;
if (PlayerInfo[playerid][pSkill] == SKILL_THIEF)robattempt = random(2);
else robattempt = random(4);
if (robattempt == 1)
{
if (GetPlayerCash(giveplayerid) > 100)
{
if (IsSuspectInRangeOfPolice(playerid) && PlayerInfo[playerid][pJailed] == 0)
{
format(string, sizeof(string), "Crime: Robbery - Victim: %s (%d)",PlayerInfo[giveplayerid][pName],giveplayerid);
ReportCrimeTOPolice(playerid,string);
}
PlayerInfo[playerid][pRobTime] = 40;
PlayerInfo[playerid][pRobberies] ++;
PlayerInfo[giveplayerid][pRobbed] ++;
amount = GetPlayerCash(giveplayerid)/4;
format(string, sizeof(string), "You Have Robbed $%d From %s (%d).",amount,PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, string);
format(string, sizeof(string), "~w~Robbed $%d From %s",amount, PlayerInfo[giveplayerid][pName]);
GameTextForPlayer(playerid,string, 4000, 3);
format(string, sizeof(string), "%s (%d) Has Robbed $%d From You.",PlayerInfo[playerid][pName],playerid,amount);
SendClientMessage(giveplayerid, COLOR_SERVER_HELP_MSG, string);
format(string, sizeof(string), "Robbed By %s~n~$%d",PlayerInfo[playerid][pName],amount);
GameTextForPlayer(giveplayerid,string, 4000, 3);
GivePlayerCash(giveplayerid, - amount);
GivePlayerCash(playerid, amount);
SetPlayerScore(playerid,GetPlayerScore(playerid) + 1);
SetPlayerScore(giveplayerid,GetPlayerScore(giveplayerid) - 1);
if(PlayerInfo[playerid][pTeam] != TEAM_LAW && PlayerInfo[playerid][pVigilante] == 0)
{
if(PlayerInfo[playerid][pJailed] == 1)
{
PlayerInfo[giveplayerid][pJailHour] += 2;
PlayerInfo[giveplayerid][pBail] += 1000;
format(string, sizeof(string), "Committed A Crime (Robbery) - Jail Sentence Extended %i Hour %i Minute $%i Bail.",PlayerInfo[giveplayerid][pJailHour],PlayerInfo[giveplayerid][pJailMinute],PlayerInfo[giveplayerid][pBail]);
SendClientMessage(giveplayerid, COLOR_WANTED_LEVEL_5, string);
}else{
if(HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_POLICE && PlayerInfo[playerid][pJailed] == 0)
{
if(PlayerInfo[playerid][pWantedLevel] > 5)
{
PlayerInfo[playerid][pWantedLevel] =10;
SetPlayerWantedStats(playerid,"Robbery");
}else{
PlayerInfo[playerid][pWantedLevel]=6;
SetPlayerWantedStats(playerid,"Robbery");
}
}else{
if(PlayerInfo[giveplayerid][pTeam] == TEAM_LAW || PlayerInfo[giveplayerid][pVigilante] == 1)
{
if(PlayerInfo[playerid][pWantedLevel] > 5)
{
PlayerInfo[playerid][pWantedLevel] =10;
SetPlayerWantedStats(playerid,"Robbery");
}else{
PlayerInfo[playerid][pWantedLevel]=6;
SetPlayerWantedStats(playerid,"Robbery");
}
}else{
if(IsSuspectInRangeOfPolice1(playerid))
{
if(PlayerInfo[playerid][pWantedLevel] > 5)
{
PlayerInfo[playerid][pWantedLevel] =10;
SetPlayerWantedStats(playerid,"Robbery");
}else{
PlayerInfo[playerid][pWantedLevel]+=3;
SetPlayerWantedStats(playerid,"Robbery");
}
}
}
}
}
}
}else{
format(string, sizeof(string), "%s (%d) Is Too Poor To Rob.",PlayerInfo[giveplayerid][pName],giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
}
}else{
if (IsSuspectInRangeOfPolice(playerid) && PlayerInfo[playerid][pJailed] == 0)
{
format(string, sizeof(string), "Crime: Attempted Robbery - Victim: %s (%d)",PlayerInfo[giveplayerid][pName],giveplayerid);
ReportCrimeTOPolice(playerid,string);
}
PlayerInfo[playerid][pRobTime] = 40;
format(string, sizeof(string), "%s (%d) Has Noticed You Trying To Rob %s. Attempt Failed..",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, string);
format(string, sizeof(string), "Attempt To Rob %s Failed",PlayerInfo[giveplayerid][pName]);
GameTextForPlayer(playerid,string, 4000, 3);
format(string, sizeof(string), "%s (%d) Has Attempted To Rob You.",PlayerInfo[playerid][pName],playerid);
SendClientMessage(giveplayerid, COLOR_SERVER_HELP_MSG, string);
if(PlayerInfo[playerid][pTeam] != TEAM_LAW && PlayerInfo[playerid][pVigilante] == 0)
{
if(PlayerInfo[playerid][pJailed] == 1)
{
PlayerInfo[giveplayerid][pJailHour] += 2;
PlayerInfo[giveplayerid][pBail] += 1000;
format(string, sizeof(string), "Committed A Crime (Robbery) - Jail Sentence Extended %i Hour %i Minute $%i Bail.",PlayerInfo[giveplayerid][pJailHour],PlayerInfo[giveplayerid][pJailMinute],PlayerInfo[giveplayerid][pBail]);
SendClientMessage(giveplayerid, COLOR_WANTED_LEVEL_5, string);
}else{
if(HouseInfo[Houseid][h_cpbustype] == BUS_TYPE_POLICE && PlayerInfo[playerid][pJailed] == 0)
{
if(PlayerInfo[playerid][pWantedLevel] > 5)
{
PlayerInfo[playerid][pWantedLevel] =10;
SetPlayerWantedStats(playerid,"Robbery");
}else{
PlayerInfo[playerid][pWantedLevel]=6;
SetPlayerWantedStats(playerid,"Robbery");
}
}else{
if(PlayerInfo[giveplayerid][pTeam] == TEAM_LAW || PlayerInfo[giveplayerid][pVigilante] == 1)
{
if(PlayerInfo[playerid][pWantedLevel] > 5)
{
PlayerInfo[playerid][pWantedLevel] =10;
SetPlayerWantedStats(playerid,"Robbery");
}else{
PlayerInfo[playerid][pWantedLevel]=6;
SetPlayerWantedStats(playerid,"Robbery");
}
}else{
if(IsSuspectInRangeOfPolice1(playerid))
{
if(PlayerInfo[playerid][pWantedLevel] > 5)
{
PlayerInfo[playerid][pWantedLevel] =10;
SetPlayerWantedStats(playerid,"Robbery");
}else{
PlayerInfo[playerid][pWantedLevel]+=3;
SetPlayerWantedStats(playerid,"Robbery");
}
}
}
}
}
}
}
}else{
SendClientMessage(playerid, COLOR_ERROR, "You Are A Law Enforcement Agent. You Cannot Commit Crimes.");
}
}else{
SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead.");
}
return 1;
}
Easy.