Raised This Month: $ Target: $400
 0% 

Create file whit random num (1-100)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
BloodyNuker
Member
Join Date: Jan 2006
Old 05-22-2006 , 10:19   Create file whit random num (1-100)
Reply With Quote #1

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
BloodyNuker is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-22-2006 , 10:25  
Reply With Quote #2

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 )
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
BloodyNuker
Member
Join Date: Jan 2006
Old 05-22-2006 , 11:38  
Reply With Quote #3

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
BloodyNuker is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-22-2006 , 12:28  
Reply With Quote #4

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))
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
BloodyNuker
Member
Join Date: Jan 2006
Old 05-22-2006 , 14:43  
Reply With Quote #5

jajajja itīs very funny

Tnkz! work perfect ++
BloodyNuker is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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