My /job command problem
#2

I've made your code a lot neater and removed pointless code (such as the sscanf statement with your 'option' string), try this:

pawn Код:
CMD:job(playerid, params[])
    if(isnull(params))
        return SendClientMessage(playerid, GREY, "USAGE: /job [join/quit]");
   
    if(strcmp(params, "join", true) == 0) {
        if(IsPlayerInRangeOfPoint(playerid, 3.0, -361.4394,1572.8923,75.9229)) {
            if(PlayerStat[playerid][JobID] >= 1)
                return SendClientMessage(playerid, GREY, "You already have a job (use /job quit to leave it).");
                SendClientMessage(playerid, GREY, "You have joined the Garbage Man job.");
                PlayerStat[playerid][JobID] = 1;
            }
        } else if(IsPlayerInRangeOfPoint(playerid, 3.0, -1958.6456,323.6250,1552.1406)) {
            if(PlayerStat[playerid][JobID] >= 1)
                return SendClientMessage(playerid, GREY, "You already have a job (use /job quit to leave it).");

            SendClientMessage(playerid, GREY, "You have joined the Table Cleaner job.");
            PlayerStat[playerid][JobID] = 2;
        } else if(IsPlayerInRangeOfPoint(playerid, 3.0, -1971.0381,324.3919,1552.1387)) {
            if(PlayerStat[playerid][JobID] >= 1)
                return SendClientMessage(playerid, GREY, "You already have a job (use /job quit to leave it).");

            SendClientMessage(playerid, GREY, "You have joined the Cells Cleaner job.");
            PlayerStat[playerid][JobID] = 3;
        }
        else if(IsPlayerInRangeOfPoint(playerid, 3.0, -349.1976,1544.5193,75.5625)) {
            if(PlayerStat[playerid][JobID] >= 1)
                return SendClientMessage(playerid, GREY, "You already have a job (use /job quit to leave it).");

            SendClientMessage(playerid, GREY, "You have joined the Boxer job.");
            PlayerStat[playerid][JobID] = 4;
        }
        else return SendClientMessage(playerid, GREY, "You're not at a valid job location.");
    } else if(strcmp(params, "quit", true) == 0) {
        new string[75];
       
        if(PlayerStat[playerid][JobID] < 1) return SendClientMessage(playerid, GREY, "You don't have a job to quit.");
        if(PlayerStat[playerid][HoursInJob] <= 4)
        {
            format(string, sizeof(string), "You must get 5 paychecks before quitting your job, you currently have %d." , PlayerStat[playerid][HoursInJob]);
            SendClientMessage(playerid, GREY, string);
        }
        else
        {
            SendClientMessage(playerid, GREY, "You have successfully quit your job.");
            PlayerStat[playerid][HoursInJob] = 0;
            PlayerStat[playerid][JobID] = 0;
        }
    } else return SendClientMessage(playerid, GREY, "Invalid option.");
   
    return 1;
}
Reply


Messages In This Thread
My /job command problem - by Soumi - 03.08.2011, 21:52
Re: My /job command problem - by Calgon - 03.08.2011, 22:40
Re : My /job command problem - by Soumi - 03.08.2011, 22:49
Re: My /job command problem - by Calgon - 03.08.2011, 22:52
Re : Re: My /job command problem - by Soumi - 03.08.2011, 22:56

Forum Jump:


Users browsing this thread: 1 Guest(s)