Replacing code with random number - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Replacing code with random number (
/showthread.php?tid=614704)
Replacing code with random number -
ax1 - 11.08.2016
I have a few thousands of lines with this code :
Код:
0.00,-1, -1, -1,200);
Can I somehow automaticly (maybe with notepad++) replace 0.00 with random number for all the lines? It would take ages to do it myself
Re: Replacing code with random number -
Luicy. - 11.08.2016
CTRL + H
Paste in 0.00,-1, -1, -1,200); at top,
at bottom,
random(1)/*0 or 1*/,-1, -1, -1,200);
Re: Replacing code with random number -
Misiur - 11.08.2016
Quote:
The range of values (from 0 to this value minus one) that can be returned.
|
random(1) will always return 0, random(2) will return 0 or 1. Also OP wants compile time random values, not runtime ones. Sorry, I only know how to write a plugin for sublime, I don't know if notepad++ supports such thing
Re: Replacing code with random number -
Vince - 11.08.2016
You're probably going to need a little script to do it. I don't see any feasible way to do it by hand, not even with regex. I would probably replace all those 0.00 values with %.2f and copy those lines to a file in the scriptfiles folder. Then create a little script that reads from that file, one line at a time. Use the line as the string input for format() and then put a random number in. Write the output to another file. Then you can finally copy that output back into the script.
Re: Replacing code with random number -
SickAttack - 11.08.2016
Just use the replace feature? As they are the same.