Help With cash giving in -
#1

i got some problem that we can give the cash in negative amount in this way we can take cash from it so how to know he used the -
pawn Код:
CMD:giveadmincash(playerid, params[])
{
        new TargetID, cash,reason[500];
        if(pInfo[playerid][Adminlevel] < 10) return SCM(playerid, COLOR_RED, ""ERROR_MESSAGE"");
        if(sscanf(params, "uds[500]", TargetID, cash,reason)) return SCM(playerid, COLOR_RED, "USAGE: /giveadmincash [id] [cash] [reason]");
        if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID )) return SCM(playerid, COLOR_RED, "*Player Is Not Connected.");
        new Miney = pInfo[TargetID][Money];
        pInfo[TargetID][Money] =Miney+cash;
        new str[128],str1[128];
        format(str,sizeof(str),"** Admin Has Given You $%d Cash. REASON : %s", cash,reason);
        SCM(TargetID ,COLOR_SKYBLUE, str);
        format(str1,sizeof(str1),"** CASH: %s(%d) (ADMIN CASH) Has Been Given Cash '$%d'. Reason %s", pInfo[TargetID][playername], TargetID, cash,reason);
        SCMA(COLOR_HOTPINK, str1);
        print(str1);
        return 1;
}
Reply
#2

Check if the amount of the money is negative number.

pawn Код:
CMD:giveadmincash(playerid, params[])
{
    if(pInfo[playerid][Adminlevel] < 10) return SCM(playerid, COLOR_RED, ""ERROR_MESSAGE"");
    new TargetID, cash, reason[50];
    if(sscanf(params, "uds[50]", TargetID, cash,reason)) return SCM(playerid, COLOR_RED, "USAGE: /giveadmincash [id] [cash] [reason]");
    if(TargetID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_RED, "*Player Is Not Connected.");
    if(cash <= 0) return SCM(playerid, COLOR_RED, "You cannot give negative amount of money");
    pInfo[TargetID][Money] += cash;
    new str[128];
    format(str,sizeof(str),"** Admin Has Given You $%d Cash. REASON : %s", cash,reason);
    SCM(TargetID ,COLOR_SKYBLUE, str);
    format(str,sizeof(str),"** CASH: %s(%d) (ADMIN CASH) Has Been Given Cash '$%d'. Reason %s", pInfo[TargetID][playername], TargetID, cash,reason);
    SCMA(COLOR_HOTPINK, str);
    print(str);
    return 1;
}
EDIT: I checked for negative cash only and it should be for $0 too as Rafaellos posted.
Reply
#3

pawn Код:
if(cash <= 0) return SendClientMessage(playerid, -1, "Invalid cash");
Edit: Late.
Reply
#4

thanks to both
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)