/REP Command problem [+reps]
#1

Hello, I'v rep command in my server, but the problem that , for example if we have 3 players

Alex (ID 0)
Strike (ID 1)
SPA (ID 2)

If player 'SPA (ID 3 ) ' type /rep 1 (which meaning ) 'strike' its return the rep to the id 0 'Alex' , but its show in msgs that it's returned to id 1'Strike' , why is that happen?

CODE
Код:
CMD:rep(playerid,params[])
{

    static IDD, amount, name[MAX_PLAYERS], string7[200], name2[MAX_PLAYERS], string8[200];
    if (sscanf(params, "ii", IDD,amount)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /rep [playerid/name] [amount]");
    if (amount > GetPlayerScore(playerid)) return SendClientMessage(playerid, 0xff0000aa, "* You do not have enough reps to give reps to player!");
    if (amount <= 0) return SendClientMessage(playerid, 0xff0000aa, "* You can't rep less than 1!");
    if (playerid == IDD) return SendClientMessage(playerid, 0xff0000aa, "* You can't rep yourselve!");
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(IDD, name2, sizeof(name2));
    format(string8,sizeof(string8),"[REP INFO] {FFAF00}%s recieved %i reps from %s",name2,amount,name);
    SendClientMessageToAll(COLOR_RED,string8);

    format(string8, sizeof(string8), "3,1[REP INFO] {FFAF00}%s recieved %i reps from %s",name2,amount,name);
	IRC_GroupSay(groupID, IRC_CHANNEL, string8);

    format(string7,sizeof(string7),"{FFFF00}* %s(%d) Has rep for you: %i",name,playerid,amount);
    SendClientMessage(ID,COLOR_RED,string7);
    SetPlayerScore(playerid, GetPlayerScore(playerid) -amount);
    //SetPlayerScore(ID,amount);
    SetPlayerScore(ID, GetPlayerScore(ID) +amount);
    return 1;
}
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
You're using the wrong variables when giving the score. Actually, you're doing more than that wrong with variables, they shouldn't be static, you don't need so many, and use "u" not "i" in "sscanf".
Ik this is off topic, but could you please tell me why do we need to use "u" in sscanf. I've been using it all the time but have been wondering why as well.
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
"i" just takes a number (playerid), "u" takes a name or number.
Ah, cheers. Finally got that answered
Reply
#4

Just change the variables?
Reply
#5

Woah you are allocating 5.6 kilobyte for just 1 command lol.
Reply
#6

Someone can fix??
Reply
#7

change from
pawn Код:
if (sscanf(params, "ii", IDD,amount)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /rep [playerid/name] [amount]");
to
pawn Код:
if (sscanf(params, "ui", IDD,amount)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /rep [playerid/name] [amount]");
edit:
pawn Код:
CMD:rep(playerid,params[])
{

    static IDD, amount, name[MAX_PLAYERS], string7[200], name2[MAX_PLAYERS], string8[200];
    if (sscanf(params, "ui", IDD,amount)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /rep [playerid/name] [amount]");
    if (amount > GetPlayerScore(playerid)) return SendClientMessage(playerid, 0xff0000aa, "* You do not have enough reps to give reps to player!");
    if (amount <= 0) return SendClientMessage(playerid, 0xff0000aa, "* You can't rep less than 1!");
    if (playerid == IDD) return SendClientMessage(playerid, 0xff0000aa, "* You can't rep yourselve!");
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(IDD, name2, sizeof(name2));
    format(string8,sizeof(string8),"[REP INFO] {FFAF00}%s recieved %i reps from %s",name2,amount,name);
    SendClientMessageToAll(COLOR_RED,string8);

    format(string8, sizeof(string8), "3,1[REP INFO] {FFAF00}%s recieved %i reps from %s",name2,amount,name);
    IRC_GroupSay(groupID, IRC_CHANNEL, string8);

    format(string7,sizeof(string7),"{FFFF00}* %s(%d) Has rep for you: %i",name,playerid,amount);
    SendClientMessage(IDD,COLOR_RED,string7);
    SetPlayerScore(playerid, GetPlayerScore(playerid) -amount);
    //SetPlayerScore(IDD,amount);
    SetPlayerScore(IDD, GetPlayerScore(IDD) +amount);
    return 1;
}
Reply
#8

Eth, you know i and d are the same..?
Reply
#9

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Eth, you know i and d are the same..?
I edited my post already..
Reply
#10

Quote:
Originally Posted by Eth
Посмотреть сообщение
change from
pawn Код:
if (sscanf(params, "ii", IDD,amount)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /rep [playerid/name] [amount]");
to
pawn Код:
if (sscanf(params, "ui", IDD,amount)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /rep [playerid/name] [amount]");
edit:
pawn Код:
CMD:rep(playerid,params[])
{

    static IDD, amount, name[MAX_PLAYERS], string7[200], name2[MAX_PLAYERS], string8[200];
    if (sscanf(params, "ui", IDD,amount)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /rep [playerid/name] [amount]");
    if (amount > GetPlayerScore(playerid)) return SendClientMessage(playerid, 0xff0000aa, "* You do not have enough reps to give reps to player!");
    if (amount <= 0) return SendClientMessage(playerid, 0xff0000aa, "* You can't rep less than 1!");
    if (playerid == IDD) return SendClientMessage(playerid, 0xff0000aa, "* You can't rep yourselve!");
    GetPlayerName(playerid, name, sizeof(name));
    GetPlayerName(IDD, name2, sizeof(name2));
    format(string8,sizeof(string8),"[REP INFO] {FFAF00}%s recieved %i reps from %s",name2,amount,name);
    SendClientMessageToAll(COLOR_RED,string8);

    format(string8, sizeof(string8), "3,1[REP INFO] {FFAF00}%s recieved %i reps from %s",name2,amount,name);
    IRC_GroupSay(groupID, IRC_CHANNEL, string8);

    format(string7,sizeof(string7),"{FFFF00}* %s(%d) Has rep for you: %i",name,playerid,amount);
    SendClientMessage(IDD,COLOR_RED,string7);
    SetPlayerScore(playerid, GetPlayerScore(playerid) -amount);
    //SetPlayerScore(IDD,amount);
    SetPlayerScore(IDD, GetPlayerScore(IDD) +amount);
    return 1;
}
When i type /rep 1 5 its return 545454 score to the id
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)