Raised This Month: $ Target: $400
 0% 

Assigning variables to cvars


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 05-26-2005 , 05:25   Assigning variables to cvars
Reply With Quote #1

im trying to write a war pluging for cs, iv got most of it working except i wanted to create a random password to secure the server.

what i need to know if its even possible, can you take a bunch of random numbers from a variable and assign it to the cvar sv_password ?

heres what i got so far

Code:
public password_generator() {     new password         password = random_num( 0,5 )     server_cmd("sv_password",password )         return PLUGIN_HANDLED }

thanks
Anthraxnz is offline
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 05-26-2005 , 09:46  
Reply With Quote #2

maybe:
Code:
    server_cmd("sv_password %s",password )
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
Basic-Master
Veteran Member
Join Date: Apr 2005
Location: hello pm
Old 05-26-2005 , 10:02   Re: Assigning variables to cvars
Reply With Quote #3

Code:
public password_generator() {     new password[2] // this is a string with 2 slots         num_to_str(random_num( 0,5 ), password, 1) // assign random value to string     set_cvar_string("sv_password", password) // set cvar         return PLUGIN_HANDLED }
Basic-Master is offline
Send a message via ICQ to Basic-Master Send a message via MSN to Basic-Master
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 05-26-2005 , 10:50  
Reply With Quote #4

thanks will give that a try
Anthraxnz is offline
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 05-26-2005 , 11:09  
Reply With Quote #5

thanks that works fine, but does any one have any ideas on how to fill the array with say 5 random numers?

i tried to use a while loop and feed it into the array that way, but it didnt work

was something like this
Code:
new i while ( password[i] != 5 ) {     num_to_str(random_num( 0,9 ), password[ i ], 1)         i++ } set_cvar_string("sv_password", password)
Anthraxnz is offline
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 05-26-2005 , 11:31  
Reply With Quote #6

hevt you set pasword to 5 arrays?
new password[4]

and why have password in the while, try to use ( i <= 5 )
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 05-26-2005 , 11:33  
Reply With Quote #7

i got this so far
Code:
public password_generator() {     new password[5]         num_to_str(random_num( 0,9 ), password, 5)     set_cvar_string("sv_password", password)         client_print(0, print_chat, "Server Password is: %s",password)     client_print(0, print_chat, "Server Password is: %s",password)     client_print(0, print_chat, "Server Password is: %s",password)     client_print(0, print_chat, "Server Password is: %s",password)     client_print(0, print_chat, "Server Password is: %s",password)          return PLUGIN_HANDLED   }

this works fine but its only puts one integer into the variable password.
Any ideas?
Anthraxnz is offline
Anthraxnz
Senior Member
Join Date: May 2005
Location: New Zealand
Old 05-26-2005 , 22:40  
Reply With Quote #8

never mind i did a more basic way, just assigned 1 random number to each space in the array by putting that random number code 5 times
Code:
    new password[6]             num_to_str(random_num( 0,9 ), password[0], 1)     num_to_str(random_num( 0,9 ), password[1], 1)     num_to_str(random_num( 0,9 ), password[2], 1)     num_to_str(random_num( 0,9 ), password[3], 1)     num_to_str(random_num( 0,9 ), password[4], 1)
Anthraxnz is offline
Basic-Master
Veteran Member
Join Date: Apr 2005
Location: hello pm
Old 05-27-2005 , 04:58  
Reply With Quote #9

this works well, too:
Code:
new password[6] // 5 chars num_to_str(random_num(10000,99999), password, 5) set_cvar_string("sv_password", password) client_print(0, print_chat, "Server password is now: %s", password)
Basic-Master is offline
Send a message via ICQ to Basic-Master Send a message via MSN to Basic-Master
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:36.


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