SA-MP Forums Archive
Admin Chat - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Admin Chat (/showthread.php?tid=348756)



Admin Chat - RieTzz - 06.06.2012

pawn Код:
CMD:a(playerid, params[])
{
     if(PlayerData[playerid][AdminLevel] < 1) return SendClientMessage(playerid,COLOR_RED,"You need to be an administrator to use this command!");
     new text[128];
     if(sscanf(params,"s[128]",text)) return SendClientMessage(playerid,COLOR_RED,"-USAGE- /a [text]");
     for(new i = 0;i<MAX_PLAYERS;i++)
 {
        if(!IsPlayerConnected(i)) continue;
        if(PlayerData[playerid][AdminLevel] < 1) continue;
        SendClientMessageEx(i,color_yellow,"ssss","Adminchat: ",PlayerInfo[playerid][Username],": {FFFFFF}",text);
    }
    return 1;
}

Hey guys! Ive got this as a adminchat, but it doesnt work ! :<

and ive got this errors! (Sorry, yes i am a noob)

pawn Код:
C:\Users\Rietz\Desktop\SAMP\gamemodes\gys.pwn(420) : error 017: undefined symbol "SendClientMessageEx"
C:\Users\Rietz\Desktop\SAMP\gamemodes\gys.pwn(420) : warning 215: expression has no effect
C:\Users\Rietz\Desktop\SAMP\gamemodes\gys.pwn(420) : error 001: expected token: ";", but found "]"
C:\Users\Rietz\Desktop\SAMP\gamemodes\gys.pwn(420) : error 029: invalid expression, assumed zero
C:\Users\Rietz\Desktop\SAMP\gamemodes\gys.pwn(420) : fatal error 107: too many error messages on one line



Re: Admin Chat - Jonny5 - 06.06.2012

you cannot use SendClientMessage to format a string
and im not sure why you would use SendClientMessageEx at all in this case

you must format a string first then use it in sendclientmessage

kinda like this

pawn Код:
CMD:a(playerid, params[])
{
     if(PlayerData[playerid][AdminLevel] < 1) return SendClientMessage(playerid,COLOR_RED,"You need to be an administrator to use this command!");
     new text[128],strOut[128];
     if(sscanf(params,"s[128]",text)) return SendClientMessage(playerid,COLOR_RED,"-USAGE- /a [text]");
     for(new i = 0;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(PlayerData[playerid][AdminLevel] < 1) continue;
        format(strOut,sizeof(strOut),"%s%s%s%s","Adminchat: ",PlayerInfo[playerid][Username],": {FFFFFF}",text);
        SendClientMessage(i,color_yellow,strOut);
    }
    return 1;
}



Re: Admin Chat - RieTzz - 06.06.2012

Oh, aha, I'll see if it works :>


EDIT1: Im gonna make it so only admins can see it? :<


Re: Admin Chat - Jonny5 - 06.06.2012

everyone makes this mistake early on

good luck with ya code.



~J5


Re: Admin Chat - MadeMan - 06.06.2012

1) Use 'i' instead of 'playerid' in 'AdminLevel'
2) You don't need to format the string every time, only once and then send it to all admins

pawn Код:
format(strOut,sizeof(strOut),"Adminchat: %s: {FFFFFF}%s",PlayerInfo[playerid][Username],text);
     for(new i = 0;i<MAX_PLAYERS;i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(PlayerData[i][AdminLevel] < 1) continue;
        SendClientMessage(i,color_yellow,strOut);
    }



Re: Admin Chat - RieTzz - 06.06.2012

Thnak you, but why do I need to use "i" instead of "playerid"?


Re: Admin Chat - MadeMan - 06.06.2012

Quote:
Originally Posted by RieTzz
Посмотреть сообщение
Thnak you, but why do I need to use "i" instead of "playerid"?
So it will check if the player who will get the message is admin, not the player who sends the message.