{========================================================================== Multidados v2.4.1 Autor: Luciano Neiva Nery Última atualização: sábado, 25 de janeiro de 2004 Lança uma quantidade de tipos de dados escolhida pelo usuário. Eventos: ON TEXT:*!dados*:#:/runscript [log] # $nick $gravarlog texto *1 | /runscript [roll] # $nick $gravarlog *1 ON TEXT:*!dados*:?:/runscript [log] $nick $nick $gravarlog texto *1 | /runscript [roll] $nick $nick $gravarlog *1 ON INPUT:*!dados*:*:/runscript [log] $activewin $me $gravarlog texto *1 | /runscript [roll] $activewin $me $gravarlog *1 ==========================================================================} function strsearch(texto1, texto2: string; apartir: value): value; var cont, achou: value; begin texto1 := strupper(texto1); texto2 := strupper(texto2); achou := 0; if apartir > strlen(texto2) then apartir := strlen(texto2) else if apartir < 1 then apartir := 1; cont := apartir; while not (achou) and (cont <= strlen(texto2)) and (strlen(texto2) > 0) do begin if strcopy(texto2, cont, strlen(texto1)) = texto1 then achou := 1 else cont := cont + 1; breathe; end; if achou then strsearch := cont else strsearch := 0; end; function isnumber(texto: string): value; var cont: value; valido: value; begin valido := 1; cont := 1; if (strcopy(texto, 1, 1) = '+') or (strcopy(texto, 1, 1) = '-') then strdel(texto, 1, 1); if strlen(texto) <= 0 then valido := 0 else begin while (cont <= strlen(texto)) and (valido) do begin if (strcopy(texto, cont, 1) <> '0') and (strcopy(texto, cont, 1) <> '1') and (strcopy(texto, cont, 1) <> '2') and (strcopy(texto, cont, 1) <> '3') and (strcopy(texto, cont, 1) <> '4') and (strcopy(texto, cont, 1) <> '5') and (strcopy(texto, cont, 1) <> '6') and (strcopy(texto, cont, 1) <> '7') and (strcopy(texto, cont, 1) <> '8') and (strcopy(texto, cont, 1) <> '9') then valido := 0; cont := cont + 1; breathe; end; end; isnumber := valido; end; function strtrim(texto: string): string; var cont, cont2, postexto: value; begin cont := 1; while cont <= strlen(texto) do begin if strcopy(texto, cont, 1) = '' then {ctrl+k} begin postexto := strsearch(',', texto, cont); if postexto > 0 then strdel(texto, cont, (postexto - cont) + 1) else strdel(texto, cont, 1); for cont2 := 1 to 2 do begin if isnumber(strcopy(texto, cont, 1)) then strdel(texto, cont, 1); breathe; end; end else if (strcopy(texto, cont, 1) = '') or (strcopy(texto, cont, 1) = '') or (strcopy(texto, cont, 1) = '') or (strcopy(texto, cont, 1) = '') or (strcopy(texto, cont, 1) = '') or (strcopy(texto, cont, 1) = '') then {ctrl+b,i,u,s,f,} strdel(texto, cont, 1) else cont := cont + 1; breathe; end; while strcopy(texto, strlen(texto), 1) = ' ' do begin strdel(texto, strlen(texto), 1); breathe; end; while strcopy(texto, 1, 1) = ' ' do begin strdel(texto, 1, 1); breathe; end; strtrim := texto; end; $texto := *4; if strpos('!DADOS', strupper(strtrim($texto))) = 1 then begin maxdados := 25; maxbonus := 30; $msg := ''; $chan := $1; $nick := $2; $log := $3; calcular := 1; erro := 0; while calcular do begin breathe; erro := 0; dado := 0; totalsembonus := 0; totalcombonus := 0; qtd := 0; tipo := 0; bonus := 0; $qtd := ''; $tipo := ''; $bonus := ''; if $msg = '' then begin $comando := *5; $comando := strupper(strtrim($comando)); end else $comando := strtrim($comando); posicao := strpos('D', $comando); posicsinal := strsearch('+', $comando, posicao); auxposicao := strpos(' ', $comando); if (auxposicao > 0) and (posicsinal > auxposicao) then posicsinal := 0; if posicsinal = 0 then posicsinal := strsearch('-', $comando, posicao); if (auxposicao > 0) and (posicsinal > auxposicao) then posicsinal := 0; if posicao > 0 then begin $qtd := strcopy($comando, 1, posicao - 1); if isnumber($qtd) then begin qtd := strtoint($qtd); if (qtd <= maxdados) and (qtd > 0) then begin if posicsinal = 0 then $tipo := strtrim(strcopy($comando, posicao + 1, strlen($comando) - posicao)) else $tipo := strtrim(strcopy($comando, posicao + 1, (posicsinal - 1) - posicao)); $tipo := strtoken($tipo); if isnumber($tipo) then begin tipo := strtoint($tipo); if (tipo = 2) or (tipo = 3) or (tipo = 4) or (tipo = 6) or (tipo = 8) or (tipo = 10) or (tipo = 12) or (tipo = 20) or (tipo = 100) then begin if posicsinal > 0 then begin $bonus := strcopy($comando, posicsinal, strlen($comando) - posicsinal + 1); if $bonus <> '' then begin auxposicao := strpos(' ', $bonus); if (auxposicao > 0) then $bonus := strcopy($bonus, 1, auxposicao - 1); end; strdel($comando, 1, posicsinal + strlen($bonus) - 1); end else begin auxposicao := strpos(' ', $comando); if (auxposicao = 0) then $comando := '' else strdel($comando, 1, auxposicao); end; if (isnumber($bonus)) or ((strtrim($bonus) = '') and (posicsinal = 0)) then begin if isnumber($bonus) then bonus := strtoint($bonus); if bonus <= maxbonus then begin if $msg = '' then $msg := ', seu(s) resultado(s):' else $msg := $msg + ' 0/ '; for cont := 1 to qtd do begin dado := random(tipo) + 1; totalsembonus := totalsembonus + dado; totalcombonus := totalcombonus + dado + bonus; $msg := $msg + '8,1 ' + inttostr(dado) + ' 8,1(' + inttostr(dado + bonus) + ')'; if cont < qtd then $msg := $msg + ','; breathe; end; $msg := $msg + ', 16,1total8,1 ' + inttostr(totalsembonus + bonus) + ' 8,1(' + inttostr(totalcombonus) + ')'; end else begin erro := 1; $msg := ': o bônus máximo permitido é ' + inttostr(maxbonus); end; end else begin erro := 1; $msg := ': bônus inválido, use os sinais + ou - após o tipo de dado, seguido do valor do bônus'; end; end else begin erro := 1; $msg := ': o tipo de dado deve ser 2, 3, 4, 6, 8, 10, 12, 20 ou 100'; end; end else begin erro := 1; $msg := ': o tipo de dado deve ser 2, 3, 4, 6, 8, 10, 12, 20 ou 100'; end; end else begin erro := 1; if qtd > maxdados then $msg := ': a quantidade máxima de dados a ser lançada é ' + inttostr(maxdados) else $msg := ': a quantidade de dados deve ser um número entre 1 e ' + inttostr(maxdados); end; end else begin erro := 1; $msg := ': a quantidade de dados deve ser um número entre 1 e ' + inttostr(maxdados); end; end else begin erro := 1; $msg := ': erro de sintaxe, use !dados d[+bônus,-bônus], ex.: !dados 3d6+3'; end; if erro then calcular := 0 else if $comando = '' then calcular := 0 else calcular := 1; end; if not erro then begin posicao := strpos('DADOS', strupper($texto)); if posicao > 0 then strdel($texto, 1, posicao +5); $texto := strtrim($texto); $comando := ' 16,1Lançando8,1 ' + $texto + ' 16,1para8,1 ' + $nick + ''; command('/runscript [log] ', $chan, ' ', $me, ' ', $gravarlog, ' texto ', $comando); command('/msg ',$chan,' ', $comando); end; $comando := ' 8,1' + $nick + '16,1' + $msg; command('/runscript [log] ', $chan, ' ', $me, ' ', $gravarlog, ' texto ', $comando); command('/msg ',$chan, ' ', $comando); end;