SA-MP Forums Archive
Any idea REP++ - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Any idea REP++ (/showthread.php?tid=334242)



Any idea REP++ - AlTy - 14.04.2012

Why this doesnt work?

pawn Код:
CMD:agivecash(playerid, params[])
{
    new id, money;
    if(PlayerInfo [playerid][pAdmin] < 1)return SendClientMessage(playerid, COLOR_WHITE, "You need to be a admin to use that command!");
    else if(sscanf(params, "ud", id, money))SendClientMessage(playerid, COLOR_WHITE, "Usage: /agivecash [id/name][cash]");
    else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_WHITE,"Error: Player is not connected!");
    else if (money > 100000)SendClientMessage(playerid,COLOR_WHITE,"Error: Max money to send: 100000");
    else {
        new To[128], From[128];
        format(To, sizeof(To), "Admin %s(%d) has sended you %s of cash!", GetName(playerid), playerid, money);
        SendClientMessage(id,COLOR_PINK, To);
        format(From, sizeof(From), "You have sended %s of admin money to %s(%d)!", money, GetName(id),id);
        SendClientMessage(id,COLOR_PINK, From);
        GivePlayerMoney(id, money);
    }
    return 1;
}

CMD:gc(playerid, params[])
{
    new id, money, mymoney;
    mymoney = GetPlayerMoney(playerid);
    if(sscanf(params, "uu", id, money))SendClientMessage(playerid, COLOR_WHITE, "Usage: /gc [id/name][cash]");
    else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_WHITE,"Error: Player is not connected!");
    else if (money > 100000)SendClientMessage(playerid,COLOR_WHITE,"Error: Max money to send: 100000");
    else if (mymoney < money)SendClientMessage(playerid,COLOR_WHITE,"Error: You dont have this mouch of money!");
    else {
        new To[128], From[128];
        format(To, sizeof(To), "%s(%d) has sended you %s of cash!", GetName(playerid), playerid, money);
        SendClientMessage(id,COLOR_PINK, To);
        format(From, sizeof(From), "You have sended %s of money to %s(%d)!", money, GetName(id),id);
        SendClientMessage(id,COLOR_PINK, From);
        GivePlayerMoney(id, money);
        GivePlayerMoney(playerid, mymoney-money);
    }
    return 1;
}

CMD:setscore(playerid, params[])
{
    new id, money;
    if(PlayerInfo [playerid][pAdmin] < 4)return SendClientMessage(playerid, COLOR_WHITE, "You need to be admin lvl 4 to use that command!");
    else if(sscanf(params, "uu", id, money))SendClientMessage(playerid, COLOR_WHITE, "Usage: /setscore [id/name][score]");
    else if (id==INVALID_PLAYER_ID)SendClientMessage(playerid,COLOR_WHITE,"Error: Player is not connected!");
    else if (id==playerid)SendClientMessage(playerid,COLOR_WHITE,"Error: You cant use this command on yourself!");
    else {
        new To[128], From[128];
        format(To, sizeof(To), "Admin %s(%d) has set your score to: %s.", GetName(playerid), playerid, money);
        SendClientMessage(id,COLOR_PINK, To);
        format(From, sizeof(From), "You have set %s score to %s(%d)!", money, GetName(id),id);
        SendClientMessage(id,COLOR_PINK, From);
        SetPlayerScore(id, money);
    }
    return 1;
}
WHen i execute it, nothing happens


Re: Any idea REP++ - Jochemd - 14.04.2012

#1: Money is an integer, so instead of %s use %d
#2: In CMD:gc and CMDetscore, you define money as a player in sscanf ("uu"). You should use "ud"

I also recommend you to make sure your formats are OK.