Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Kviz Pogodi Broj v1.0 © 2012, ->UrOS<-
- Contact e-mail [email protected]
- Formatright
- *English*
- This plugin is free software;
- you can modify it under the terms of the
- GNU General Public License as published by the Free Software Foundation.
- *Serbian*
- Ovaj plugin je besplatni program;
- mozete ga menjati postujuci prava autora, samo ga ne smete prodavati.
- */
- #include <amxmodx>
- #include <amxmisc>
- #include <colorchat>
- #include <nvault>
- #include <fakemeta>
- #define PLUGIN "Kviz Pogodi Broj"
- #define VERSION "1.0"
- #define AUTHOR "->UrOS<-"
- new resenje = 0
- new bool:kviz = false
- new pokusaji[33]
- new rank[33]
- new meni[33]
- new vreme
- new ucestalost
- new nagrada
- new opseg
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_cvar("pogodibroj", VERSION, (FCVAR_SERVER|FCVAR_SPONLY))
- register_concmd("say", "provera")
- register_concmd("say_team", "provera")
- register_clcmd("say /kviz","prikazimenu")
- register_clcmd("say_team /kviz","prikazimenu")
- register_clcmd("say /kviztop15","prikazitop15")
- register_clcmd("say_team /kviztop15","prikazitop15")
- register_clcmd("say /kvizrank","prikazirank")
- register_clcmd("say_team /kvizrank","prikazirank")
- vreme = register_cvar("pogodibroj_vreme", "60", ADMIN_RCON)
- ucestalost = register_cvar("pogodibroj_ucestalost", "90", ADMIN_RCON)
- nagrada = register_cvar("pogodibroj_nagrada", "16000", ADMIN_RCON)
- opseg = register_cvar("pogodibroj_opseg", "500", ADMIN_RCON)
- set_task(get_pcvar_float(ucestalost),"generisi")
- }
- public plugin_precache()
- {
- precache_sound("ambience/lv2.wav")
- precache_sound("buttons/bell1.wav")
- precache_sound("vox/bravo.wav")
- }
- public client_putinserver(id)
- {
- set_task(15.0, "reklama", id, _, _, "a", 1)
- rank[id] = ucitajrank(id)
- }
- public generisi()
- {
- resenje = random_num(1,get_pcvar_num(opseg))
- kviz = true
- set_hudmessage(85, 170, 255, 0.02, 0.65, 0, 6.0, 10.0)
- show_hudmessage(0, "[Kviz] Pogodi trazeni broj izmedju 1 i %d",get_pcvar_num(opseg))
- ColorChat(0, TEAM_COLOR, "^4[Kviz] ^1Pogodi trazeni broj izmedju^4 1 ^1i^4 %d",get_pcvar_num(opseg))
- client_cmd(0, "speak ambience/lv2.wav")
- set_task(get_pcvar_float(vreme),"vremeisteklo")
- for(new id=0;id<33;id++)
- pokusaji[id]=0
- }
- public vremeisteklo()
- {
- if(kviz)
- {
- kviz = false
- ColorChat(0, TEAM_COLOR, "^4[Kviz] ^1Vreme je isteklo, trazeni broj je bio ^3%d",resenje)
- client_cmd(0, "speak buttons/bell1.wav")
- }
- set_task(get_pcvar_float(ucestalost),"generisi")
- }
- public provera(id)
- {
- if(kviz)
- {
- new text[32]
- read_argv(1,text,31)
- new odgovor = str_to_num(text)
- if(odgovor==0 && (resenje != 0 || text[ 0 ] != '0'))
- return
- pokusaji[id]++
- if(odgovor>get_pcvar_num(opseg))
- {
- ColorChat(id, TEAM_COLOR, "^4[Kviz] ^1Trazi se samo broj izmedju^4 1 ^1i^4 %d",get_pcvar_num(opseg))
- }
- else if(resenje>odgovor)
- {
- ColorChat(id, TEAM_COLOR, "^4[Kviz] ^1Trazeni broj je ^3VECI ^1od unetog broja^3 %d",odgovor)
- }
- else if(resenje<odgovor)
- {
- ColorChat(id, TEAM_COLOR, "^4[Kviz] ^1Trazeni broj je ^4MANJI ^1od unetog broja^4 %d",odgovor)
- }
- else if(odgovor==resenje)
- {
- kviz = false
- new ime[32]
- get_user_name(id, ime, 31)
- set_pev(id, pev_frags, pev(id, pev_frags) + get_pcvar_num(nagrada)/pokusaji[id])
- message_begin( MSG_BROADCAST, get_user_msgid("ScoreInfo") )
- write_byte( id )
- write_short( pev(id, pev_frags))
- write_short( get_pdata_int(id, 444, 5) )
- write_short( 0 )
- write_short( get_pdata_int(id, 114, 5) )
- message_end( )
- rank[id] += 1
- sacuvajrank(id, rank[id])
- ColorChat(0, TEAM_COLOR, "^4[Kviz]^3 %s ^1je prvi pogodio trazeni broj^4 %d ^1sa^3 %d ^1pokusaja, nagrada^4 %d$",ime,resenje,pokusaji[id],get_pcvar_num(nagrada)/pokusaji[id])
- client_cmd(0, "speak buttons/bell1.wav")
- {
- client_cmd(id, "speak vox/bravo.wav")
- ColorChat(id, TEAM_COLOR, "^4[Kviz] ^1Cestitamo pogodili ste trazeni broj^4 %d ^1sa^3 %d ^1pokusaja, osvajate^4 %d fragova",resenje,pokusaji[id],get_pcvar_num(nagrada)/pokusaji[id])
- }
- }
- }
- }
- public ucitajrank( id )
- {
- new valut = nvault_open("kviz")
- new authid[33]
- new vaultkey[64], vaultdata[64]
- get_user_authid(id, authid, 32)
- format(vaultkey, 63, "_%s_BODOVI_", authid)
- nvault_get(valut, vaultkey, vaultdata, 63)
- nvault_close(valut)
- return str_to_num(vaultdata)
- }
- public sacuvajrank(id, bodovi)
- {
- new valut = nvault_open("kviz")
- if(valut == INVALID_HANDLE)
- set_fail_state("Greska nValut kviz (invalid handle)")
- new authid[32]
- new vaultkey[64], vaultdata[64]
- get_user_authid(id, authid, 31)
- format(vaultkey, 63, "_%s_BODOVI_", authid)
- format(vaultdata, 63, "%d^n", bodovi)
- nvault_set(valut, vaultkey, vaultdata)
- nvault_close(valut)
- }
- public prikazirank(id)
- ColorChat(id, TEAM_COLOR,"^4[Kviz] ^1Pogodili ste trazeni broj ^4%d ^1puta", rank[id])
- public prikazitop15(id)
- {
- new i, count, name[98]
- static sort[34][2]
- for(i=0;i<33;i++)
- {
- sort[count][0] = i
- sort[count][1] = rank[i]
- count++
- }
- SortCustom2D(sort,count,"stats")
- new buffer[2048]
- new line[256]
- new len = format( buffer, 2047, "<body bgcolor=#000000 style=^"color:#ffffff^"><pre><Center><img src=^"http://img62.imageshack.us/img62/2709/kvizzz.gif^"><table width=100%% cellpadding=1 cellspacing=1 border=0>")
- len += format( buffer[len], 2047-len, "<tr style=^"color:#8FABFF^"><th width=5%%>#<th width=60%%>Nick<th width=35%%>Broj pogodaka")
- new players[32], num
- get_players(players, num)
- new b = clamp(count,0,15)
- for(new a = 0; a < b; a++)
- {
- get_user_name(sort[a][0], name, 97)
- while (containi(name, "<") != -1)
- replace(name, 96, "<", "<")
- while (containi(name, ">") != -1)
- replace(name, 96, ">", ">")
- //if(sort[a][1] != 0) // ako ima 0 bodova ne prikazuje ga u listi
- {
- format(line, 255, "<tr %s><td>%d<td style=^"color:%s^">%s<td>%d", ((a%2)==0) ? " bgcolor=#333333" : " bgcolor=#262626", a+1,((a%2)==0) ? "#9CFF7A" : "red", name, sort[a][1])
- len += format( buffer[len], 2047-len, line )
- }
- }
- format(line, 255, "</table><font color=^"red^">(Statistika trenutno pristutnih igrača)</body></pre>" )
- len += format( buffer[len], 2047-len, line )
- show_motd(id, buffer, "Kviz - Top 15")
- return PLUGIN_CONTINUE
- }
- public stats(elem1[],elem2[])
- {
- if(elem1[1] > elem2[1]) return -1
- else if(elem1[1] < elem2[1]) return 1
- return 0
- }
- public prikazimotd(id)
- {
- static motd[1501], len
- len = format(motd, 1500,"<body bgcolor=#000000><font color=#87cefa><pre>")
- len += format(motd[len], 1500-len,"<center><img src=^"http://img62.imageshack.us/img62/2709/kvizzz.gif^"></center></img>")
- len += format(motd[len], 1500-len,"<center><h4><font color=^"red^"><B>%s - Verzija %s</B> </font></h4></center>", PLUGIN, VERSION)
- len += format(motd[len], 1500-len,"<center><h4><font color=^"blue^"><B>Plugin napravio %s</B> </font></h4></center>", AUTHOR)
- len += format(motd[len], 1500-len,"<center><h4><font color=^"white^"><B>Kontakt e-mail [email protected]</B> </font></h4></center>")
- len += format(motd[len], 1500-len,"<center><font color=^"white^"> </font></center>")
- len += format(motd[len], 1500-len,"<center><h4><font color=^"red^"><B>-----------------------</B> </font></h4></center>")
- len += format(motd[len], 1500-len,"<center><font color=^"white^">Za sva pitanja i informacije</font></center>")
- len += format(motd[len], 1500-len,"<center><font color=^"white^">pisite na gore navdeni e-mail</font></center>")
- len += format(motd[len], 1500-len,"<center><h4><font color=^"red^"><B>-----------------------</B> </font></h4></center>")
- show_motd(id, motd, "Kviz - Informacije")
- return 0
- }
- public prikazimenu(id)
- {
- formatex( meni, charsmax( meni ), "\rKviz Pogodi Broj \yv1.0")
- new menu = menu_create( meni, "menuakcija")
- formatex( meni, charsmax( meni ), "\d Vidi Rank")
- menu_additem( menu, meni, "0")
- formatex( meni, charsmax( meni ), "\d Vidi Top15")
- menu_additem( menu, meni, "1")
- formatex( meni, charsmax( meni ), "\d Informacije o pluginu")
- menu_additem( menu, meni, "2" )
- menu_display( id, menu )
- }
- public menuakcija( id, menu, item )
- {
- if( item >= 0 )
- {
- new access, callback, actionString[ 2 ]
- menu_item_getinfo( menu, item, access, actionString, charsmax( actionString ), _, _, callback )
- new action = str_to_num( actionString )
- {
- switch( action )
- {
- case 0:
- {
- prikazirank(id)
- set_task(0.1, "prikazimenu", id, _, _, "a", 1)
- }
- case 1:
- {
- prikazitop15(id)
- set_task(0.1, "prikazimenu", id, _, _, "a", 1)
- }
- case 2:
- {
- prikazimotd(id)
- set_task(0.1, "prikazimenu", id, _, _, "a", 1)
- }
- }
- }
- }
- menu_destroy( menu )
- return PLUGIN_HANDLED
- }
- public reklama(id)
- {
- if(is_user_connected(id))
- {
- ColorChat(id, TEAM_COLOR, "^4[Kviz] ^1Ovaj server koristi ^3%s v%s ^1za informacije o pluginu ^3say /kviz", PLUGIN, VERSION)
- set_task(600.0, "reklama", id, _, _, "a", 1)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment