PDA

View Full Version : I'm having problems making a /richlist command for IRC.


OleKristian95
07/04/2012, 12:37 PM
I'm having problems with creating a /richlist command for my IRC

The command looks like this:

IRCCMD:richlist(botid, channel[], user[], host[], params[]) {
if (IRC_IsHalfop(botid, channel, user))
new msg[128], Slot1 = -1, Slot2 = -1, Slot3 = -1, Slot4 = -1, HighestCash = -9999;
IRC_GroupSay(gGroupID, channel, msg);
format(msg, sizeof(msg), "Rich List:");
IRC_GroupSay(gGroupID, channel, msg);

for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x)) if (GetPlayerMoney(x) >= HighestCash) {
HighestCash = GetPlayerMoney(x);
Slot1 = x;
}
HighestCash = -9999;
for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1) if (GetPlayerMoney(x) >= HighestCash) {
HighestCash = GetPlayerMoney(x);
Slot2 = x;
}
HighestCash = -9999;
for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2) if (GetPlayerMoney(x) >= HighestCash) {
HighestCash = GetPlayerMoney(x);
Slot3 = x;
}
HighestCash = -9999;
for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2 && x != Slot3) if (GetPlayerMoney(x) >= HighestCash) {
HighestCash = GetPlayerMoney(x);
Slot4 = x;
}
IRC_GroupSay(gGroupID, channel, msg);
format(msg, sizeof(msg), "(%d) %s - $%d", Slot1,PlayerName2(Slot1),GetPlayerMoney(Slot1) );
IRC_GroupSay(gGroupID, channel, msg);
if(Slot2 != -1) {
new msg[128];
IRC_GroupSay(gGroupID, channel, msg);
format(msg, sizeof(msg), "(%d) %s - $%d", Slot2,PlayerName2(Slot2),GetPlayerMoney(Slot2) );
IRC_GroupSay(gGroupID, channel, msg);
}
if(Slot3 != -1) {
IRC_GroupSay(gGroupID, channel, msg);
format(msg, sizeof(msg), "(%d) %s - $%d", Slot3,PlayerName2(Slot3),GetPlayerMoney(Slot3) );
IRC_GroupSay(gGroupID, channel, msg);
}
if(Slot4 != -1) {
IRC_GroupSay(gGroupID, channel, msg);
format(msg, sizeof(msg), "(%d) %s - $%d", Slot4,PlayerName2(Slot4),GetPlayerMoney(Slot4) );
IRC_GroupSay(gGroupID, channel, msg);
}
return 1;
}

This is the errors I get:

C:\Users\Ole Kristian\Desktop\San Andreas Server\gamemodes\SATDM~RP.pwn(34041) : error 003: declaration of a local variable must appear in a compound block
C:\Users\Ole Kristian\Desktop\San Andreas Server\gamemodes\SATDM~RP.pwn(34041) : error 017: undefined symbol "msg"
C:\Users\Ole Kristian\Desktop\San Andreas Server\gamemodes\SATDM~RP.pwn(34041) : warning 215: expression has no effect
C:\Users\Ole Kristian\Desktop\San Andreas Server\gamemodes\SATDM~RP.pwn(34041) : error 001: expected token: ";", but found "]"
C:\Users\Ole Kristian\Desktop\San Andreas Server\gamemodes\SATDM~RP.pwn(34041) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

Line 34041:

new msg[128], Slot1 = -1, Slot2 = -1, Slot3 = -1, Slot4 = -1, HighestCash = -9999;

OleKristian95
07/04/2012, 11:52 PM
IRCCMD:richlist(botid, channel[], user[], host[], params[]) {
if (IRC_IsHalfop(botid, channel, user))
new HighestCash = -9999;
IRC_GroupSay(gGroupID, channel, "Rich List:");

for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x)) if (GetPlayerMoney(x) >= HighestCash) {
new Slot1 = -1;
HighestCash = GetPlayerMoney(x);
Slot1 = x;
}
new Slot2 = -1;
HighestCash = -9999;
for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1) if (GetPlayerMoney(x) >= HighestCash) {
HighestCash = GetPlayerMoney(x);
Slot2 = x;
}
new Slot3 = -1;
HighestCash = -9999;
for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2) if (GetPlayerMoney(x) >= HighestCash) {
HighestCash = GetPlayerMoney(x);
Slot3 = x;
}
new Slot4 = -1;
HighestCash = -9999;
for(new x=0; x<MAX_PLAYERS; x++) if (IsPlayerConnected(x) && x != Slot1 && x != Slot2 && x != Slot3) if (GetPlayerMoney(x) >= HighestCash) {
HighestCash = GetPlayerMoney(x);
Slot4 = x;
}
IRC_GroupSay(gGroupID, channel, "(%d) %s - $%d", Slot1,PlayerName2(Slot1),GetPlayerMoney(Slot1) );
if(Slot2 != -1) {
IRC_GroupSay(gGroupID, channel, "(%d) %s - $%d", Slot2,PlayerName2(Slot2),GetPlayerMoney(Slot2) );
}
if(Slot3 != -1) {
IRC_GroupSay(gGroupID, channel, "(%d) %s - $%d", Slot3,PlayerName2(Slot3),GetPlayerMoney(Slot3) );
}
if(Slot4 != -1) {
IRC_GroupSay(gGroupID, channel, "(%d) %s - $%d", Slot4,PlayerName2(Slot4),GetPlayerMoney(Slot4) );
}
return 1;
} else return IRC_GroupSay(gGroupID, channel, "4ERROR: Player is not connected");
}

Tried the code a little bit but still it doesnt works, I am about to give up.. please help :(

OleKristian95
08/04/2012, 10:04 PM
Please... anyone... try help me :/