Raised This Month: $ Target: $400
 0% 

Reading random line.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 10-05-2006 , 13:10   Reading random line.
Reply With Quote #1

If i f.e have these four lines:

---
Haha you died!
KABOOM!
HE powa?
Do not mess with explosives...
---

What should i do if i want a random line to appear when someone is killed by a HE.... - How the event works. I just dont know how to take a random line.
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-05-2006 , 14:34   Re: Reading random line.
Reply With Quote #2

Code:
switch(random_num(0,3)) {     case 0:     {         client_print(dead_player_id,print_chat,"Haha you died!")     }     case 1:     {         client_print(dead_player_id,print_chat,"KABOOM!")     }     case 2:     {         client_print(dead_player_id,print_chat,"HE powa?")     }     case 3:     {         client_print(dead_player_id,print_chat,"Do not mess with explosives...")     } }
__________________
EAT YOUR VEGGIES
Silencer123 is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 10-05-2006 , 14:50   Re: Reading random line.
Reply With Quote #3

A better way to do this.
Code:
new const Cows[4][] = {     "Haha you died!",     "KABOOM!",     "HE powa?",     "Do not mess with explosives..." } function_what() {     client_print(dead_player_id, print_chat, "%s", Cows[random(0, 3)]) }

If you were trying to read those 4 lines off of a file and store it into the plugin. There alot of tutorials or people that got help with how to read files in the scripting section.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 10-05-2006 , 15:38   Re: Reading random line.
Reply With Quote #4

Do you mean a random line from a file? That can be done with the following.

Code:
new szLine[256],txtlen; read_file("filename.ext" , random_num(0 , file_size("filename.ext",1)) , szLine , 255 , txtlen);
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 10-05-2006 , 16:39   Re: Reading random line.
Reply With Quote #5

No..

teame06:

Why is it random(0,3) - When there's 4 in the "const"

Last edited by stigma; 10-05-2006 at 16:46.
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-05-2006 , 16:48   Re: Reading random line.
Reply With Quote #6

Quote:
Originally Posted by stigma View Post
Why is it random(0,3) - When there's 4 in the "const"
Because array indexes start at 0. So if you have 4 elements in an array, valid indexes are: 0, 1, 2, and 3. If you used random_num(0,4) and 4 came up, it would be out of bounds, because you are trying to reference the 5th element which doesn't exist.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 10-05-2006 , 16:55   Re: Reading random line.
Reply With Quote #7

Okay thanks..
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 10-05-2006 , 16:56   Re: Reading random line.
Reply With Quote #8

This isent a part of the topic..

But do you know how to get the TEAM's score?
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
Silencer123
Veteran Member
Join Date: Jul 2006
Old 10-05-2006 , 17:05   Re: Reading random line.
Reply With Quote #9

Register every time when a Team wins and add 1 to a specific variable.
Use the Search to find what logevents to use. And dont forget to set back to 0 when Game Commencing.
__________________
EAT YOUR VEGGIES
Silencer123 is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 10-05-2006 , 22:57   Re: Reading random line.
Reply With Quote #10

You can register the TeamScore message and remember what its values are in your own variables.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 04:56.


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