Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- SA-MP Chatbox
- von pwnfl4sh
- v3
- */
- #include <a_samp>
- #undef MAX_PLAYERS
- #define MAX_PLAYERS 25
- #define SHOW_INFO
- #define ALLOW_COLORS
- #define CHAT_WIDTH 170.0
- #define DIALOG_FARBE 1337
- new Text:ChatBox;
- new Text:ChatLine[10];
- new Text:ChatInfo;
- new ChatStr[10][128];
- public OnFilterScriptInit()
- {
- ChatBox = TextDrawCreate(30.000000, 190.000000, "__");
- TextDrawBackgroundColor(ChatBox, 255);
- TextDrawFont(ChatBox, 1);
- TextDrawLetterSize(ChatBox, 0.000000, 14.000000);
- TextDrawColor(ChatBox, -1);
- TextDrawSetOutline(ChatBox, 0);
- TextDrawSetProportional(ChatBox, 1);
- TextDrawSetShadow(ChatBox, 1);
- TextDrawUseBox(ChatBox, 1);
- TextDrawBoxColor(ChatBox, 370546326);
- TextDrawTextSize(ChatBox, 30.000000+CHAT_WIDTH, -10.000000);
- TextDrawSetSelectable(ChatBox, 0);
- for(new i=0;i<10;i++)
- {
- ChatLine[i] = TextDrawCreate(31.000000, 191.000000+(i*10), "_");
- TextDrawBackgroundColor(ChatLine[i], 255);
- TextDrawFont(ChatLine[i], 1);
- TextDrawLetterSize(ChatLine[i], 0.219999, 0.899999);
- TextDrawColor(ChatLine[i], -1);
- TextDrawSetOutline(ChatLine[i], 0);
- TextDrawSetProportional(ChatLine[i], 1);
- TextDrawSetShadow(ChatLine[i], 1);
- TextDrawSetSelectable(ChatLine[i], 0);
- format(ChatStr[i],128,"_");
- }
- ChatInfo = TextDrawCreate(32.000000, 302.000000, "~r~T~w~ zum Chatten...");
- TextDrawBackgroundColor(ChatInfo, 255);
- TextDrawFont(ChatInfo, 1);
- TextDrawLetterSize(ChatInfo, 0.500000, 1.000000);
- TextDrawColor(ChatInfo, -1);
- TextDrawSetOutline(ChatInfo, 0);
- TextDrawSetProportional(ChatInfo, 1);
- TextDrawSetShadow(ChatInfo, 1);
- TextDrawSetSelectable(ChatInfo, 0);
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- SetPVarInt(playerid,"Chat",0);
- SetPVarInt(playerid,"Farbe",0);
- SendClientMessage(playerid,-1,"Um die Chatbox anzuzeigen, tippe /chatbox.");
- #if defined ALLOW_COLORS
- SendClientMessage(playerid,-1,"Deine Chatfarbe kannst du mit /farbe ändern.");
- #endif
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- new tstr[128], name[MAX_PLAYER_NAME];
- GetPlayerName(playerid,name,MAX_PLAYER_NAME);
- new maxlen = floatround(((CHAT_WIDTH * 0.24)-strlen(name))-1,floatround_ceil);
- switch(GetPVarInt(playerid,"Farbe"))
- {
- case 0:
- {
- format(tstr,128,"%s~w~: %s",name,text);
- }
- case 1:
- {
- format(tstr,128,"~r~~h~~h~%s~w~: %s",name,text);
- }
- case 2:
- {
- format(tstr,128,"~y~%s~w~: %s",name,text);
- }
- case 3:
- {
- format(tstr,128,"~b~~h~%s~w~: %s",name,text);
- }
- case 4:
- {
- format(tstr,128,"~g~~h~~h~%s~w~: %s",name,text);
- }
- }
- if(strlen(text) > maxlen)
- {
- format(tstr,128,"Maximale Textlänge überschritten(>>%d/%d<<)",strlen(text),maxlen);
- SendClientMessage(playerid,-1,tstr);
- }
- else
- {
- new line = FreeChatLine();
- format(ChatStr[line],128,tstr);
- for(new i=0;i<10;i++)
- {
- TextDrawSetString(ChatLine[i],ChatStr[i]);
- }
- for(new i=0;i<MAX_PLAYERS;i++)
- {
- if(IsPlayerConnected(i))
- {
- if(GetPVarInt(i,"Chat") == 1)
- {
- HideChatBox(i);
- ShowChatBox(i);
- }
- }
- }
- }
- return 0;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext,"/chatbox",true))
- {
- if(GetPVarInt(playerid,"Chat") == 0)
- {
- ShowChatBox(playerid);
- }
- else if(GetPVarInt(playerid,"Chat") == 1)
- {
- HideChatBox(playerid);
- }
- return 1;
- }
- #if defined ALLOW_COLORS
- if(!strcmp(cmdtext,"/farbe",true))
- {
- ShowPlayerDialog(playerid,DIALOG_FARBE,DIALOG_STYLE_LIST,"{FFFFFF}Chatfarbe auswählen","{FFFFFF}Weiß\n{FF4450}Rot\n{FFD100}Gelb\n{00A1FF}Blau\n{00FF73}Grün","Wählen","Abbr.");
- return 1;
- }
- #endif
- return 0;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- if(response)
- {
- if(dialogid == DIALOG_FARBE)
- {
- switch(listitem)
- {
- case 0:
- {
- SetPVarInt(playerid,"Farbe",0);
- SendClientMessage(playerid,-1,"Deine Chatfarbe ist jetzt Weiß.");
- }
- case 1:
- {
- SetPVarInt(playerid,"Farbe",1);
- SendClientMessage(playerid,0xFF4500FF,"Deine Chatfarbe ist jetzt Rot.");
- }
- case 2:
- {
- SetPVarInt(playerid,"Farbe",2);
- SendClientMessage(playerid,0xECE65BFF,"Deine Chatfarbe ist jetzt Gelb.");
- }
- case 3:
- {
- SetPVarInt(playerid,"Farbe",3);
- SendClientMessage(playerid,0x33CCFFAA,"Deine Chatfarbe ist jetzt Blau.");
- }
- case 4:
- {
- SetPVarInt(playerid,"Farbe",4);
- SendClientMessage(playerid,0x10F441AA,"Deine Chatfarbe ist jetzt Grün.");
- }
- }
- }
- }
- return 1;
- }
- stock ShowChatBox(playerid)
- {
- SetPVarInt(playerid,"Chat",1);
- TextDrawShowForPlayer(playerid,ChatBox);
- for(new i=0;i<10;i++)
- {
- TextDrawShowForPlayer(playerid,ChatLine[i]);
- }
- #if defined SHOW_INFO
- TextDrawShowForPlayer(playerid,ChatInfo);
- #endif
- return 1;
- }
- stock HideChatBox(playerid)
- {
- SetPVarInt(playerid,"Chat",0);
- TextDrawHideForPlayer(playerid,ChatBox);
- for(new i=0;i<10;i++)
- {
- TextDrawHideForPlayer(playerid,ChatLine[i]);
- }
- #if defined SHOW_INFO
- TextDrawHideForPlayer(playerid,ChatInfo);
- #endif
- return 1;
- }
- stock FreeChatLine()
- {
- new line = -1;
- for(new i=0;i<10;i++)
- {
- if(!strcmp(ChatStr[i],"_",false))
- {
- line = i;
- break;
- }
- }
- if(line == -1)
- {
- for(new i=0;i<9;i++)
- {
- format(ChatStr[i],128,ChatStr[i+1]);
- }
- line = 9;
- format(ChatStr[9],128,"_");
- }
- return line;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement