/rob Command Help!
#1

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.

this is command please fix this :P

PHP код:
dcmd_rob(playeridparams[])
{
    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(stringsizeof(string), "You Cannot Rob Someone Inside %s.",HouseInfo[Houseid][h_HouseIntName]);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    }
    
tmp strtok(paramsidx);
    if(!
strlen(tmp))
    {
    new 
Players;
    for(new 
0GetMaxPlayers(); i++)
    {
        if(
IsPlayerConnected(i) && != playerid && PlayerInfo[i][pSpawn] == && GetDistanceBetweenPlayers(playerid,i) < 10)
        {
        
Players ++;
        if (
Players 0)giveplayerid i; break;
        }
    }
    if (
Players == 0)
    return 
SendClientMessage(playeridCOLOR_ERROR"No Players Close Enough To Rob.");
    }else{
    if(!
isNumeric(tmp))
    {
    
giveplayerid ReturnUser(playeridtmp);
    if(
giveplayerid == INVALID_PLAYER_ID)
    {
    return 
1;
    }
    }
    else
    {
    
giveplayerid strval(tmp);
    if(!
IsPlayerConnected(giveplayerid))
    {
    
format(stringsizeof(string), "%d Is Not A Valid ID."giveplayerid);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    }
    }
    if(
giveplayerid == playerid)
    {
    
SendClientMessage(playeridCOLOR_ERROR"Are You Stupid? You Cannot Rob Yourself.");
    return 
1;
    }
    if(
PlayerInfo[playerid][pJailed] == || PlayerInfo[playerid][pAJailed] == 1)
    {
    
SendClientMessage(playeridCOLOR_ERROR"You Cannot Use This Command In Jail.");
    return 
1;
    }
    if(
GetDistanceBetweenPlayers(playerid,giveplayerid) > 3)    {
    
format(stringsizeof(string), "%s (%d) Is Not Close Enough.  You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    if(
GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(giveplayerid))
    {
    
format(stringsizeof(string), "%s (%d) Is Not Close Enough.  You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    if(
GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) != PLAYER_STATE_ONFOOT)
    {
    
format(stringsizeof(string), "%s (%d) Is Not Close Enough.  You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    if(
GetPlayerState(playerid) != PLAYER_STATE_ONFOOT && GetPlayerState(giveplayerid) == PLAYER_STATE_ONFOOT)
    {
    
format(stringsizeof(string), "%s (%d) Is Not Close Enough.  You Cannot Rob %s.",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    return 
1;
    }
    if(
PlayerInfo[playerid][pRobTime] > 0)
    {
    
SendClientMessage(playeridCOLOR_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(stringsizeof(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(stringsizeof(string), "You Have Robbed $%d From %s (%d).",amount,PlayerInfo[giveplayerid][pName],giveplayerid);
    
SendClientMessage(playeridCOLOR_SERVER_HELP_MSGstring);
    
format(stringsizeof(string), "~w~Robbed $%d From %s",amountPlayerInfo[giveplayerid][pName]);
    
GameTextForPlayer(playerid,string40003);
    
format(stringsizeof(string), "%s (%d) Has Robbed $%d From You.",PlayerInfo[playerid][pName],playerid,amount);
    
SendClientMessage(giveplayeridCOLOR_SERVER_HELP_MSGstring);
    
format(stringsizeof(string), "Robbed By %s~n~$%d",PlayerInfo[playerid][pName],amount);
    
GameTextForPlayer(giveplayerid,string40003);
    
GivePlayerCash(giveplayerid, - amount);
    
GivePlayerCash(playeridamount);
    
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(stringsizeof(string), "Committed A Crime (Robbery) - Jail Sentence Extended %i Hour %i Minute $%i Bail.",PlayerInfo[giveplayerid][pJailHour],PlayerInfo[giveplayerid][pJailMinute],PlayerInfo[giveplayerid][pBail]);
    
SendClientMessage(giveplayeridCOLOR_WANTED_LEVEL_5string);
    }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(stringsizeof(string), "%s (%d) Is Too Poor To Rob.",PlayerInfo[giveplayerid][pName],giveplayerid);
    
SendClientMessage(playeridCOLOR_ERRORstring);
    }
    }else{
    if (
IsSuspectInRangeOfPolice(playerid) && PlayerInfo[playerid][pJailed] == 0)
    {
    
format(stringsizeof(string), "Crime: Attempted Robbery - Victim: %s (%d)",PlayerInfo[giveplayerid][pName],giveplayerid);
    
ReportCrimeTOPolice(playerid,string);
    }
    
PlayerInfo[playerid][pRobTime] = 40;
    
format(stringsizeof(string), "%s (%d) Has Noticed You Trying To Rob %s.  Attempt Failed..",PlayerInfo[giveplayerid][pName],giveplayerid,ObjectGenderPronouns[PlayerInfo[giveplayerid][pGender]]);
    
SendClientMessage(playeridCOLOR_SERVER_HELP_MSGstring);
    
format(stringsizeof(string), "Attempt To Rob %s Failed",PlayerInfo[giveplayerid][pName]);
    
GameTextForPlayer(playerid,string40003);
    
format(stringsizeof(string), "%s (%d) Has Attempted To Rob You.",PlayerInfo[playerid][pName],playerid);
    
SendClientMessage(giveplayeridCOLOR_SERVER_HELP_MSGstring);
    
    if(
PlayerInfo[playerid][pTeam] != TEAM_LAW && PlayerInfo[playerid][pVigilante] == 0)
    {
    if(
PlayerInfo[playerid][pJailed] == 1)
    {
    
PlayerInfo[giveplayerid][pJailHour] += 2;
    
PlayerInfo[giveplayerid][pBail] += 1000;
    
format(stringsizeof(string), "Committed A Crime (Robbery) - Jail Sentence Extended %i Hour %i Minute $%i Bail.",PlayerInfo[giveplayerid][pJailHour],PlayerInfo[giveplayerid][pJailMinute],PlayerInfo[giveplayerid][pBail]);
    
SendClientMessage(giveplayeridCOLOR_WANTED_LEVEL_5string);
    }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(playeridCOLOR_ERROR"You Are A Law Enforcement Agent. You Cannot Commit Crimes.");
    }
    }else{
    
SendClientMessage(playeridCOLOR_ERROR"You Cannot Use This Command When You're Dead.");
    }
    return 
1;

Reply
#2

pawn Код:
amount = GetPlayerCash(giveplayerid)/4;
pawn Код:
amount = random(GetPlayerCash(giveplayerid));
Reply
#3

But How MAX 500000 and Not More than 500000 ?
Reply
#4

anyone? please?
Reply
#5

Easy.

amount = random(GetPlayerCash(giveplayerid));
while(amount >= 500000)
{
amount = random(GetPlayerCash(giveplayerid));
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)