Дата: 16.02.2011, Среда, 02:38:00 | Сообщение # $NUMBER
Группа: VIP
Сообщений: 1021
Автор:ZaR Описание Как бэ анти-флуд в одну секунду. Если в секунду больше текста пишем, то выводится окно с каптчей. Количество строчек:46 Quote #include <a_samp> new Flood[MAX_PLAYERS]; new Answer[MAX_PLAYERS][10]; new ChatText[MAX_PLAYERS][256]; new bool:DialogPower[MAX_PLAYERS]; public OnFilterScriptInit(){ for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)&&!IsPlayerNPC(i)) Flood[i]=GetTickCount()+1000; return 1;} public OnPlayerText(playerid, text[]){ if(DialogPower[playerid]) return 0; if(Flood[playerid]+1000>GetTickCount()){ new str[256]; format(Answer[playerid],10,"%c%c%c%c",mathrandom(65,90),mathrandom(65,90),mathrandom(65,90),mathrandom(65,90)); format(str, 256, "Ââåäèòå êîä %s: ", Answer[playerid]); format(ChatText[playerid], 256, "%s", text); ShowPlayerDialog(playerid, 99, DIALOG_STYLE_INPUT, "Captcha", str, "Ââåñòè", "Êèêíóòüñÿ"); DialogPower[playerid]=true; return 0;} Flood[playerid]=GetTickCount(); return 1;} public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]){ if(dialogid==99) if(response){ if(!strcmp(inputtext, Answer[playerid])){ SendPlayerMessageToAll(playerid, ChatText[playerid]); Flood[playerid]=GetTickCount(); DialogPower[playerid]=false;} else{ DialogPower[playerid]=true; format(Answer[playerid],10,"%c%c%c%c",mathrandom(65,90),mathrandom(65,90),mathrandom(65,90),mathrandom(65,90)); new str[256]; format(str, 256, "Ââåäèòå êîä %s: ", Answer[playerid]); ShowPlayerDialog(playerid, 99, DIALOG_STYLE_INPUT, "Captcha", str, "Ââåñòè", "Ïîëó÷èòü äðóãóþ");} }else{ DialogPower[playerid]=true; format(Answer[playerid],10,"%c%c%c%c",mathrandom(65,90),mathrandom(65,90),mathrandom(65,90),mathrandom(65,90)); new str[256]; format(str, 256, "Ââåäèòå êîä %s: ", Answer[playerid]); ShowPlayerDialog(playerid, 99, DIALOG_STYLE_INPUT, "Captcha", str, "Ââåñòè", "Ïîëó÷èòü äðóãóþ");} return 1;} stock mathrandom(min,max) { new g=random(max); while(g<min) g=random(max); return g;}
|