AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Create file whit random num (1-100) (https://forums.alliedmods.net/showthread.php?t=28773)

BloodyNuker 05-22-2006 10:19

Create file whit random num (1-100)
 
Hello, i need create a file and the name must are a random number
(I found to put random number but i need espesificate in caseīs the result to create this number, and i must make 100 caseīs... Donīt exist other metod ?)
I put this... but donīt right
Code:

new numero = random_num(0, 100)
formatex( text, 255, "addons/amxmodx/123/%s.txt", numero);
write_file( text , numero , -1 );

Tnkz

Hawk552 05-22-2006 10:25

You should use the new file natives, and also are you sure there's a directory "123" ?

Code:
    new text[256], file[64]     new numero = random_num(0, 100)     formatex( file, 63, "addons/amxmodx/123/%d.txt", numero)     formatex( text, 255, "my text should go here. For future reference, the numero is: %d", numero)     write_file( file , text )

BloodyNuker 05-22-2006 11:38

Oks, tnkz, and i have got other cuestion if you can help plz.

(I need kick a player, but if the player write in console "amx_123 Hello", the plugin donīt kick the player)

When a player enter in the server the plugin ...
Code:

register_clcmd("amx_123", "cmdChat")

///////////////////////////////////

public client_putinserver(id)
{
set_task(20.0, "client_1", id, "b")
}

If the player write in console "Hello", after 20 seconds the plugin create a file whit a random number

Code:

public cmdChat(id,level,cid)
{
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED

new message[192]
read_args(message,191)

remove_quotes(message);

new message2[256]
copy(message2 , 255 , "Hello");
if(equali(message,message2))
{
new text[256], file[64]
new numero = random_num(0, 100)
formatex( file, 63, "addons/amxmodx/123/%d.txt", numero)
formatex( text, 255, "my text should go here. For future reference, the numero is: %d", numero)
write_file( file , text )
}
return PLUGIN_HANDLED
}

This work i think, but this not, show this...

20 seconds later, when player entered in game the plugin show if the file exist....(because if the file exist, is because the player put amx_123 Hello)

Code:

public client_verificacion3(id)
{
if( !is_user_connected(id) ) { return PLUGIN_HANDLED; }
new name[32];
get_user_name( id , name , 31 );
if(file_exists( file ))
{
}
else
{
client_cmd(id,"disconnect")
}
return PLUGIN_CONTINUE
}

I make this, but i think there are other method to kick a player if this donīt say in console amx_123 Hello
no? :?

Tnkz and sorry if this a stupid question :D

Hawk552 05-22-2006 12:28

Umm... thats a really bad method. Try this:

Code:
#include <amxmodx> #include <amxmisc> new bool:g_bSaidHello[33] public plugin_init() {     register_plugin("Hello","1.0","Hawk552")         register_clcmd("say","fnHookSay") } public client_disconnect(id)     g_bSaidHello[id] = false     public client_putinserver(id)     set_task(20.0,"fnCheckHello",id)     public fnHookSay(id) {     new szArgs[128]     read_args(szArgs,127)         if(containi(szArgs,"hi") != -1 || containi(szArgs,"hello") != -1)         g_bSaidHello[id] = true } public fnCheckHello(id)     if(!g_bSaidHello[id])         server_cmd("kick #%d ^"You must say hello.^"",get_user_userid(id))

BloodyNuker 05-22-2006 14:43

jajajja itīs very funny :P

Tnkz! work perfect :D ++ :!:


All times are GMT -4. The time now is 16:18.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.