VegaS 1087 Posted November 21, 2016 Share Posted November 21, 2016 M2 Download Center This is the hidden content, please Sign In or Sign Up ( Internal ) Spoiler Perhaps it will be useful for some people for various systems. Have fun. # onPressKeyDict[app.DIK_F5] = lambda : self.Print() # For test function @root/game.py def Print(self): import app, chat list = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" # Set list maxStr = 10 # Set the maximum number of characters k = "" for v in xrange(maxStr): k = k + list[app.GetRandom(0, len(list) - 1)] chat.AppendChat(chat.CHAT_TYPE_INFO, "Result word: %s" % str(k)) 1 4 Link to comment Share on other sites More sharing options...
Fivercloud 55 Posted November 25, 2016 Share Posted November 25, 2016 +1 Link to comment Share on other sites More sharing options...
Honorable Member Mali 41872 Posted April 2, 2018 Honorable Member Share Posted April 2, 2018 c++ version #include <iostream> #include <ctime> using namespace std; int main() { srand( time( NULL ) ); char list[] = {"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y"}; int maxStr = 10; std::string random_word = ""; for (int i = 0; i < maxStr; ++i) { int randa = rand() % sizeof(list); if (list[randa] == ',') { i--; continue; } random_word += list[randa]; } cout<<random_word; return 0; } Link to comment Share on other sites More sharing options...
Nolwarg 1 Posted April 2, 2018 Share Posted April 2, 2018 1 godzinę temu, Mali61 napisał: c++ version #include <iostream> #include <ctime> using namespace std; int main() { srand( time( NULL ) ); char list[] = {"a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y"}; int maxStr = 10; std::string random_word = ""; for (int i = 0; i < maxStr; ++i) { int randa = rand() % sizeof(list); if (list[randa] == ',') { i--; continue; } random_word += list[randa]; } cout<<random_word; return 0; } for what you used comma in table?? Link to comment Share on other sites More sharing options...
Bot Metin2 Dev 4882 Posted April 2, 2018 Bot Share Posted April 2, 2018 import random, string def Print(maxStr): list = [x for x in string.digits + string.ascii_letters] k = "" for v in range(0, maxStr): k += list[random.randint(0, len(list) - 1)] print("Result word: %s" % str(k)) Print(10) For Python3 + anyone, who wants to use it in an extern program. Nice idea, not that bad tbh. ^^ King Regards Cyber Link to comment Share on other sites More sharing options...
Honorable Member Mali 41872 Posted April 2, 2018 Honorable Member Share Posted April 2, 2018 24 minutes ago, Nolwarg said: for what you used comma in table?? For layout, you can delete commas Link to comment Share on other sites More sharing options...
Nolwarg 1 Posted April 2, 2018 Share Posted April 2, 2018 33 minuty temu, Mali61 napisał: For layout, you can delete commas I know lols xD this is better in my opinion: Link to comment Share on other sites More sharing options...
Recommended Posts