Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

A script i made need a lil help


Recommended Posts

Sub hobo(index)
If GetVar("FLAGS.ini", GetPlayerName(index), "Flag1") = 0 Then
Call RaiseFlag(Index, 1, 1)
Call BattleMsg(index,"Hobo: Thank you!", 4, 0)
End If
If GetVar("FLAGS.ini", GetPlayerName(index), "Flag1") = 1 Then
Call BattleMsg(index,"Hobo: Please, can you get me a salmon to eat ? i can pay you back!", 4, 0)
Call TakeItem(index, 32)
Call GiveItem(index, 1, 100)
Call LowerFlag(Index, 1, 1)
End If
End Sub

THis is just a simple quest
"im a hobo i need food blah.."
* brings food*
"here you go"
* gets item *
–-----------
SO how should a scripted tile look like for this case 0 and where do i put the main script that i have here?
Link to comment
Share on other sites

Okay; first off, do you have the RaiseFlag, LowerFlag, TakeItem, and GiveItem in your main.txt?

If not, you'll have to add them (I'm assuming you do have them, since you called them in your script).

Now, to actually use this, paste it at the bottom of your main.txt, and under Case 0 for the scripted sub, just put:
Case 0
  Call hobo(index)
  Exit Sub
Link to comment
Share on other sites

Soooo..
Sub hobo(index)
If Int(GetVar("FLAGS.ini", GetPlayerName(index), "Flag1")) = 0 Then
Call RaiseFlag(Index, 1, 1)
Call BattleMsg(index,"Hobo: Thank you!", 4, 0)
End If
If GetVar("FLAGS.ini", GetPlayerName(index), "Flag1") = 1 Then
Call BattleMsg(index,"Hobo: Please, can you get me a salmon to eat ? i can pay you back!", 4, 0)
Call TakeItem(index, 32)
Call GiveItem(index, 1, 100)
Call LowerFlag(Index, 1, 1)
End If
End Sub
Link to comment
Share on other sites

@manbearpig:

> Aww doesnt work =((*double chin*

You need to do it for everything that returns a string, eg both GetVar functions =/

Also, you have a logical error in your script, but let's see if it can atleast work first ;)

EDIT:
Or, you could just send it back as a string, eg:
If GetVar("FLAGS.ini", GetPlayerName(index), "Flag1") = "0" Then

EDIT 2: Oh, and you're calling the INI wrong also; it should be:
If GetVar("FLAGS.ini", "" & GetPlayerName(index) & "", "Flag1") = "0" Then
or
If Int(GetVar("FLAGS.ini", "" & GetPlayerName(index) & "", "Flag1")) = 0 Then
Link to comment
Share on other sites

@manbearpig:

> im such a noob so can any one just post a new main but with my script aded to it so i  can learn what to do and so i wont have this mistake again?

It's not a mistake in installing it, it's a mistake in the syntax.

Now, when the Getvar gets something from an ini, it returns a strong, not a number.  You're trying to get it to read 0 or 1 as numbers, when you should get it to read 0 or 1 as strings (with strings, they need to be in quotes).

Now, what you can do, is simply have the 0 and 1 in double-quotes (eg, "0", "1").

Your second error, was when calling the GetVar in the first place:
If GetVar("FLAGS.ini", **GetPlayerName(index)**, "Flag1") Then
It needs to accept three strings, but you only have two (notice the quotes in the two arguments, but not the one in the middle).
To overcome this, you can use the "&", to attach the string like so:
If GetVar("FLAGS.ini", **"" & GetPlayerName(index) & ""**, "Flag1") Then

That should work.
But please notice; you are using GetVar twice, to get two differnet values from the ini; if you look at the script you re-posted, you only changed the first one.

SO, the working script (assuming other syntax,and logic is correct), should be as follows (there are two methods, one with Int() and one without Int(), both should work, but look at them both to see what you did wrong):

> Sub hobo(index)
> If Int(GetVar("FLAGS.ini", GetPlayerName(index), "Flag1")) = 0 Then
> Call RaiseFlag(Index, 1, 1)
> Call BattleMsg(index,"Hobo: Thank you!", 4, 0)
> End If
> If Int(GetVar("FLAGS.ini", GetPlayerName(index), "Flag1")) = 1 Then
> Call BattleMsg(index,"Hobo: Please, can you get me a salmon to eat ? i can pay you back!", 4, 0)
> Call TakeItem(index, 32)
> Call GiveItem(index, 1, 100)
> Call LowerFlag(Index, 1, 1)
> End If
> End Sub

Or:

> Sub hobo(index)
> If GetVar("FLAGS.ini", GetPlayerName(index), "Flag1") = "0" Then
> Call RaiseFlag(Index, 1, 1)
> Call BattleMsg(index,"Hobo: Thank you!", 4, 0)
> End If
> If GetVar("FLAGS.ini", GetPlayerName(index), "Flag1") = "1" Then
> Call BattleMsg(index,"Hobo: Please, can you get me a salmon to eat ? i can pay you back!", 4, 0)
> Call TakeItem(index, 32)
> Call GiveItem(index, 1, 100)
> Call LowerFlag(Index, 1, 1)
> End If
> End Sub

Also, as I asked before, you did install the RaiseFlag, LowerFlag, TakeItem, and GiveItem subs in your main.txt, right?

Warning - while you were typing a new reply has been posted. You may wish to review your post.
I haven't even noticed that he was calling the TakeItem wrong, then he probably didn't install the subs
Link to comment
Share on other sites

@manbearpig:

> nope.

Why would you Call LowerFlag, if you don't even have it?

Go find those functions and subs, and install them into your main.txt (I'm not sure where they would be)

Though, it looks like you used that random generator for making scripts; it's not the best, and it doesn't provide the functions or anything (it also calls the functions incorrectly).
I'd recommend you get a basic understanding of scripting, and read up on some quest tutorials; because what you're trying to accomplish can be done alot easier if scripted manually

EDIT: I found the raise/lower flag subs; not sure if they are the ones that script uses, so check the arguments and make sure they match up: http://www.touchofdeathforums.com/smf/index.php?topic=7014.0
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...