PDA

View Full Version : Fast typing event


floatman
09-10-2012, 10:34
Description:
Every x seconds (x is a CVAR), the plugin is creating a new set of random chars and prints it as a hud message. The player who types first these chars is rewarded with an amount of money (CVAR). The array which stores the set is being cleared after x secs after the message is printed (x is a CVAR).

Cvars:
fastev_responsetime (default: 20.0)
fastev_moneyprize (default: 5000)
fastev_repeattime (default: 120.0)
fastev_randomamount (default: 1)
fastev_randommin (default: 500)
fastev_randommax (default: 5000)
fastev_hudtime (default: 25.0)

Note: if you have the fastev_randomamount CVAR set to 1, the fastev_moneyprize will be ignored.

Modules:
cstrike
nvault (3.0 -)

ML (1.0 - 2.1 versions):
[en] - floatman
[lt] - BeasT
[ro] - AleeKz
[pt] - quilhos
[es] - lucas_7_94

ML (2.2 - 3.1 versions):
[en] - floatman
[ro] - AleeKz
[sk] - luki1412
[tr] - Erdener


ML (3.2 - current versions):
[en] - floatman
[de] - UchihaSkills

Changelog:

3.2 - code optimization
3.1 - added a cvar to help you handle the holdtime of the hud message
3.0 - major improvement in the code;
- nvault required;
- the restriction system is now using steam ids to ban users from participating to the event;
2.3 - cvar for a random amount of money (as a prize)
2.2 - added a restriction system for players
2.1 - temporary solution for % and ;
2.0 - new random system
- code optimization

1.0 - first releasePlease report any mistakes, bugs etc.

BeasT
09-10-2012, 11:03
Nice :fox:

[lt]
NEW_CODE = Ivesk siuos simbolius, kad laimetum pinigini priza:
ANNOUNCE_WINNER = %s laimejo %d$.

AleeKz
09-10-2012, 12:21
Cool.

Here it's the romanian translation :


[ro]
NEW_CODE = Scrie urmatoarele caractere pentru a primi un premiu in bani:
ANNOUNCE_WINNER = %s a castigat %d$.

kiki33hun
09-10-2012, 13:35
Haha, good joob!

mabaclu
09-13-2012, 11:55
Make it random so that the letters are shown from 30 seconds before to 30 seconds after the time set in the CVAR.

floatman
09-13-2012, 13:25
Make it random so that the letters are shown from 30 seconds before to 30 seconds after the time set in the CVAR.
You want me to extend the holdtime of the hud message?

quilhos
09-13-2012, 17:14
[pt]
NEW_CODE = Escreve os seguintes caracteres para ganhares um premio (dinheiro):
ANNOUNCE_WINNER = %s ganhou %d$.

fysiks
09-13-2012, 19:10
There is a lot of excessive code.
Characters are not entirely random.
There is a much better way to do this if you want random characters in the code string.

YamiKaitou
09-13-2012, 19:33
A few improvements

public clear_vars()
{
for( new i = 0; i < 500; i++ )
g_Codename[ i ] = EOS;

for( new j = 0; j < 10; j++ )
{
for(new k = 0; k < 2; k++)
{
g_Total[ k ][ j ] = EOS;
}
}

g_On = 0;
}
->
public clear_vars()
{
arrayset(g_Codename, EOS, sizeof(g_Codename));

new j = sizeof(g_Total);
for (new k = 0; k < j; k++)
arrayset(g_Total, EOS, sizeof(g_Total[k]));

g_On = 0;
}

public plugin_init()
{
new Float:time = get_pcvar_float( g_RepTime );

set_task( time, "create", _, _, _, "b" );
}
->
public plugin_cfg()
{
set_task( get_pcvar_float( g_RepTime ), "create", _, _, _, "b" );
}

Do Not Hardcode your lengths, use charsmax (http://hg.alliedmods.net/amxmodx-central/file/tip/plugins/include/string.inc#l14) for strings and sizeof for loops

Most, if not all, of your 2D arrays have no point being 2D, make them 1D

new g_Codename[ 500 ];
->
new g_Codename[ 20 ];

Use formatex (http://hg.alliedmods.net/amxmodx-central/file/tip/plugins/include/string.inc#l41) instead of format (http://hg.alliedmods.net/amxmodx-central/file/tip/plugins/include/string.inc#l31)

lucas_7_94
09-13-2012, 20:36
@Yami , array_set doesnt exist , i think you mean arrayset.

fysiks
09-13-2012, 21:06
@Yami , array_set doesnt exist , i think you mean arrayset.

That's ok because g_Total should not exist anyways and therefore there will be no need for arrayset().

lucas_7_94
09-13-2012, 21:16
I mean array_set doesnt exists.

fysiks
09-13-2012, 21:56
I mean array_set doesnt exists.

You already said that once. I can read.

lucas_7_94
09-13-2012, 22:13
My bad , sorry i translate your post bad , sorry.

YamiKaitou
09-13-2012, 22:17
@Yami , array_set doesnt exist , i think you mean arrayset.
Opps, fixed

That's ok because g_Total should not exist anyways and therefore there will be no need for arrayset().
I use it twice. But I agree about g_Total

fysiks
09-13-2012, 22:57
I use it twice. But I agree about g_Total

The other one (for g_Codename) will not be needed when you fix that to be a single array instead of a multidimensional array.

YamiKaitou
09-13-2012, 23:18
g_Codename is a 1D array. Maybe I'm lost as to what you are suggesting.

fysiks
09-13-2012, 23:44
g_Codename is a 1D array. Maybe I'm lost as to what you are suggesting.

Oops, your right, I was thinking I remembered another useless multidimensional array (Oh, found it, it's "Message"), my bad lol.

So, what I meant to say, to get rid of all arrayset()'s, is that because it's a string, you simply need to assign the 0th element to the value EOS to effectively "clear" it (as long as you never reference individual characters with non-string methods).

floatman
09-14-2012, 05:35
Thank you all for your support. Updated to 2.0 version.

lucas_7_94
09-14-2012, 09:20
[ES]
NEW_CODE = Tipea los siguientes caracteres para ganar una recompenza (dinero)
ANNOUNCE_WINNER = %s gano %d$

Razvann.
09-15-2012, 07:43
[ro]
NEW_CODE = Tasteaza urmatoarele caractere pentru a castiga un premiu (bani):
ANNOUNCE_WINNER = %s a castigat %d$.

floatman
09-15-2012, 11:56
Updated to 2.2. A new restriction system has been implemented. Basically, it creates a file in the /configs/ folder. If you're trying to unrestrict the player, the plugin will automatically add a semicolon in front of the players' name in that file (fastev_restrictedusers.ini).

Any sugestions that will improve the plugin are welcomed.

mabaclu
09-15-2012, 12:11
You want me to extend the holdtime of the hud message?

No, to make the time when the letters are shown a bit more random.

floatman
09-15-2012, 13:09
No, to make the time when the letters are shown a bit more random.
I will consider that in the next version.

fysiks
09-15-2012, 13:24
You shouldn't be reading the file more than once during the whole map. It is currently EXTREMELY inefficient. Consider using a Trie to cache the "blocked" status. Also, use only SteamIDs.

floatman
09-15-2012, 13:48
You shouldn't be reading the file more than once during the whole map. It is currently EXTREMELY inefficient. Consider using a Trie to cache the "blocked" status. Also, use only SteamIDs.
Will do.

sonel
09-15-2012, 14:28
Can you add custom words?

quilhos
09-16-2012, 08:14
You can do for example a .ini file where people put words and that words will be used into event :)

fysiks
09-16-2012, 13:36
You can do for example a .ini file where people put words and that words will be used into event :)

What event?

YamiKaitou
09-16-2012, 14:36
Why are you still saving get_pcvar_float to a variable and then using that variable only once?

fysiks
09-16-2012, 14:44
Also, you shouldn't use "time" as a variable since it is a function.

lucas_7_94
09-16-2012, 14:45
Also , use Steamids , its a poor method detect with name.

BeasT
09-16-2012, 15:20
Consider using dhud or update the msg every 0.1 or so seconds, because now, the hud is overwritten by other plugin hud msgs.

quilhos
09-16-2012, 18:35
What event?

"Fast typing event"

Merciless
09-17-2012, 15:44
for( new j = 0; j < sizeof g_Codename - 1; j++ )


->


new iLen = sizeof g_Codename - 1
for( new j = 0; j < iLen; j++ )

fysiks
09-17-2012, 18:59
for( new j = 0; j < sizeof g_Codename - 1; j++ )


->


new iLen = sizeof g_Codename - 1
for( new j = 0; j < iLen; j++ )


This is likely a negligible improvement (if an improvement at all). Also, charsmax() should be used instead of sizeof()-1 for readability.

floatman
09-18-2012, 12:11
for( new j = 0; j < sizeof g_Codename - 1; j++ )
->


new iLen = sizeof g_Codename - 1
for( new j = 0; j < iLen; j++ )

Kind of useless improvement...

Will consider all of your ideas for the new version.

AleeKz
09-23-2012, 13:14
[ro]
NEW_CODE = Scrie urmatoarele caractere pentru a primi un premiu in bani:
ANNOUNCE_WINNER = %s a castigat %d$.
RESTRICTION_ADDED = %s a fost adaugat in lista de restrictii.
HAS_RESTRICTION = %s are deja o restrictie pe nume!
RESTRICTION_DELETED = %s a fost sters din lista de restrictii.
CODE_NOTACCESS = Exista o restrictie asupra numelui tau.

For romanian ^^

luki1412
10-22-2012, 09:13
Slovak translation

[sk]
NEW_CODE = Napis nasledujuce znaky a vyhraj cenu (peniaze): %s
ANNOUNCE_WINNER = %s vyhral %d$.
RESTRICTION_ADDED = %s bol pridany do listiny zakazanych.
HAS_RESTRICTION = %s uz je na listine zakazanych!
RESTRICTION_DELETED = %s bol odstraneny z listiny zakazanych.
CODE_NOTACCESS = Si na listine zakazanych.

Erdener
10-22-2012, 13:59
Thnx GJ!, This Turkish translation

[tr]
NEW_CODE = Bir odul kazanmak icin asagidaki karakterleri yazin (para): %s
ANNOUNCE_WINNER = %s %d$ kazandi .
RESTRICTION_ADDED = %s sinirlama listesine eklendi.
HAS_RESTRICTION = %s adi zaten sinirlama listesinde var!
RESTRICTION_DELETED = %s sinirlama listesinden silindi.
CODE_NOTACCESS = Adi uzerinde bir sinirlama var.

Groven
10-22-2012, 15:52
Swedish Transation


[SE]
NEW_CODE = Skriv dom foljande boksteverna for att fo ett pris (pengar): %s
ANNOUNCE_WINNER = %s vann %d$

I made a update so this can work with CashMod (http://forums.alliedmods.net/showthread.php?t=137503&highlight=CashMod).

Edit: Can you make a CVAR to remove the Signs.

Some of them is impossible to remember and how to make them and the message comes every 5 seconds you should add a cvar for that.

floatman
10-31-2012, 12:17
Translations were added. Thanks!
Groven, you want to restrict some of the symbols?
Also, the plugin works just fine. I don't know what do you mean by every 5 seconds.

A new update will be available soon (with major improvements).

Groven
10-31-2012, 20:07
Translations were added. Thanks!
Groven, you want to restrict some of the symbols?
Also, the plugin works just fine. I don't know what do you mean by every 5 seconds.

A new update will be available soon (with major improvements).


What I mean is like remove the sign. Sometimes a word can come with $@8uwdawu[@] it's very hard to type in CS.

TedMan
11-28-2012, 08:23
You can make it to win random money prizes ?

P1raten
12-01-2012, 14:50
You can make it to win random money prizes ?
Find:
new g_Codename[ 20 ];
new g_On = 0;
new g_Time, g_Prize, g_RepTime;

Add this after:
// Added random variable, remove this if you don't want random
new g_Random = true;

Find:
client_print( 0, print_chat, "[EVENT] %L", LANG_PLAYER, "ANNOUNCE_WINNER", szName, get_pcvar_num( g_Prize ) );

cs_set_user_money( i_Index, (cs_get_user_money(i_Index) + get_pcvar_num(g_Prize)) );
g_On = 0;

Add this before:
// If random is true
if (g_Random == true)
{
// The prize will be between 100 and 5000
g_Prize = random_num(100, 5000);
}

I also attached the modified version if you're too lazy.

EDIT: Check the next page for an update on this that is not hardcoded.

quilhos
12-01-2012, 18:18
Find:
new g_Codename[ 20 ];
new g_On = 0;
new g_Time, g_Prize, g_RepTime;

Add this after:
// Added random variable, remove this if you don't want random
new g_Random = true;

Find:
client_print( 0, print_chat, "[EVENT] %L", LANG_PLAYER, "ANNOUNCE_WINNER", szName, get_pcvar_num( g_Prize ) );

cs_set_user_money( i_Index, (cs_get_user_money(i_Index) + get_pcvar_num(g_Prize)) );
g_On = 0;

Add this before:
// If random is true
if (g_Random == true)
{
// The prize will be between 100 and 5000
g_Prize = random_num(100, 5000);
}

I also attached the modified version if you're too lazy.


What's this? What do you did?

P1raten
12-01-2012, 20:59
What's this? What do you did?
Are you asking what I did? Or are you just saying I did something wrong?

If the latter then why not just point out what I did wrong so that I can learn from my mistake?

stiffmast3r
12-01-2012, 21:53
German [de]

NEW_CODE = Schreibe folgenden Buchstaben in den Chat und Gewinne einen Preis (money): %s
ANNOUNCE_WINNER = %s gewann %d$.
RESTRICTION_ADDED = %s wurde zur Blockierliste hinzugefügt.
HAS_RESTRICTION = %s ist bereits Blockiert!
RESTRICTION_DELETED = %s wurde von der Blockierliste entfernt.
CODE_NOTACCESS = Dein Name ist in der Blockerliste.

TedMan
12-03-2012, 08:30
@ P1raten
fastevent.sma(244) : warning 213: tag mismatch

P1raten
12-03-2012, 18:28
@ P1raten
Sorry about that.

Here's a new one.

EDIT: This one is still hardcoded, i just fixed a warning on this one.

quilhos
12-04-2012, 08:57
Sorry about that.

Here's a new one.

Edit your first post, before post a new one xD, maybe people get confused. I'm asking what you did different xb

P1raten
12-04-2012, 09:59
Edit your first post, before post a new one xD, maybe people get confused. I'm asking what you did different xb
You're so clever. :D

What I did was I made a new boolean, and set it to true. Then I check later in the code whether or not it has been set and if it has then I choose a random number between 100 and 5000 which becomes the prize money.

It's hardcoded at the moment.

Lemmi edit some posts and I'll remove the hardcoded part and redirect people to this post.

EDIT: Updated with a new version of the changes I made.

Changes:
The random prize feature is no longer hardcoded.
The above now has a cvar: fevent_rand_prize
Default for the cvar is "1". (Enabled)

TedMan
12-12-2012, 12:35
@P1raten
Your plugin does not work correctly when I write the code my server is crashing...
OS : Windows XP

floatman
01-27-2013, 07:23
You can make it to win random money prizes ?
Good idea. Check the first post.

TedMan
01-30-2013, 06:12
It will be great if this will works for ammo packs too :)
Random AP amont.

floatman
02-10-2013, 09:57
Updated to 3.0:
- major improvement in the code;
- nvault is now required;
- the restriction system is now using steam ids to ban users from participating to the event.

ILUSION
02-13-2013, 12:15
[ES]
NEW_CODE = Tipea los siguientes caracteres para ganar una recompenza (dinero)
ANNOUNCE_WINNER = %s gano %d$
omg Lucas.

[ES]
NEW_CODE = Escribe los siguientes caracteres para ganar un premio (dinero): %s
ANNOUNCE_WINNER = %s gano %d$.
RESTRICTION_ADDED = %s fue agregado a la lista de restringidos.
HAS_RESTRICTION = %s ya tiene una restrinccion con ese nombre!
RESTRICTION_DELETED = %s fue eliminado de la lista de restringidos.
CODE_NOTACCESS = Usted tiene una restriccion con su nombre.

simanovich
02-13-2013, 14:20
Another version of "First Write" (I think only at israeli non-steam's servers it' pupolar...) by Just0ne

floatman
05-12-2013, 02:43
(3.1) You can now handle the holdtime for the hud message by modifying the fastev_hudtime CVAR's value to another float (default: 25.0).

alicx
05-12-2013, 09:17
French translation ;)

[fr]
NEW_CODE = Ecrit le mot suivant pour gagner un cadeau(argent): %s
ANNOUNCE_WINNER = %s a gagner %d$.
RESTRICTION_ADDED = %s a été ajouter à la liste de restriction.
HAS_RESTRICTION = %s a déja une restriction pour son nom!
RESTRICTION_DELETED = %s a été effacer de la liste de restriction.
CODE_NOTACCESS = Tu as une restriction pour ton nom.

ConnorMcLeod
05-12-2013, 09:36
This french is full of mistakes, don't add to lang file please, if i have time, gonna make correct translation.


edit :
[fr]
NEW_CODE = Écris les caractères suivants pour recevoir un prix (argent): %s
ANNOUNCE_WINNER = %s a gagné %d$.
RESTRICTION_ADDED = %s a été ajouté à la liste de restrictions.
HAS_RESTRICTION = %s a déjà une restriction sur son nom!
RESTRICTION_DELETED = %s a été effacé de la liste de restrictions.
CODE_NOTACCESS = Tu as une restriction sur ton nom.

Btw, why you talk about name restriction, when this is steamid that is restricted ?
Also, you could use directly steamid as nvault key, since that vault doesn't contain any other datas.
Last, i think now '%' is usable ;)

Jhob94
05-12-2013, 10:00
Well i didnt tested this plugin/looked at the code so idk if my suggestion is on plugin.
Make it 5 seconds before start type an HUD or print_center/print_chat saying that type event gonna start, i think is better ;)

floatman
05-12-2013, 12:04
Btw, why you talk about name restriction, when this is steamid that is restricted ?
Where did I talk about name restriction? In the changelog maybe, but that was for an older version.

Also, you could use directly steamid as nvault key, since that vault doesn't contain any other datas.
Done.

Last, i think now '%' is usable ;)
I forgot about the update, sorry. Modified.

Well i didnt tested this plugin/looked at the code so idk if my suggestion is on plugin.
Make it 5 seconds before start type an HUD or print_center/print_chat saying that type event gonna start, i think is better ;)
I will consider this in the next version.

ConnorMcLeod
05-13-2013, 00:56
Where did I talk about name restriction?

I guess there for example :
HAS_RESTRICTION = %s has already a restriction on his name


@@ new szMessage[ 192 ];

@@ formatex( szMessage, charsmax( szMessage ), "[EVENT] %L ", LANG_PLAYER, "NEW_CODE", g_Codename );

new Float:holdtime = get_pcvar_float( g_HoldTime );
new Float:repeattime = get_pcvar_float( g_RepTime );

if( holdtime > repeattime )
{
holdtime = repeattime - 5.0;
}

new Float:cleartime = get_pcvar_float( g_Time );
set_task( cleartime, "clear_vars" );

set_hudmessage( 0, 255, 0, 0.07, 0.21, 0, 6.0, holdtime, _, _, -1 );
@@ ShowSyncHudMsg( 0, g_SyncHudMsg, szMessage );

Setting ML this way won't work, i guess it gonna use server lang by default, you can directly format in ShowSyncHudMsg though, and ML gonna work fine in there.


Aboult nvault, i think would be better to use a more specific name, considering "restriction" could be used by another plugin or is not self explaning if someone browse ftp files and delete it, or whatever, but your decision.


I think it would be better to set an index to one of the tasks, i remember JGHG knife duel plugin where there is same situation as in this plugin, a repeat task, then another set task with low time, and the looping message task was then flooded.

floatman
05-31-2013, 06:48
Updated to 3.2 - the code has been improved and a minor bug has been fixed.
I also need the new translations for the ML system. Thanks.

UchihaSkills
05-31-2013, 07:30
German Translation
[de]
NEW_CODE = Gib die folgenden Zeichen ein um einen Preis zu gewinnen (Geld): %s
ANNOUNCE_WINNER = %s gewinnt %d$.
RESTRICTION_ADDED = %s wurde an der Teilnahme des events gebannt!
HAS_RESTRICTION = %s ist bereits an der Teilnahme des events gebannt worden!
RESTRICTION_DELETED = %s wurde aus der Beschränkungs liste gestrichen!
CODE_NOTACCESS = wurde an der Teilnahme des events gebannt!

floatman
08-09-2013, 06:08
The german translation has been added. Thanks.

4ever16
02-24-2017, 04:54
Just dropping a comment.
Nice idea.

Nume2k1
04-27-2017, 16:58
Latvian lang

[lv]
NEW_CODE = Ievadi atbilstošu vārdu lai vinetu balvu (nauda): %s
ANNOUNCE_WINNER = %s ieguva %d$.
RESTRICTION_ADDED = %s tika nobanots, un nevar vairs piedalīties eventā.
HAS_RESTRICTION = %s jau ir banots un nevar piedalīties eventā.
RESTRICTION_DELETED = %s tika unbanots, un var atsākt piedalīšanos eventos.
CODE_NOTACCESS = Tu nevari piedalities, jo esi banots.

Natsheh
05-04-2017, 05:17
This guy is not alive he died in 2013 in a car accident , he left this good work in the memory of his good soul!

simanovich
05-05-2017, 05:04
This guy is not alive he died in 2013 in a car accident , he left this good work in the memory of his good soul!

https://i.imgur.com/jpyR1hh.png

Natsheh
05-05-2017, 14:28
https://i.imgur.com/jpyR1hh.png

he was in a coma for two years, sadly.

TheBeast
08-18-2018, 09:01
I have a problem, event shows up at hud but for 1 sec and dissapear..
my cvars :
g_Time = register_cvar( "fastev_responsetime", "30.0" );
g_Prize = register_cvar( "fastev_moneyprize", "5000" );
g_RepTime = register_cvar( "fastev_repeattime", "120.0" );
g_Random = register_cvar( "fastev_randomamount", "1" );
g_Min = register_cvar( "fastev_randommin", "500" );
g_Max = register_cvar( "fastev_randommax", "5000" );
g_HoldTime = register_cvar( "fastev_hudtime", "35.0" );

edited hud
set_hudmessage( 0, 255, 0, 0.07, 0.92, 0, 6.0, 35.0, _, _, -1 );
ShowSyncHudMsg( 0, g_SyncHudMsg, "[FEVENT] %L", LANG_PLAYER, "NEW_CODE", g_Codename );

Any help?