Hiring an npc, Can anyone help??
Hi again..
Got this lil' script, which should allow the player to hire the Swordslinger, (for 5pp an hour), its not working, and I've no idea why, could someone please have a look and maybe popint me in the right direction??? Please! sub EVENT_SAY { my $fig = quest::saylink("fight"); if($text=~/Hail/i) { quest::say("I am for hire, $name, and I'm currently charging 5pp per hour, Want me to fight for you $class?, just pass me 5pp"); } sub EVENT_ITEM { if(($platinum == 5)) { quest::depop; $client->MakePet(null, Trillion, "Trillion"); } } sub EVENT_TIMER { if($timer eq "payme") { quest::say("Time for my payment, $name"); quest::stoptimer("payme"); } sub EVENT_ITEM { if(($platinum == 5)) { } else { quest::depop; } quest::settimer("payme", 60); } } |
Multiple problems. One thing is you have two ITEM subs. Your brackets are also not matched up. And your logic may not accomplish what you are trying to do.
Not sure you are using this right: MakePet(spell_id, pettype, name=NULL) |
Quote:
I didn't know yo couldn't have 2 event items, where I ran into problems was where I want the player to pay for the hours service.. |
you can't have two subroutines with the same name in the same namespace in perl. only the last one ends up being used. if you want to check your scripts for compilation errors while writing them, add these lines at the top and run then from a command line, instead of using them from within the emulator:
Code:
use strict; Code:
no strict 'vars'; example_script.pl Code:
Code:
C:\EQEmu\sandbox>perl test_conditionals.pl |
Quote:
had another shot, this is how it looks now :) But, got a problem with the else statement?, anyone got thoughts, thanks for the help thus far! sub EVENT_SAY { if($text=~/Hail/i) { quest::say("I am for hire, $name, and I'm currently charging 5pp per hour, Want me to fight for you $class?, just pass me 5pp"); } sub EVENT_TIMER { if($timer eq "payme") { quest::say("Time for my payment, $name"); quest::stoptimer("payme"); } } else { quest::say("No pay, no fighting, see you around, $name"); quest::depop; } sub EVENT_ITEM { if(($platinum == 5)) { quest::depop; $client->MakePet(null, Trillion, "Trillion"); } } quest::settimer("payme", 60); } |
You have syntax errors all over the place.
As a general rule of thumb, for every left bracket, there is a closing right bracket. If there's an if statement, a bracket follows that if statement to encapsulate the following commands. For example, sub EVENT_SAY { <-- Starting bracket for SUB_EVENT if($name eq "Penny") { - If the name matches "Penny", do the below command. quest::say("Hi Penny!"); } - Close the if statement } - Close the subroutine. I recommend taking a tutorial on perl. It will teach you elementary concepts about the scripting language. http://www.tizag.com/perlT/ Furthermore, remember that you can set quest globals in order to save your variables past zoning, zone shutdown, or client desync. There are examples littered over this forum as well as on the EQEmulator wiki for a detailed description of how they work. If you aren't ready to learn about that, using a simple variable would be good enough to track paid status. You would still have to kill the player's pet by depopping it by client ID, but this should get you started on checking a timer. Alternatively, use makepet to spawn a pet by NPC ID, assign a script to the pet in the templates folder. The alternative would be something like what i listed below. Code:
Hope that helps. |
and for god sakes use the damn code tags...
|
And, as c0ncrete demonstrated above, Perl will happily tell you where the syntax errors are, you just need to use it.
Code:
C:\Temp>perl -c t.pl |
All times are GMT -4. The time now is 01:04 PM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.