Tester & admin chat
#5

PHP код:
CMD:tchat(playerid,params[])
{
    if(
pInfo[playerid][pAdminLevel] < && pInfo[playerid][Tester] < 1) return SendClientMessage(playerid, -1""COL_RED"EROARE: You are not admin or tester!");
    if(!
strlen(params)) return SendClientMessage(playerid, -1""COL_RED"TesterCmd: /tchat [Text]");
    new 
Testerstring[144];
    
format(Testerstringsizeof(Testerstring), ""COL_GREEN"[Tester Chat] %s %s[%d]: %s",
        (
pInfo[playerid][pAdminLevel]) ? (GetAdminName(playerid)) : (GetTesterName(playerid)), PlayerName(playerid), playeridparams);
    
SendMessageToAllTesters(Testerstring, -1);
    return 
1;

This method uses 'ternary operators'. https://sampforum.blast.hk/showthread.php?tid=612076

In your original code, you had two statements that queried whether the player was an admin, so if an admin was to use the command it would result in the message being sent twice. You should use 'return' to break the code to prevent it from continuing when you've achieved the result you want.

EDIT:
Quote:

If player is not helper but admin, the statement will be true because of OR. Change it to AND.

The downside of copying and pasting :>

Quote:

There is `isnull` macro, it is better checking first or second character than all of them (strlen).

I'm aware of that.
Reply


Messages In This Thread
Tester & admin chat - by Zeus666 - 13.10.2018, 12:15
Re: Tester & admin chat - by v1k1nG - 13.10.2018, 12:58
Re: Tester & admin chat - by Chyakka - 13.10.2018, 13:00
Re: Tester & admin chat - by ShadowMortar - 13.10.2018, 13:52
Re: Tester & admin chat - by Threshold - 14.10.2018, 01:29
Re: Tester & admin chat - by Calisthenics - 14.10.2018, 09:47
Re: Tester & admin chat - by Zeus666 - 14.10.2018, 10:16
Re: Tester & admin chat - by CaptainBoi - 14.10.2018, 12:42
Re: Tester & admin chat - by UFF - 14.10.2018, 12:44
Re: Tester & admin chat - by Boarden - 14.10.2018, 13:09

Forum Jump:


Users browsing this thread: 1 Guest(s)