(FS) Dialog Chat

Готовые решения скриптов, filterScript

Moderator: SJplayer

Avatar
Topic author
SJplayer M
Модератор
Модератор
Posts: 191
With us: 7 years 4 months

(FS) Dialog Chat

Post #1by SJplayer » 3 Jul 2013, 16:42

(FS) Dialog Chat
Идея: Folleah
Код: SDraw
Тестирование: Burton


Image


Два окна: Со списком тех, кто в чате, и сам диалог с чатом. Обновление только ручное (отсылкой сообщения или просто нажатием Enter'a), так как если обновлять диалог всем при отправке, текст, который вводили другие, но не отправили, пропадает.

Код

Code: Select all

#define FILTERSCRIPT
#include <a_samp>
#undef MAX_PLAYERS
#define MAX_PLAYERS (10)
#define FOREACH_NO_BOTS
#include <foreach>
#define LIST (10)
#define INBOX (11)
new Iterator:InChat<MAX_PLAYERS>;
new Lines[10][128] = {"\n","\n","\n","\n","\n","\n","\n","\n","\n","\n"};
 
public OnPlayerDisconnect
(playerid,reason)
{
    if(Iter_Contains(InChat,playerid)) Iter_Remove(InChat,playerid);
    return 1;
}
 
public OnPlayerCommandText
(playerid,cmdtext[])
{
    if(!strcmp(cmdtext,"/chat"))
    {
        if(Iter_Contains(InChat,playerid)) return SendClientMessage(playerid,-1,"Вы уже в чате.");
        if(Iter_Count(InChat) == 0) ShowPlayerDialog(playerid,LIST,DIALOG_STYLE_MSGBOX,"Состав конференции","Пусто","Войти","Отмена");
        else
        
{
            new str[256],plname[32];
            foreach(new i : InChat)
            {
                GetPlayerName(i,plname,32);
                format(str,256,"%s%s\n",str,plname);
            }
            ShowPlayerDialog(playerid,LIST,DIALOG_STYLE_MSGBOX,"Состав конференции",str,"Войти","Отмена");
        }
        return 1;
    }
    return 1;
}
 
public OnDialogResponse
(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == LIST)
    {
        if(response)
        {
            Iter_Add(InChat,playerid);
            new str[1024];
            format(str,64,"_______________________________________________________\n");
            for(new i = 0; i < 10; i++) format(str,960,"%s%s",str,Lines[i]);
            ShowPlayerDialog(playerid,INBOX,DIALOG_STYLE_INPUT,"Чат",str,"Отправить","Выйти");
        }
        return 1;
    }
    if(dialogid == INBOX)
    {
        if(response)
        {
            if(strlen(inputtext) == 0)
            {
                new str[1024];
                format(str,64,"_______________________________________________________\n");
                for(new i = 0; i < 10; i++) format(str,1024,"%s%s",str,Lines[i]);
                ShowPlayerDialog(playerid,INBOX,DIALOG_STYLE_INPUT,"Чат",str,"Отправить","Выйти");
            }
            else
            
{
                new skf[2],lp = 0;
                while(lp != strlen(inputtext))
                {
                    skf[0] = strfind(inputtext,"{",false,lp);
                    if(skf[0] != -1)
                    {
                        skf[1] = strfind(inputtext,"}",false,skf[0]);
                        if(skf[1] != -1)
                        {
                            strdel(inputtext,skf[0],skf[1]+1);
                            lp = skf[0];
                        }
                        else lp = strlen(inputtext);
                    }
                    else lp = strlen(inputtext);
                }
                new bool:pr = true,text[96],li = 0;
                for(new i = 0; i < 95, i < strlen(inputtext); i++)
                {
                    if(inputtext[i] == ' ')
                    {
                        if(pr) continue;
                        else
                        
{
                            text[li] = inputtext[i];
                            pr = true;
                            li++;
                        }
                    }
                    else
                    
{
                        text[li] = inputtext[i];
                        li++;
                        pr = false;
                    }
                }
                text[li] = '\0';
                if(strlen(text) == 0)
                {
                    new str[1024];
                    format(str,64,"_______________________________________________________\n");
                    for(new i = 0; i < 10; i++) format(str,1024,"%s%s",str,Lines[i]);
                    ShowPlayerDialog(playerid,INBOX,DIALOG_STYLE_INPUT,"Чат",str,"Отправить","Выйти");
                    return 1;
                }
                new plname[32];
                for(new i = 1; i < 10; i++) format(Lines[i-1],96,Lines[i]);
                GetPlayerName(playerid,plname,32);
                format(Lines[9],128,"{A9C4E4}%s: {FFFFFF}%s\n",plname,text);
                new str[1024];
                format(str,64,"_______________________________________________________\n");
                for(new i = 0; i < 10; i++) format(str,1024,"%s%s",str,Lines[i]);
                ShowPlayerDialog(playerid,INBOX,DIALOG_STYLE_INPUT,"Чат",str,"Отправить","Выйти");
            }
        }
        else Iter_Remove(InChat,playerid);
        return 1;
    }
    return 1;
}

! ! !


Return to “Скрипты / FS”

Who is online

Users browsing this forum: 1 guest