rEf 53 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 (upraveno) Zdravím dám vám sem jeden menší script který funguje na principu že se vypíše do chatu: [ Text ] Kdo jako první napíše náhodný text '' SAFRWERSDG '' získá náhodnou částku. Následně pokud jako první napíšete text vypíše se do chatu: [ Text ] Jako první napsal náhodný text '' SAFRWERSDG '' hráč rEf a získal $20.000. Předem upozorňuji případné inteligenty že ano mohl jsem udělat určité věci jinak, mohl jsem použít třeba YSI a podobné hovadiny ale já to dělal prakticky bez použití ničeho až na stock PlayerName. A teď samotný script: #include <a_samp> new RandText[10]; //samotný text má 10 písmen max můžete si přidat/měnit potom ale nezapomente zmenit aj cisla new LetterList[26][] = { "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" }; // seznam písmen new RText=0; forward RandomText(); //forward pro publick RandomText public OnFilterScriptInit(){ SetTimer("RandomText", 5*60000, true); //timer return true; } public RandomText(){ new string[30], str[256]; format(string, sizeof(string), "%s%s%s%s%s%s%s%s%s%s" , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]); // 10 random písmen RandText = string; //uloží písmena na RandText RText=1; format(str, sizeof(str), "[ {C2A2DA}Text{FFFFFF} ] Kdo jako první napíše náhodný text '' %s '' získá náhodnou částku.",RandText); SendClientMessageToAll(-1,str); //vypíše zprávu pro všechny hráče return true; } public OnFilterScriptExit(){ return true; } public OnPlayerText(playerid, text[]){ new string[256]; new cash = random(50000); //náhodný cash od 0 do 50 000 je lepší použít RandomEx (najdete na samp foru) a nastavit si třeba od 5000 do 1500 if(RText == 1){ //pokud je RaText na 1 bude to reagovat if(!strcmp(text, RandText, true)){ //zjistí jestli někdo napsal ten text format(string, sizeof(string), "[ {C2A2DA}Text{FFFFFF} ] Jako první napsal náhodný text '' %s '' hráč %s a získal {33AA33}$%d{FFFFFF}.",RandText,PlayerName(playerid),cash); SendClientMessageToAll(-1,string); //vypíše zprávu pro všechny hráče GivePlayerMoney(playerid, cash); //dá tomu co napsal jako první cash RText=0; } } return true; } stock PlayerName(playerid){ //klasickej stock PlayerName new pname[MAX_PLAYER_NAME]; GetPlayerName(playerid, pname, MAX_PLAYER_NAME); return pname; } For můžete nahradit třeba ForPlayers a další další blbosti... Celý to funguje na principu že to vybere náhodně 10 písmen které dá se říct uloží na RandText a nastaví RaText na 1. Potom když napíšete správně těch 10 písmen tak vám to dá peníze a nastaví RaText na 0. Nevím co víc k tomu říct... Jestli se to někomu nelíbí je mi to jedno, kdo to ocení nějak i kdyby si to upravoval budu rád. Edited 9. Srpen, 2015 by rEf 1 Link to comment Share on other sites More sharing options...
Mikoo 8 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 Pekne Link to comment Share on other sites More sharing options...
Hlavní moderátor vEnd 279 Odesláno: 15. Červen, 2015 Hlavní moderátor Share Odesláno: 15. Červen, 2015 kdybys ta jednotlivá písmena použil jako znaky ('A', 'B' a pak %c%c atd.), nemusel bys mít LetterList jako 2D pole... neber to ani tak jako výtku, jako spíš možnost ušetřit trochu paměti btw, nepřehánějte to s tím YSI, taky to nemusí být v každém 50řádkovém scriptu Link to comment Share on other sites More sharing options...
TheRohlikar 21 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 Good job ! Jen... format(string, sizeof(string), "%s%s%s%s%s%s%s%s%s%s" , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]); Nebylo by lepší to hodit do "strcat" ? Link to comment Share on other sites More sharing options...
arci224 11 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 (upraveno) kdybych hodnotil tak 9/10 + Pěkné + Přehledné + Snaha - CTRL + C Mohl si to trochu dát aby to nebylo CTRL + C jelikož, to není tak dlouhé. A je to jen na random. Edited 15. Červen, 2015 by arci224 Link to comment Share on other sites More sharing options...
TheRohlikar 21 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 JSi feťák ? Není to TUT, je to script. Takže pokud chce, tak ho zveřejnit může. A hádám, že mu nějaká CTRLská lama nemířila zbraní na hlavu, aby to sem hodil. 1 Link to comment Share on other sites More sharing options...
arci224 11 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 JSi feťák ? Není to TUT, je to script. Takže pokud chce, tak ho zveřejnit může. A hádám, že mu nějaká CTRLská lama nemířila zbraní na hlavu, aby to sem hodil. Nejsem, a vím že to je script.. ale přece jenom .. je to CTRL + C... Link to comment Share on other sites More sharing options...
Tedy 8 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 Nejsem, a vím že to je script.. ale přece jenom .. je to CTRL + C... A to jsi vzal prosím tě kde? K scriptu - pěkně udělané, a hlavně se s tím dá ještě pracovat ( přidat do číslice... ) 9,5 / 10 Link to comment Share on other sites More sharing options...
Administrátor Ewwe 434 Odesláno: 15. Červen, 2015 Administrátor Share Odesláno: 15. Červen, 2015 (upraveno) Strašně nadšenej bude ten co vyhraje 0$ BTW je strašně užasně skvělý jak cpeš 30 znaků do 10 znaků ... Tten pvar tam má taky smyslu jak brejle pro mrtvýho Edited 15. Červen, 2015 by Ewwe Link to comment Share on other sites More sharing options...
Tedy 8 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 Strašně nadšenej bude ten co vyhraje 0$ BTW je strašně užasně skvělý jak cpeš 30 znaků do 10 znaků ... Tten pvar tam má taky smyslu jak brejle pro mrtvýho Však i kdyby vyhrál 0 $ ... Je to realita, ne? Link to comment Share on other sites More sharing options...
Lax. 28 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 (upraveno) Nejsem, a vím že to je script.. ale přece jenom .. je to CTRL + C... Keď si si nevšimol - "PAWN - Scripty", takú ... napíšeš dokonca 2x, no konec.. :rofl: Edited 15. Červen, 2015 by Lax. Link to comment Share on other sites More sharing options...
Mikoo 8 Odesláno: 15. Červen, 2015 Share Odesláno: 15. Červen, 2015 Hadže mi to error: RandText = string; //uloží písmena na RandText Link to comment Share on other sites More sharing options...
Baseball 2 Odesláno: 16. Červen, 2015 Share Odesláno: 16. Červen, 2015 Dej tam místo new string[30], str[256]; new string[10], str[256];. Je tam jen 10 písmen Link to comment Share on other sites More sharing options...
Hlavní moderátor vEnd 279 Odesláno: 16. Červen, 2015 Hlavní moderátor Share Odesláno: 16. Červen, 2015 Dej tam místo new string[30], str[256]; new string[10], str[256];. Je tam jen 10 písmen když mu chceš poradit, tak alespoň správně, velikost musí být 11 (EOS) Link to comment Share on other sites More sharing options...
TheRohlikar 21 Odesláno: 16. Červen, 2015 Share Odesláno: 16. Červen, 2015 Good job ! Jen... format(string, sizeof(string), "%s%s%s%s%s%s%s%s%s%s" , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))] , LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]); Nebylo by lepší to hodit do "strcat" ? Může prosím někdo odpovědět ? Díík. Link to comment Share on other sites More sharing options...
Administrátor Ewwe 434 Odesláno: 16. Červen, 2015 Administrátor Share Odesláno: 16. Červen, 2015 Dej tam místo new string[30], str[256]; new string[10], str[256];. Je tam jen 10 písmen Jo 2O zbytečnejch znaků je větší zátěž než 11O zbytečnejch znaků... Link to comment Share on other sites More sharing options...
rEf 53 Odesláno: 19. Červen, 2015 Author Share Odesláno: 19. Červen, 2015 (upraveno) Když jsem to dělal nějaký stringy jsem neřešil prostě mě to chytlo a musel sem to za každou cenu zrealizovat nějakou optimalizaci si může udělat člověk sám v případě že umí počítat a podobně. Samozřejmě to lze vytvořit i mnohem jednodušeji no. Edited 19. Červen, 2015 by rEf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now