cmd:contract problem
#1

When i type /contract it says "You already placed a contract on this player", what's the problem in it?

pawn Код:
CMD:contract(playerid, params[])
{
    new string[128], playerb, amount;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /contract [playerid] [amount]");
    if(IsAHitman(playerid)) return SendClientMessage(playerid, COLOR_GREY, "This played is an Hitman, he can not be contracted");
    if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You mus be at least level 3 to make a contract on someone.");
    if(amount < 3000 || amount > 50000) return SendClientMessage(playerid, COLOR_GREY, "Contracts are between $3000 and $50,000.");
    if(PlayerInfo[playerid][pMoney] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much on you at the moment.");
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't contract yourself.");
    if(PlayerInfo[playerb][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You can't contract people under level 3.");
    if(!strcmp(RPN(playerid), PlayerInfo[playerb][pContractBy], false)) return SendClientMessage(playerid, COLOR_GREY, "You have already placed a contract on this player.");
    if(PlayerInfo[playerb][pContract] >= 150000) return SendClientMessage(playerid, COLOR_GREY, "Player has the maximum contract amount on his head already.");
    PlayerInfo[playerb][pContract] += amount;
    format(PlayerInfo[playerb][pContractBy], 32, "%s", RPN(playerid));
    GiveZaiatMoney(playerid, -amount);
    format(string, sizeof(string), "HitmanWarn: %s has placed a contract on %s for $%d.", RPN(playerid), RPN(playerb), amount);
    SendHitmanMessage(COLOR_YELLOW, string);
    SendAdminMessage(COLOR_DARKRED, 3, string);
    Log("logs/contract.log", string);
    return 1;
}
Reply
#2

Why you use strcmp for PlayerInfo like that?
Reply
#3

pawn Код:
CMD:contract(playerid, params[])
{
    new string[128], playerb, amount;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(sscanf(params, "ui", playerb, amount)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /contract [playerid] [amount]");
    if(IsAHitman(playerid)) return SendClientMessage(playerid, COLOR_GREY, "This played is an Hitman, he can not be contracted");
    if(PlayerInfo[playerid][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You mus be at least level 3 to make a contract on someone.");
    if(amount < 3000 || amount > 50000) return SendClientMessage(playerid, COLOR_GREY, "Contracts are between $3000 and $50,000.");
    if(PlayerInfo[playerid][pMoney] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much on you at the moment.");
    if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't contract yourself.");
    if(PlayerInfo[playerb][pLevel] < 3) return SendClientMessage(playerid, COLOR_GREY, "You can't contract people under level 3.");
    //Get alternative for the line below! Compile it this way first and then get the alternative
    //if(!strcmp(RPN(playerid), PlayerInfo[playerb][pContractBy], false)) return SendClientMessage(playerid, COLOR_GREY, "You have already placed a contract on this player.");
    if(PlayerInfo[playerb][pContract] >= 150000) return SendClientMessage(playerid, COLOR_GREY, "Player has the maximum contract amount on his head already.");
    PlayerInfo[playerb][pContract] += amount;
    format(PlayerInfo[playerb][pContractBy], 32, "%s", RPN(playerid));
    GiveZaiatMoney(playerid, -amount);
    format(string, sizeof(string), "HitmanWarn: %s has placed a contract on %s for $%d.", RPN(playerid), RPN(playerb), amount);
    SendHitmanMessage(COLOR_YELLOW, string);
    SendAdminMessage(COLOR_DARKRED, 3, string);
    Log("logs/contract.log", string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)