givemoney
#1

Hey, i made my give money command and it gives no errors but when i type '/givemoney 1(playerid) 1(Ammount)' it gives him 49$ and when i type 2 it gives him 50$.
My code:
pawn Код:
CMD:givemoney(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] == 1 || IsPlayerAdmin(playerid))
    {
        new pID, kolicina;
        if(sscanf(params, "us", pID, kolicina))return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Pravilan Sintaks: /givemoney [DeoImena/ID] [Kolicina].");
        if(pID == INVALID_PLAYER_ID)return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Igrac nije pronadjen ili nije konektovan.");
        new string[128], string2[128];
        new ime_igraca[MAX_PLAYER_NAME];
        GetPlayerName(playerid, ime_igraca, sizeof(ime_igraca));
        format(string, sizeof (string), ""BOJA_CRVENA"[Novac]"BOJA_BELA" Admin %s vam je dao %d$.", ime_prezime(playerid), kolicina);
        format(string2, sizeof (string2), ""BOJA_CRVENA"[Novac]"BOJA_BELA" Dali ste igracu %s %d$.", ime_igraca, kolicina);
        SendClientMessage(pID, -1, string);
        SendClientMessage(playerid, -1, string2);
       
        GivePlayerMoney(pID, kolicina);
    }
    else
    {
        SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Niste ovlasceni da koristite ovu komandu.");
    }
    return 1;
}
Reply
#2

Money is an amount. You are using string instead of an integer. Replace the following:

pawn Код:
if(sscanf(params, "us", pID, kolicina))return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Pravilan Sintaks: /givemoney [DeoImena/ID] [Kolicina].");
With
pawn Код:
if(sscanf(params, "ui", pID, kolicina))return SendClientMessage(playerid, -1, ""BOJA_PLAVA"[Info]"BOJA_BELA" Pravilan Sintaks: /givemoney [DeoImena/ID] [Kolicina].");
You can either use i or d because kolicina is not a string but integer.
Reply
#3

FalconX said the fix for your problem but I'm going to tell you why it gave 49 and 50.

You used specifier "s" without size so the size was by default 32. You enter 1 which the character '1' is number 49 and character '2' is number 50.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)