mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jun 2014
Posts: 6
R
raggie Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2014
Posts: 6
I wrote a profile script so visitors to my channel can make profiles for others to view. So far, a visitor can make a profile, edit it if need be, and view their own profile. The problem is, if someone tries to view another person's profile, it only shows the profile of the person typing !view <nick>. I don't know how to make it so others can call up another person's profile using !view <nick>

Can someone help me please?

Last edited by raggie; 22/06/14 04:02 PM.
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
What informations you want to display when someone types !view <nick> ?

Also please paste the code that you have to understand the way that you have script it to help you better.

Last edited by westor; 22/06/14 04:44 PM.

Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jun 2014
Posts: 6
R
raggie Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2014
Posts: 6
When !view <nick> is used, I want it to display the profile info found in the .ini file for the nick specified after !view.

So what is the way to do that?

Here is my profile script...


on *:text:!setup:#ChanName: {
query $nick Please answer the following questions here in my PM.
query $nick What is your age? Type !age (your age)
}

on *:text:!age *:*: {
writeini info $+ .ini $nick Age $2-
query $nick What is your gender? Type !gender (your gender)
}

on *:text:!gender *:*: {
writeini info $+ .ini $nick Gender $2-
query $nick What is your location? Type !location (your location)
}

on *:text:!location *:*: {
writeini info $+ .ini $nick Location $2-
query $nick What is your role? Type !role (your role)
}

on *:text:!role *:*: {
writeini info $+ .ini $nick Role $2-
query $nick Now describe yourself. Type !desc (your description)
}

on *:text:!desc *:*: {
writeini info $+ .ini $nick Description $2-
query $nick Your profile is now finished. Thank you.
msg #ChanName * * * $nick has just made a profile. Type !view $nick to check it out. * * *
Halt
}

on *:text:!view *:#ChanName: {
/notice $nick * * * Profile for $nick * * * | /notice $nick * | /notice $nick Age: $readini(info $+ .ini,$nick,Age) - - - Gender: $readini(info $+ .ini,$nick,Gender) - - - Location: $readini(info $+ .ini,$nick,Location) - - - Role: $readini(info $+ .ini,$nick,Role) | /notice $nick * | /notice $nick Description: $readini(info $+ .ini,$nick,Description) | /notice $nick * | /notice $nick * * * End of profile * * *
Halt
}

Last edited by raggie; 22/06/14 06:14 PM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
If you made that script, you should understand that $nick refers to the nickname typing the text, when typing !view <nick>, you want to use <nick> instead of $nick, <nick> is just the second parameter, $2 .

You used $2 in your others on text event to get each informations, here it's the same.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2014
Posts: 6
R
raggie Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2014
Posts: 6
I know $nick means the nick of the person typing.

As for the rest of what you said, it makes no sense to me.

Could you provide a snippet?

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Sure.
In your situation, you have the nick who sent the message, $nick, and the nick specified after !view, which is the second word of the message, $2, and I quote:
Quote:
When !view <nick> is used, I want it to display the profile info found in the .ini file for the nick specified after !view.


Note also that you must always use the 'n' switch with $readini when you don't want to evaluate the line being read, this is unsafe and in a typical script like this (and it's the case here) there is an exploit, people can use the current script here to do anything they want on your computer, you can read more about it here .

Code:
on *:text:!view *:#ChanName: {
;this check that $2, the nickname, is specified and that we have a profile for that nickname
if ($2 != $null) && ($ini(info.ini,$2) != $null) {
/notice $nick * * * Profile for $2 * * *
/notice $nick *
;no need to use info $+ .ini, info.ini is just fine, maybe you had something before..
/notice $nick Age: $readini(info.ini,n,$2,Age) - - - Gender: $readini(info.ini,n,$2,Gender) - - - Location: $readini(info .ini,n,$2,Location) - - - Role: $readini(info.ini,n,$2,Role) | /notice $nick *
/notice $nick Description: $readini(info.ini,n,$2,Description) 
/notice $nick * 
/notice $nick * * * End of profile * * *
;no need to halt here
}
}

Last edited by Wims; 22/06/14 08:32 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2014
Posts: 6
R
raggie Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2014
Posts: 6
Wims... I just tried it and it did nothing.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Are you typing only "!view"? You must give a nickname here
If you are giving a nickname, make sure it has an entry in the ini file, it should work


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2014
Posts: 6
R
raggie Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2014
Posts: 6
I'm typing in a nick after !view and there is an entry for that nick.

Also, I get know where to put the 'n' switch element nor the correct way to use it.


Last edited by raggie; 22/06/14 09:27 PM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Note: you edited your post but it was originally saying that the script only worked when specifying a nickname

Yes, that was intended because you didn't state you wanted both and I didn't assume so. You have to use an if statement and to use $nick in one case and $2 for the other:
Code:
on *:text:!view *:#ChanName:{
  ;the code will use the variable %nick for the profile, either set to $2 or to $nick
  if ($2 != $null) {
    if ($ini(info.ini,$2) != $null) var %nick $2
    else {
     msg $chan Error: no profile for the nickname $2
     ;after an error, you don't want to keep going with the profile so you /return, using /halt is not necessary and can have consequences on the rest of the loaded scripts
     return
    }
  }
  elseif ($ini(info.ini,$nick) != $null) var %nick $nick
  else {
   msg $chan Error: no profile for the your nickname $nick
   return
  }
  /notice $nick * * * Profile for %nick * * *
  /notice $nick *
  /notice $nick Age: $readini(info.ini,n,%nick,Age) - - - Gender: $readini(info.ini,n,%nick,Gender) - - - Location: $readini(info.ini,n,%nick,Location) - - - Role: $readini(info.ini,n,%nick,Role) | /notice $nick *
  /notice $nick Description: $readini(info.ini,n,%nick,Description) 
  /notice $nick * 
  /notice $nick * * * End of profile * * *
  }
}
The 'n' switch on $readini is there, switches go after the filename in $readini

Last edited by Wims; 22/06/14 09:55 PM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jun 2014
Posts: 6
R
raggie Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2014
Posts: 6
Wims, I'm sorry for the mix up earlier.

You did solve my problem tho. Thank you so much. smile

Joined: May 2013
Posts: 140
R
Vogon poet
Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Thank I am using this in my bot and made a couple of changes, I have received a couple of requests to delete a profile. Not good with ini files and can thus not be able to figure out how to delete the whole entry that looks like this.

[Nikita]
Age=35
Gender=female
Location=Gauteng
Role=Chanel Owner
Description=Brown eyes and hair, slender

Also is there a way to edit one of the entries only: eg change Age=35 to Age=36

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
To delete the information in the ini file, here you would just use the command "/remini path/to/file.ini nikita"
To update an information, you have to use "/writeini path/to/file.ini nikita age 36" where you can replace "age" with any item name, aka gender, location etc.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2013
Posts: 140
R
Vogon poet
Offline
Vogon poet
R
Joined: May 2013
Posts: 140
Thank you Wims for being willing to help others. One last question if I may?

I want to prevent users without a profile to access other profiles, I have tried various ways without success the last above your code below seems to allow users with or without a profile. Any ideas?

Quote


on *:text:!view *:#: {
;check if having profile======================

if ($2 != $null) {
if ($ini(info.ini,$2) != $null) var %nick $2
else {
msg # Sorry you nust have a profile to view other profiles... Type !setup to do so
return
}
}
elseif ($ini(info.ini,$nick) != $null) var %nick $nick
else {
msg # Sorry you nust have a profile to view other profiles... Type !setup to do so
return
}

; ====================

: your code to view regardless of having a profile

on *:text:!view *:#ChanName:{
;the code will use the variable %nick for the profile, either set to $2 or to $nick
if ($2 != $null) {
if ($ini(info.ini,$2) != $null) var %nick $2
else {
msg $chan Error: no profile for the nickname $2
;after an error, you don't want to keep going with the profile so you /return, using /halt is not necessary and can have consequences on the rest of the loaded scripts
return
}
}
elseif ($ini(info.ini,$nick) != $null) var %nick $nick
else {
msg $chan Error: no profile for the your nickname $nick
return
}
/notice $nick * * * Profile for %nick * * *
/notice $nick *
/notice $nick Age: $readini(info.ini,n,%nick,Age) - - - Gender: $readini(info.ini,n,%nick,Gender) - - - Location: $readini(info.ini,n,%nick,Location) - - - Role: $readini(info.ini,n,%nick,Role) | /notice $nick *
/notice $nick Description: $readini(info.ini,n,%nick,Description)
/notice $nick *
/notice $nick * * * End of profile * * *
}
}





Link Copied to Clipboard