[Help] Vip chat
#1

hi , i have this :
pawn Код:
dcmd_vchat( playerid, params[] )
{
    #pragma unused params

    if( Vip[ playerid ] < 1 )
        return SendClientMessage( playerid, COLOR_CERVENA, "  [!] Only Vips can do that !" );
    if(Vip[playerid] >= 1)
    {
         new name[24];
        GetPlayerName(playerid, name, 24);
        new string[300];
        format(string, sizeof(string), "[VIP CHAT] %s [%d]: %s", name, playerid, string[1]);
        SendClientMessage(playerid, COLOR_WHITE, string);
    }
    return 1;
but the problem is the script doesn't show what player say only %s: , i hope you help me
Reply
#2

pawn Код:
dcmd_vchat( playerid, params[] )
{
    if( Vip[ playerid ] < 1 )
        return SendClientMessage( playerid, COLOR_CERVENA, "  [!] Only Vips can do that !" );
    if(Vip[playerid] >= 1)
    {
        if(!strlen(params))  return SendClientMessage( playerid, COLOR_CERVENA, "Usage: /vchat [text]" );
        new name[24];
        GetPlayerName(playerid, name, 24);
        new string[300];
        format(string, sizeof(string), "[VIP CHAT] %s [%d]: %s", name, playerid, string[1]);
        for(new i=0; i<MAX_PLAYERS; i++) if(Vip[i]>=1) SendClientMessage(i, COLOR_WHITE, string);
    }
    return 1;
}
Reply
#3

thank you!
Reply
#4

Rather than the for loop I recommend that you use foreach. It's more efficient and there's no reason the string length should be 300, change it to 128.
Reply
#5

Quote:
Originally Posted by Zhao
Посмотреть сообщение
Rather than the for loop I recommend that you use foreach. It's more efficient and there's no reason the string length should be 300, change it to 128.
for loop -> foreach
Also, I agree about the lenght. Max lenght string in SA-MP is 128.
Reply
#6

lol i have writen in a string like string[800] because in a MSGBOX without it , it doesn't appear...
Reply
#7

I am talking about SendClientMessage function.
About the Dialogs, the max is 1024
Reply
#8

Quote:
Originally Posted by Dwane
Посмотреть сообщение
I am talking about SendClientMessage function.
About the Dialogs, the max is 1024
oh thanks for the information
Reply
#9

Hi dude!

You're making it way too complicated! Why don't you use it like this? Add this under "OnPlayerText":

pawn Код:
if(text[0] == '*')
    {
        if(PlayerInfo[playerid][VIP] >= 1)
        {
            new str[128], name[24];
            GetPlayerName(playerid, name, 24);
            format(str, 128, "[VIP CHAT] %s(%d): %s", name,playerid, text[1]);
            SendMessageToVIP(COLOR_KHAKI,str);
            return 0;
        }
        return 1;
    }
And forward this:

pawn Код:
forward SendMessageToVIP(color,const string[]);
pawn Код:
public SendMessageToVIP(color,const string[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) == 1)
        if(PlayerInfo[i][VIP] >= 1)
        SendClientMessage(i, color, string);
    }
    return 1;
}
I don't know what your enum for the player's info is like, just put a VIP-Level into it and replace the variables with your own! FINISHED!

Hope I could help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)