/bribe command help!
#1

here is my command in this there is not any bug, but i want to add a new syntax in it and other syntax's should be same.
just i want to add if i write /bribe (amount) it shoudl workd and send bribe of "amount" to nearest cop!

pawn Код:
COMMAND:bribe(playerid, params[])
{
    if (PlayerInfo[playerid][pDead] == 0)
    {
        if (PlayerInfo[playerid][pTeam] == TEAM_CIVILIAN && PlayerInfo[playerid][pVigilante] == 0)
        {
            new idx,TargetId,amount,string[256],tmp[256];
            tmp = strtok(params, idx);

            if (!strlen(tmp))
            {
                TargetId = GetClosestPlayer(playerid);

                if (TargetId == INVALID_PLAYER_ID || PlayerInfo[TargetId][pLevel] < 3)
                {
                    SendClientMessage(playerid, COLOR_ERROR, "No Police Officers Close Enough To Bribe.");
                    return 1;
                }
            }
            else
            {
                if (!isNumeric(tmp))
                {
                    TargetId = ReturnUser(playerid, tmp);
                    if (TargetId == INVALID_PLAYER_ID)
                    {
                        return 1;
                    }
                }
                else
                {
                    TargetId = strval(tmp);

                    if (!IsPlayerConnected(TargetId))
                    {
                        format(string, sizeof(string), "%d Is Not A Valid ID.", TargetId);
                        SendClientMessage(playerid, COLOR_ERROR, string);
                        return 1;
                    }
                }
            }

            tmp = strtok(params, idx);

            if (!strlen(tmp))
            {
                amount = 15000;
            }
            else
            {
                if (!isNumeric(tmp))
                {
                    SendClientMessage(playerid, COLOR_ERROR, "Invalid Amount - Enter A Numerical Character.");
                    return 1;
                }
                amount = strval(tmp);
            }

            //permissions durring doing missions needed.

            if (amount > 15000 || amount < 1000)
            {
                format(string, sizeof(string), "Invalid Amount $%d - Minimum Bribe : $1000 Maximum Bribe: $15000",amount);
                SendClientMessage(playerid,COLOR_ERROR, string);
                return 1;
            }

            if (TargetId == playerid)
            {
                SendClientMessage(playerid, COLOR_ERROR, "You Cannot Offer Yourself A Bribe.");
                return 1;
            }
            if (PlayerInfo[playerid][pWantedLevel] > 8)
            {
                SendClientMessage(playerid,COLOR_ERROR, "You Are On The List Of Most Wanted Suspects.  You Cannot Bribe The Police.");
                return 1;
            }

            if (PlayerInfo[TargetId][pSkill] != SKILL_COP && PlayerInfo[playerid][pVigilante] == 0)
            {
                format(string, sizeof(string), "%s Is Not A Police Officer.",PlayerInfo[TargetId][pName]);
                SendClientMessage(playerid,COLOR_ERROR, string);
                return 1;
            }

            if (GetDistanceBetweenPlayers(playerid,TargetId) > 5)
            {
                format(string, sizeof(string), "%s Is Too Far Away To Offer A Bribe To.",PlayerInfo[TargetId][pName]);
                SendClientMessage(playerid,COLOR_ERROR, string);
                return 1;
            }
            if (GetPlayerVirtualWorld(playerid) != GetPlayerVirtualWorld(TargetId))
            {
                SendClientMessage(playerid, COLOR_ERROR, "No Police Officers Close Enough To Bribe.");
                return 1;
            }

            if (PlayerInfo[TargetId][pDead] == 1)
            {
                format(string, sizeof(string), "%s Is Dead And Cannot Be Offered A Bribe.",PlayerInfo[TargetId][pName]);
                SendClientMessage(playerid,COLOR_ERROR, string);
                return 1;
            }

            if (PlayerInfo[TargetId][pAJailed] == 1)
            {
                format(string, sizeof(string), "%s (%i) Has Been Jailed And Cannot Be Offered a Bribe.",PlayerInfo[TargetId][pName],TargetId);
                SendClientMessage(playerid, COLOR_ERROR, string);
                return 1;
            }

            if (PlayerInfo[playerid][pBribeWaitTime] > 0)
            {
                SendClientMessage(playerid, COLOR_ERROR, "Please Wait Before Offering Another Bribe.");
                return 1;
            }


            if (PlayerInfo[playerid][pBribeOfferedTo] == TargetId)
            {
                format(string, sizeof(string), "You Have Already Offered A Bribe To %s",PlayerInfo[TargetId][pName]);
                SendClientMessage(playerid, COLOR_ERROR, string);
                return 1;
            }

            format(string, sizeof(string), "You Have Offered Officer %s (%d) A Bribe ($%d).  Wait To See If %s Will Accept.",PlayerInfo[TargetId][pName],TargetId,amount,SubjectGenderPronouns[PlayerInfo[TargetId][pGender]]);
            SendClientMessage(playerid, COLOR_SERVER_HELP_MSG, string);
            format(string, sizeof(string), "~w~BRIBE OFFERED TO OFFICER %s", PlayerInfo[TargetId][pName]);
            SendGameText(playerid, string, 3000, 3);

            format(string, sizeof(string), "%s (%d) Has Offered You A Bribe ($%d). Type /accept Or /refuse.",PlayerInfo[playerid][pName],playerid,amount);
            SendClientMessage(TargetId,COLOR_SERVER_HELP_MSG, string);
            format(string, sizeof(string), "~w~OFFERED A BRIBE BY %s~n~[$%d]~n~~y~TYPE /ACCEPT OR /REFUSE", PlayerInfo[playerid][pName],amount);
            SendGameText(TargetId, string, 3000, 3);


            PlayerInfo[playerid][pBribe] = amount;
            PlayerInfo[playerid][pBribeWaitTime] = 30;

            PlayerInfo[playerid][pBribeOfferedTo] = TargetId;
            PlayerInfo[TargetId][pBribeOfferedBy] = playerid;

            if (IsPlayerNPC(TargetId) && PlayerInfo[TargetId][pTeam] == TEAM_LAW)
            {
                if (amount < 10000)
                {
                    cmd_refuse(TargetId, " ");
                }
                else
                {
                    switch(random(5))
                    {
                        case 0, 1, 2, 3:
                        {
                        cmd_accept(TargetId, " ");
                        }

                        case 4, 5:
                        {
                        cmd_refuse(TargetId, " ");
                        }
                    }
                }
            }
        }
        else
        SendClientMessage(playerid, COLOR_ERROR, "Only Civilians Can Use This Command.");
    }
    else
    SendErrorMessage(playerid, 3);

    return 1;
}
Reply


Messages In This Thread
/bribe command help! - by danish007 - 14.02.2015, 21:20
Re: /bribe command help! - by danish007 - 15.02.2015, 11:30
Re: /bribe command help! - by Ritzy2K - 15.02.2015, 11:46
Re: /bribe command help! - by Golf - 15.02.2015, 11:48
Re: /bribe command help! - by danish007 - 15.02.2015, 16:09
Re: /bribe command help! - by danish007 - 16.02.2015, 10:35
Re: /bribe command help! - by AndySedeyn - 16.02.2015, 10:55
Re: /bribe command help! - by danish007 - 16.02.2015, 16:03
Re: /bribe command help! - by danish007 - 17.02.2015, 15:14
Re: /bribe command help! - by Golf - 17.02.2015, 15:47

Forum Jump:


Users browsing this thread: 2 Guest(s)