mIRC Home    About    Download    Register    News    Help

Print Thread
ok, hard to think a topic:P #98052 20/09/04 12:09 PM
Joined: Apr 2003
Posts: 42
E
eendje Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Apr 2003
Posts: 42
I got a script which saves things in hash tabkles, detailed explanation isnt neccesarry, but I want my script to check if someone types !abc, get $1 from item xxx in hastable zzz. make that a variable, set %lvl $hget(xxx,$nick)

Then do a check with this script:

Code:
alias showfarms {

  .remove stats.tmp  
  var %number = $gettok($hget(darkhash,$$1),2,32), %nick = $1
  var %a = 1
  while $hget(darkfarm,%a).data {
    tokenize 32 $v1
    if $2 < %number { write stats.tmp You can farm $hget(darkfarm,%a).item he/she is level $1 and has a Defense of $2 - This farm has been submitted by $3 on $4 }
    inc %a
  }
  filter -fftc 7 32 stats.tmp stats.tmp *
  if !$filtered { .msg %nick Im sorry, no farms found for you. }
  else { .play %nick stats.tmp 1500 }
}


but also check the lvl from the 'farm' if its in a 5 lvl range from var %lvl (so if %lvl = 54 it check 49-59)


---
signatures own
Re: ok, hard to think a topic:P #98053 20/09/04 01:09 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Try to explain to your best abilities.

The way the script was set up, it would message someone all the people with a lower defense to the person who typed !getfarm.

First question: do you still want that?

Second question: You want to see the defenses of the people with a level that are in the range: your level -+ 5. How do you want that organized?

I mean what do you want: to see all the defense below your defense, or to see the defenses of people with level +- 5 your level.

It's 2 different kind of informations that do not go along.

I still think you should make some easier scripts first, because I'm afraid it's still a bit too complex.

Greets

Last edited by FiberOPtics; 20/09/04 02:16 PM.

Gone.
Re: ok, hard to think a topic:P #98054 20/09/04 03:41 PM
Joined: Apr 2003
Posts: 42
E
eendje Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Apr 2003
Posts: 42
you said what I want:P I want people withint 5 lvls range of my lvl defenses shown if the have a lower defense them me, its just 1 more if command I suppose. but noone can tell me how to make a a thing checking a 5 number difference, (they say $rand but then I need to specify myself and thats not what I want)


---
signatures own
Re: ok, hard to think a topic:P #98055 20/09/04 03:42 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
This code will do the following:

It will output to the user, the information of other players, with these restrictions:

1) Their defense is lower than that of the requester

AND

2) Their level is in a range of: [level - 5 ; level + 5] of the requester

Those two conditions have to be met, in order for the script to show them.

Code:
 
alias showfarms {
  var %nick = $1
  tokenize 32 $hget(darkhash,$1)
  var %defense = $2, %range = $+($calc($1 -5),-,$calc($1 +5)), %a = 1
  .fopen -o farms farms.tmp
  while $hget(darkhash,%a).data {
    tokenize 32 $v1
    if $2 < %defense && $1 isnum %range { .fwrite -n farms $hget(darkhash,%a).item $1- }
    inc %a
  }
  .fclose farms
  filter -fftc 3 32 farms.tmp farms.tmp *
  if $filtered { .play -a playfarms %nick farms.tmp 1500 }
  else { .msg %nick Im sorry, no farms found for you. }
}
 [color:red]  [/color] 
alias playfarms {
  .msg $1 You can farm $2 he/she is level $3 and has a Defense of $4 - This farm has been submitted by $5 on $6
}

A tip for the future: Try to elaborate as much as you can on what you would like. Try using real examples, and try to illustrate your wishes in a clear way.

This will be the last thing I make for you regarding this script, because it is your bot, you are the scripter, and it should be you who scripts it. Sounds logical. grin

Greets


Gone.
Re: ok, hard to think a topic:P #98056 20/09/04 04:30 PM
Joined: Apr 2003
Posts: 42
E
eendje Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Apr 2003
Posts: 42
ok thanks, you sya start on easier things heh. but dont know what to do:P ithis is something i needed, and nothing else. anyway thanks a lot;)


---
signatures own
Re: ok, hard to think a topic:P #98057 20/09/04 05:04 PM
Joined: Apr 2003
Posts: 42
E
eendje Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Apr 2003
Posts: 42
its not working,

2 things

1) It should get farms from hashtable 'darkfarm' and nicks from 'darkhash', So i changed thse 2 lines:

while $hget(darkfarm,%a).data {
if $2 < %defense && $1 isnum %range { .fwrite -n farms $hget(darkfarm,%a).item $1- }

from darkhash to darkfarm ( I think the first one is get data from $nick and both 2nd ones getting the farm)

Also I changed:

if $hget(darkhash, $nick) { showfarms $nick }

put a space between *(darkhash, $nick)* (between , and $:P)

cause it said 'you dont exist to everyone' and now they do exist.

Now when I first tried it it said "no farms found for you"

When I added several farms it still says that.

This is in my darkfarm hash":

Someone -> 56 50000 |SwE|Tjirp 20/09/2004
pian -> 54 1500000 PiaNistu 20/09/2004
pia -> 59 2500000 PiaNistu 20/09/2004
15 -> 15 15 |SwE|Tjirp 20/09/2004
tjirpi -> 10 1000 PiaNistu 20/09/2004
Tjirp -> 56 500000 |SwE|Tjirp 20/09/2004

and with this user from 'darkhash' im looking it up:

Tjirp -> 56 2000000

So it seems obvious to me it should show farms, but it does not. Ive been looking but coudnt find anything. this is now my total code btw;

Code:
on *:TEXT:!getfarm:#:{
  if $hget(darkhash, $nick) { showfarms $nick }
  else { msg $nick You dont exist, Please register by downloading Tjirps farm script }
}

alias showfarms {
  var %nick = $1
  tokenize 32 $hget(darkhash,$1)
  var %defense = $2, %range = $+($calc($1 -5),-,$calc($1 +5)), %a = 1
  .fopen -o farms farms.tmp
  while $hget(darkfarm,%a).data {
    tokenize 32 $v1
    if $2 &lt; %defense &amp;&amp; $1 isnum %range { .fwrite -n farms $hget(darkfarm,%a).item $1- }
    inc %a 
  }
  .fclose farms  filter -fftc 3 32 farms.tmp farms.tmp *
  if $filtered { .play -a playfarms %nick farms.tmp 1500 }
  else { .msg %nick Im sorry, no farms found for you. }
}

alias playfarms {
  .msg $1 You can farm $2 he/she is level $3 and has a Defense of $4 - This farm has been submitted by $5 on $6
}


---
signatures own
Re: ok, hard to think a topic:P #98058 20/09/04 05:48 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
No no no...

Why would you use 2 hash tables just to store nicks with their scores...

This isn't making any sense.

Btw, there's absolutely no space needed after a comma in identifiers like $hget(one,two) is just fine.

Look, that script is working perfect, I have tested it. Your script is fine with 1 hash table, if you are using 2 hash tables for something as simplistic as this, then you don't know what hash tables are for.

Anyway, as I said, someone else will have to script it for you, or yourself.

I gave you a working solution, do with it whatever you please :tongue:

I'm sorry if I sound rude, but it's kinda frustrating when you spend time making someone else a perfectly working script, and then they make changes to it and say it doesn't work.

Bye!


Gone.
Re: ok, hard to think a topic:P #98059 20/09/04 05:52 PM
Joined: Apr 2003
Posts: 42
E
eendje Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Apr 2003
Posts: 42
I use 2 for when someone registers himself in one, but he also gets added. his stats get changed so it isnt correct no more.

EDIT: I first tried it, but offcourse it didnt work cause farms aint listed in darkhash but in darkfarm

Last edited by eendje; 20/09/04 05:57 PM.

---
signatures own
Re: ok, hard to think a topic:P #98060 20/09/04 06:01 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
You can also do that with 1 hash table, but it takes some willingness and time to invest, to know that.

Please check out that hash table tutorial i gave you in that other thread

You'll never get better at scripting, if you don't want to spend time learning and trying things out.
So do as I did: read some hash table tutorials, experience, and after a while, you won't even need help making things.
In fact, you'll become the one helping others grin

Or wait for someone else to help you with your script, I did my part.

Tot ziens eendje, het is niks persoonlijks hoor, maar je moet eerst leren wandelen, alvorens te kunnen lopen.

Daag!


Gone.
Re: ok, hard to think a topic:P #98061 20/09/04 06:16 PM
Joined: Apr 2003
Posts: 42
E
eendje Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Apr 2003
Posts: 42
ik wil best leren maar weet niet waar te beginnen. alle tutorial basics ken ik al uit me hoofd, wat is de stap die je daarna moet nemen dan. blijkbaar niet hashtables want die gebruikt veel while loops (moet ook nog leren:P) maar kan geen goeie tuts vinden.

en er is niks waarom ik het zou willeen, alleen dit script is alles wat me nu nog bezig houd.


---
signatures own
Re: ok, hard to think a topic:P #98062 20/09/04 06:28 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Ja, ik versta dat allemaal wel best, maar de basics kennen betekent niet dat je goed overweg kunt met hash tables zelf.

Bijvoorbeeld: het is niet omdat je de command /hadd, $hget, /hsave, etc. kent, dat je daarom ook goed overweg kunt met hash tables.

Een van de belangrijkste dingen om iets te leren zijn praktische voorbeelden.
Je kunt niet zomaar een programma ontwerpen als je de bouwstenen kent, maar zonder te weten hoe de bouwstenen in elkaar passen.

Om het met een voorbeeldje te geven: Je kunt geen huis bouwen, zelfs al heb je al het nodige materiaal. Je moet ook goed weten hoe een huis gesconstrueerd moet worden, alvorens het materiaal te gebruiken om tot je doel te komen. Snap je de analogie met je eigen script?

Kijk het is niet dat ik je niet wil helpen, dat zie je ook, maar ik heb ook eerst moeten experimenteren met vanallles. Ik ben nu bvb. begonnen met C++ te leren, een moeilijke programmeertaal. Ik ga nu ook nie direct proberen een programma als mIRC na te bouwen of zo, simpelweg omdat ik er nog de ervaring niet voor heb, zelfs al weet ik al een beetje hoe het zou moeten.

En dan nog het laatste belangrijke is: iets dat ik al vermeld had, is dat je heel uitvoerig moet uitleggen hoe je script in elkaar zit, wat je precies wil, en illustreren met voorbeelden. Bvb. het is pas nu dat je me zegt dat je 2 hash tables gebruikt, terwijl het script die ik je heb gegeven in die andere thread maar 1 gebruikt. Vind je dat geen belangrijke informatie die je me eerst zou moeten hebben gegeven? Dat moeten mensen toch weten, hoe kunnen ze je anders op de beste manier helpen?

Maar goed, dit is allemaal mijn mening, en dat hoeft niet noodzakelijk jouw mening te zijn natuurlijk. Maar je merkt toch zelf dat je nog niet goed genoeg bent om zoiets te maken? Ik bedoel maar, bvb om die range van levels te maken. Dat is bvb. iets heel simpels, maar als je dat nog niet weet is dat toch een teken? En while loops zijn bijna onmisbaar, die moet je zeker eerst leren vooraleer je iets deftig kunt maken. Je ziet dat ik while ook vaak gebruik hé, en nog vele andere commands.

'k Wil je wel een paar tips geven: wat ik heel veel heb gedaan (en trouwens nog altijd) is altijd de Search functie gebruiken, om te lezen over zaken die ik nog niet goed snap.

Ook ga ik vaak google gebruiken daarvoor, en bvb ook de Tutorials sectie van de website mircscripts.org.

Nog even terzijde: als je vindt dat je al genoeg van hash tables kent, dan moet je dat es testen. Maak bijvoorbeeld eens een klein acronym scriptje, of een "welcome back" scriptje enzo. Ik durf wedden dat je nog niet hebt gewerkt met /hsave -i, en dat je nog niet weet welke bij-effecten daar aan hangen, die kunnen leiden tot verkeerde resultaten.

Nou, als je wilt zoek ik je wel ff een paar goeie tutorials (als die al bestaan, hehe grin).

Groetjes!

Last edited by FiberOPtics; 20/09/04 06:31 PM.

Gone.
Re: ok, hard to think a topic:P #98063 20/09/04 06:35 PM
Joined: Apr 2003
Posts: 42
E
eendje Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Apr 2003
Posts: 42
laat ik het zo zeggen:

Alles wat ik ken is:

Variables, events en if-then-else.

de rest ben ik niet toe gekomen omdat ik er nog nooit wat mee gedaan heb willen doen. nu met deze kom ik hash tables, while loops tegen en zo. mja is wat moeilijker maar snap er nu wel iets meer van. ook die scripts die je me geef snap ik 50%, alleen dat filter geshit en zo is nog wel een beetje moeilijk:P heb ook nog nooit met inis gewerkt.

en voorbeelden vinden.. hmm ik heb gezogt naar hash tables, maar kon ze niet vinden. niet in voorbeelden die ik snap.

maar ieder geval bedankt voor je hulp. en ik probeer altijd weer te leren:).


---
signatures own
Re: ok, hard to think a topic:P #98064 20/09/04 07:06 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Oh yeah, before I forget, the /help file is also a great resource to learn mirc scripting.

For example, check /help while loops. And then try to make the following 3 scripts:

1) Simple script: echo on your screen the ascii characters 1-255. Tip: $chr(number). So I want a loop that echos for each line: character + according number.

2) Little bit harder: make a script that shows the following on your screen:

1
12
123
1234
12345
123456
1234567
12345678
123456789
12345678910

Tip: 2 while loops nested

3) Make a script that will put an input text reverse. Example: "one two three" becomes" three two one"

Try to make those 3 and pm me the results. Btw I'm pretty sure no one is interested in seeing this, so we better take our convo into private messages.

Good luck!


Gone.
Re: ok, hard to think a topic:P #98065 21/09/04 12:00 PM
Joined: Aug 2004
Posts: 101
D
dr_Eamer Offline
Vogon poet
Offline
Vogon poet
D
Joined: Aug 2004
Posts: 101
Quote:
Tip: 2 while loops nested

Just wondering why... One is enough! :tongue:

Anyway......


Maybe I wake up one day to notice that all my life was just a dream!
Re: ok, hard to think a topic:P #98066 21/09/04 01:59 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Yeah that's true.

Often I don't even use while loops where others would. But that's not really the point.

I just wanted him to do something with nested loops, the examples are actually irrelevant.

Anyway, with a single loop it would be something like:

alias loopit {
var %a = 1, %b
while %a < 11 {
%b = %b $+ %a
echo -a %b
inc %a
}
}

But as stated, I want him to do the nested one :tongue:

Greets

Last edited by FiberOPtics; 21/09/04 02:06 PM.

Gone.
Re: ok, hard to think a topic:P #98067 21/09/04 09:12 PM
Joined: Aug 2004
Posts: 101
D
dr_Eamer Offline
Vogon poet
Offline
Vogon poet
D
Joined: Aug 2004
Posts: 101
Be cool! cool


Maybe I wake up one day to notice that all my life was just a dream!
Re: ok, hard to think a topic:P #98068 22/09/04 12:03 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe.

We've been meeting on IRC the last few days, and I've been teaching him mIRC Scripting (as you could see, he only knew events, variables and if-then-else).

He's a real fast learner. Soon he'll be helping me with scripting lol.

Greets


Gone.