CMD:contract
#1

How would I convert this from STRCMP to ZCMD?

pawn Код:
CMD:contract(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /contract [playerid/PartOfName] [amount]");
            return 1;
        }
            giveplayerid = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /contract [playerid/PartOfName] [amount]");
                return 1;
            }
            moneys = strval(tmp);
            if(moneys < 1000 || moneys > 1000000) { SendClientMessage(playerid, COLOR_GREY, "   Contract money must be atleast $1000, and not more then $1000000!"); return 1; }
            if(PlayerInfo[playerid][pLevel] < 2)
            {
                SendClientMessage(playerid, COLOR_GRAD1, "You must be level 2 to place a Contract.");
                return 1;
            }
            if (IsPlayerConnected(giveplayerid))
            {
                if(giveplayerid != INVALID_PLAYER_ID)
                {
                    if(PlayerInfo[giveplayerid][pMember] == 8 && PlayerInfo[playerid][pMember] == 8)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Cannot place Contracts on your own Agency!");
                        return 1;
                    }
                    else if(PlayerInfo[giveplayerid][pLeader] == 8 && PlayerInfo[playerid][pMember] == 8)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Cannot place Contracts on your own Agency!");
                        return 1;
                    }
                    else if(PlayerInfo[giveplayerid][pMember] == 8||PlayerInfo[giveplayerid][pLeader] == 8)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Can't contract a Hitman !");
                        return 1;
                    }
                    if(PlayerInfo[playerid][pAdminDuty] == 1 || PlayerInfo[playerid][pTesterDuty] == 1)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* You may not place a contract on admin/testers on duty");
                        return 1;
                    }
                    if(IsACop(giveplayerid) && moneys < 30000)
                    {
                        SendClientMessage(playerid, COLOR_GREY, "* Only $30000 or above can be placed as a Contract on Cops !");
                        return 1;
                    }
                    if(giveplayerid == playerid) { SendClientMessage(playerid, COLOR_GREY, "* You cannot Contract yourself!"); return 1; }
                    GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                    playermoney = GetPlayerMoney(playerid);
                    if (moneys > 0 && playermoney >= moneys)
                    {
                        SafeGivePlayerMoney(playerid, (0 - moneys));
                        PlayerInfo[giveplayerid][pHeadValue]+=moneys;
                        format(string, sizeof(string), "%s has placed a contract on %s, for $%d.",sendername, giveplayer, moneys);
                        SendFamilyMessage(8, COLOR_YELLOW, string);
                        format(string, sizeof(string), "* You placed a contract on %s, for $%d.",giveplayer, moneys);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        format(string, sizeof(string), "[INFO]: %s (%d) has placed a contract on %s (%d) for $%d", sendername, playerid, giveplayer,giveplayerid, moneys);
                        SendAdminMessage(COLOR_YELLOW,string);
                        SendClientMessage(giveplayerid, COLOR_LIGHTBLUE, "* Someone has placed a hit contract on you, you might want protection!");
                        PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount.");
                    }
                }
            }
            else
            {
                format(string, sizeof(string), "   %d is not an active player.", giveplayerid);
                SendClientMessage(playerid, COLOR_GRAD1, string);
            }
        }
        return 1;
    }
I need it to work with SSCANF2.

Thanks
Reply
#2

Untested:
pawn Код:
CMD:contract(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(PlayerInfo[playerid][pLevel] < 2) return SendClientMessage(playerid, COLOR_GRAD1, "You must be level 2 to place a Contract.");

        new ID, string[128], amount[128], giveplayer[128];
        if(sscanf(params,"ui", ID, amount)) retrun SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /contract [playerid/PartOfName] [amount]");
        else if(ID == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_GREY, "Invalid playerid!");
        if(amount < 1000 || amount > 1000000) return SendClientMessage(playerid, COLOR_GREY, "   Contract money must be atleast $1000, and not more then $1000000!");
        if (IsPlayerConnected(ID))
        {
            if(ID != INVALID_PLAYER_ID)
            {
                if(PlayerInfo[ID][pMember] == 8 && PlayerInfo[playerid][pMember] == 8)
                {
                    SendClientMessage(playerid, COLOR_GREY, "* Cannot place Contracts on your own Agency!");
                    return 1;
                }
                else if(PlayerInfo[ID][pLeader] == 8 && PlayerInfo[playerid][pMember] == 8)
                {
                    SendClientMessage(playerid, COLOR_GREY, "* Cannot place Contracts on your own Agency!");
                    return 1;
                }
                else if(PlayerInfo[ID][pMember] == 8||PlayerInfo[ID][pLeader] == 8)
                {
                    SendClientMessage(playerid, COLOR_GREY, "* Can't contract a Hitman !");
                    return 1;
                }
                if(PlayerInfo[playerid][pAdminDuty] == 1 || PlayerInfo[playerid][pTesterDuty] == 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "* You may not place a contract on admin/testers on duty");
                    return 1;
                }
                if(IsACop(ID) && amount < 30000)
                {
                    SendClientMessage(playerid, COLOR_GREY, "* Only $30000 or above can be placed as a Contract on Cops !");
                    return 1;
                }
                if(ID == playerid) return SendClientMessage(playerid, COLOR_GREY, "* You cannot Contract yourself!");
                GetPlayerName(ID, giveplayer, sizeof(giveplayer));
                playermoney = GetPlayerMoney(playerid);
                if (amount > 0 && playermoney >= amount)
                {
                    SafeGivePlayerMoney(playerid, (0 - amount));
                    PlayerInfo[ID][pHeadValue]+=amount;
                    format(string, sizeof(string), "%s has placed a contract on %s, for $%d.",sendername, giveplayer, amount);
                    SendFamilyMessage(8, COLOR_YELLOW, string);
                    format(string, sizeof(string), "* You placed a contract on %s, for $%d.",giveplayer, amount);
                    SendClientMessage(playerid, COLOR_WHITE, string);
                    format(string, sizeof(string), "[INFO]: %s (%d) has placed a contract on %s (%d) for $%d", sendername, playerid, giveplayer,ID, amount);
                    SendAdminMessage(COLOR_YELLOW,string);
                    SendClientMessage(ID, COLOR_LIGHTBLUE, "* Someone has placed a hit contract on you, you might want protection!");
                    PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "   Invalid transaction amount.");
                }
            }
        }
        else
        {
            format(string, sizeof(string), "   %d is not an active player.", ID);
            SendClientMessage(playerid, COLOR_GRAD1, string);
        }
    }
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)