Formating a message?
#1

Hello, I need a bit of help changing the 'target audience' of my messages.

pawn Код:
if(IsPlayerLoggedIn(playerid)) {SaveChar(playerid);}
    if(LogMessage == 1)
    {
    switch(reason)
    {
        case 0: format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Timeout)", RPN(playerid));
        case 1: format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Leaving)", RPN(playerid));
        case 2: format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Kicked/Banned)", RPN(playerid));
    }
    Log("logs/joinleave.log", string);
    }
    else if(LogMessage == 0)
    {
    return 1;
    }
You see where it says case 0: - I want that to basically only be sent to admins.

My admin message 'line' is (Example)
pawn Код:
SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);}
I tried doing;
pawn Код:
case 0: format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Timeout)", RPN(playerid));
SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);
case 1: format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Leaving)", RPN(playerid));
SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);
case 2: format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Kicked/Banned)", RPN(playerid));
SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);
and
pawn Код:
}
Log("logs/joinleave.log", string);
SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);
}
else if(LogMessage == 0)
But it failed to work, any ideas?

(Errors:
pawn Код:
C:\Users\User\Desktop\zGamingRoleplay\zGamingRoleplay\gamemodes\ZRP.pwn(2953) : error 002: only a single statement (or expression) can follow each "case"
C:\Users\User\Desktop\zGamingRoleplay\zGamingRoleplay\gamemodes\ZRP.pwn(2953) : warning 215: expression has no effect
C:\Users\User\Desktop\zGamingRoleplay\zGamingRoleplay\gamemodes\ZRP.pwn(2954) : error 014: invalid statement; not in switch
C:\Users\User\Desktop\zGamingRoleplay\zGamingRoleplay\gamemodes\ZRP.pwn(2954) : warning 215: expression has no effect
C:\Users\User\Desktop\zGamingRoleplay\zGamingRoleplay\gamemodes\ZRP.pwn(2954) : error 001: expected token: ";", but found ":"
C:\Users\User\Desktop\zGamingRoleplay\zGamingRoleplay\gamemodes\ZRP.pwn(2954) : error 029: invalid expression, assumed zero
C:\Users\User\Desktop\zGamingRoleplay\zGamingRoleplay\gamemodes\ZRP.pwn(2954) : fatal error 107: too many error messages on one line

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


5 Errors.
Reply
#2

pawn Код:
case 0:
{
    format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Timeout)", RPN(playerid));
    SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);
}
case 1:
{
    format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Leaving)", RPN(playerid));
    SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);
}
case 2:
{
    format(string, sizeof(string), "*[%d:%d:%d] %s has left the server. (Kicked/Banned)", RPN(playerid));
    SendAdminMessage(COLOR_ADMINMESSAGE, 1, string);
}
Reply
#3

I shall try such, and give rep if it works :3

EDIT: It worked, + Rep given. Thankyou :3

+ Something new learned XD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)