Log in

View Full Version : Multiple item checker and nuker on EVENT_TARGET_CHANGE. Need help.


Drakiyth
05-05-2012, 10:08 PM
player.pl <--- Possible?


sub EVENT_TARGET_CHANGE {

if(plugin::check_hasitem($client, xxxx) && if(plugin::check_hasitem($client, xxxx)
{
$client->NukeItem(xxxx);
$client->NukeItem(xxxx);
}
}


I put this in templates named as player.pl and it's purpose is to check 2 or more items on the player at once as soon as they switch targets and if they break this rule the nuke goes off and eliminates all of the items. (it's an anti-cheat for having items you're not supposed to.) This however is not working when I try it with a couple test items. Is there anyway to make this work?

NOTE: The player is not allowed to have both of these items and that's why the anti cheat burns them.

joligario
05-05-2012, 10:20 PM
Need only 1 if and close your parenthesis

oslander
05-05-2012, 10:29 PM
Need only 1 if and close your parenthesis

sub EVENT_TARGET_CHANGE {

if(plugin::check_hasitem($client, 4202) && plugin::check_hasitem($client, 4203)
{
$client->NukeItem(4202);
$client->NukeItem(4203);
}

I think this is what he means. I used bronze mask and collar as an example.

lerxst2112
05-05-2012, 10:46 PM
Close...


if(plugin::check_hasitem($client, 4202) && plugin::check_hasitem($client, 4203))

joligario
05-05-2012, 11:29 PM
And just a note: the way you have it only triggers if they have both.

Drakiyth
05-06-2012, 01:05 AM
And just a note: the way you have it only triggers if they have both.

It's not working. I switch the target and the items aren't deleted. Does the NukeItem feature not work with this or is there something wrong with this script?
EDIT: I forget to close it originally, a small mistake but it's not working even closed below.


#Player.pl Under the Wayfarer's message in Templates.

sub EVENT_TARGET_CHANGE {

if(plugin::check_hasitem($client, 4202) && plugin::check_hasitem($client, 4203))
{
$client->NukeItem(4202);
$client->NukeItem(4203);
}

}

lerxst2112
05-06-2012, 02:06 AM
Add some debugging information to the script to make sure it is even running. Add messages at each stage so you can see where it goes wrong, and simplify it into small steps you can test individually and then put them together.

Drakiyth
05-06-2012, 05:12 AM
This is goofy. Why does it do this?

THIS WILL PLAY A FANFARE AND NUKE THE CHOSEN ITEMS EVERY TIME A
DIFFERENT TARGET IS CHOSEN OR DROPPED.

# File is player.pl in the templates folder.

sub EVENT_TARGET_CHANGE {

quest::ding();
$client->NukeItem(4202);
$client->NukeItem(4203);
}

}


THIS WILL NOT DO ANYTHING. THE PLUGIN IS CORRECT BECAUSE I TESTED IT ON A NPC INSTEAD OF PLAYER.PL


# File is player.pl in the templates folder.

sub EVENT_TARGET_CHANGE {

if(plugin::check_hasitem($client, "4202")
{
quest::ding();
$client->NukeItem(4202);
$client->NukeItem(4203);
}

}



So what in the world do I need to do to check for those items that it's not passing through to get to the next stage on EVENT_TARGET_CHANGE or is it impossible?

Secrets
05-06-2012, 07:44 AM
# File is player.pl in the templates folder.

sub EVENT_TARGET_CHANGE {

if(plugin::check_hasitem($client, "4202") )
{
quest::ding();
$client->NukeItem(4202);
$client->NukeItem(4203);
}

}

You are missing a closing ). I highlighted where it was missing. A perl interpreter will tell you these errors if you run "perl script.pl" on the windows command line.

If it shows nothing when you run it, then it's an issue with the emulator code and not a syntax error.

lerxst2112
05-06-2012, 05:44 PM
lol, I made it bold in mine too, but making it giant is a sure win. :) <3 Secrets

Drakiyth
05-06-2012, 09:15 PM
The extra ) actually broke the script on the npc and wasn't needed. (I already said I tested this on an NPC with the single ")") It was fine as is. Thanks for trying to help though. This call doesn't work with this EVENT type so it's impossible to do with it. I asked if you all knew a way to get this to work but I doubt it. I'll have to figure something else out.

NOTE: If I knew the answer to something I would of already made a script for the person who was asking for help. If you want to show you're true tech gods that know anything it would be better if you actually showed it instead of act like I should know everything already. If I did I wouldn't be asking for help. "Closing" that isn't even needed. The extra "IF" was a mistake but the single ) was fine. Try the script for yourself on an NPC.

trevius
05-06-2012, 10:22 PM
First of all, with your attitude in your last reply, you really don't deserve further help. The answer has already been handed to you and you are complaining about that.

I tested the following script just now on a player.pl in my blackburrow zone and it worked perfectly fine.

sub EVENT_TARGET_CHANGE {

if (plugin::check_hasitem($client, 2632))
{
quest::ding();
$client->Message(13, "Target Changed");
}

}

Note that I used a different item ID, because I just picked a random item my character had on them for testing. I also didn't use your nuke item, but used a debug message instead to prove it was getting that far and it did.

Also, anytime you have an opening parenthesis "(", or curly bracket "{", you always need a closing one that goes with that specific one. I highly recommend you download notepad++ for your script editing, because it will make it really easy for you to make sure you have your brackets and parenthesis properly closed. Just click next to the one you want to check and it highlights the other one in red.

The people that were responding in this thread to help you have been doing this stuff for years, so they know what they are talking about.

If you are still having a problem with that script, then your issue is most likely with the plugin itself. Maybe you don't have plugins in the correct folder. By default from PEQ, the plugin folder is inside the quest folder. You need to move it directly into your server folder for them to actually work.

As mentioned earlier, you are using && in your example which means they need to have both items for the nuke item to happen. What you want is || for OR instead of AND. This should work:
sub EVENT_TARGET_CHANGE {

if(plugin::check_hasitem($client, 4202) || plugin::check_hasitem($client, 4203))
{
$client->Message(13, "Nuking Items");
$client->NukeItem(4202);
$client->NukeItem(4203);
}

}

Secrets
05-06-2012, 11:10 PM
I didn't mean it as offensive, I was just pointing out a syntax error. Trevius' reply is right though, the script he posted should work.

I didn't mean to come of as a know-it-all. I just wanted to help.

chrsschb
05-07-2012, 12:10 AM
I use a shit load of check_hasitem plugins on my server, Trevius is 100% right!

Drakiyth
05-07-2012, 02:45 AM
I apologize if I came off rude. I'm just extremely stressed out right now with trying to fix this stuff up. I decided to make the first tier and higher path charms epic lore so now people can't have two of them in their inventory at once, however bots are bringing in a problem with being able to stash these charms. Trevius, Secrets, Lerxst, Joligaro, Oslander, thank you for your help.

Would you good folks know how to do away with unwanted items on bots by any chance?

Secrets
05-07-2012, 06:13 AM
I apologize if I came off rude. I'm just extremely stressed out right now with trying to fix this stuff up. I decided to make the first tier and higher path charms epic lore so now people can't have two of them in their inventory at once, however bots are bringing in a problem with being able to stash these charms. Trevius, Secrets, Lerxst, Joligaro, Oslander, thank you for your help.

Would you good folks know how to do away with unwanted items on bots by any chance?

No, there's no easy fix for permanently preventing items for bots atm, but I don't see why it couldn't be implemented.

nosfentora
05-07-2012, 10:17 AM
Would you good folks know how to do away with unwanted items on bots by any chance?


Off the top of my head I would expand on your current script.

Create a list of item id's you DON'T want bots to have. That way you don't need to add any more code, you just need to add the item id to the list.

Check against that list when trading with the bot, and either poof the item or hand it back to the character.

I haven't looked at what events are available for bots, but at trading time would probably be the best, or you could do at bot despawn if that event is available.

The 2nd method wouldn't prevent some form of abuse while the bot is alive though.

You could expand it further by setting a qglobal on the character that if they do it once, they get the item back and a warning. if they do it again the item poofs. do it a third time they get sent to the POJ trials alone or some interesting place.

I haven't touched quests in a long time so i'm not sure what events are available for bots.

Drakiyth
05-07-2012, 04:14 PM
That's actually a really good idea. Just need to find a way to remove items with a script from bots in general. Do you have any ideas on that, Nosfentora? Aside from hacking...

nosfentora
05-07-2012, 04:59 PM
Off the top of my head not really. You could run an sql query something like


DELETE FROM botinventory WHERE ItemID IN (itemid1,itemid2,itemid3)


that would delete all items that are in that list from bot inventory.

you could get real complicated and have a scheduled task run on the os every X hours and run that script, or run it by hand whenever you want.

as far as a perl script, you could do something like this pseudo code suggests


var banned_item_id_list = {1000,10002,10003}

EVENT bot_spawn

for each item in bot_inventory
if banned_item_id_list contains item.itemid
delete item
end if
next

end event

chrsschb
05-07-2012, 10:09 PM
I assume these class / sub-class charms are pretty powerful. So powerful in fact that a player would never want to get rid of it. So if the charm is used in the quest to upgrade it, I'm assuming that the quest is repeatable? If the quest is repeatable make it NOT repeatable and you've solved your problem. I know if > I < only had ONE badass charm, and couldn't get another, I damn sure wouldn't waste it on a bot.

Cilraaz
05-08-2012, 10:39 AM
I assume these class / sub-class charms are pretty powerful. So powerful in fact that a player would never want to get rid of it. So if the charm is used in the quest to upgrade it, I'm assuming that the quest is repeatable? If the quest is repeatable make it NOT repeatable and you've solved your problem. I know if > I < only had ONE badass charm, and couldn't get another, I damn sure wouldn't waste it on a bot.

I think it's more a matter of dropping the starter charm on a bot, obtaining a second one, questing the second one to the best it can be, taking the first one back from the bot, and questing it up to be next to the best it can be. That assumes that it's somehow possible to get the starter item again, but I think it's the problem that's happening.

Drakiyth, if you're interested in finding out who is cheating (now that you've outlined that storing a charm on a bot is a no-no), you could use something like:

SELECT * FROM account WHERE id=(
SELECT account_id FROM character_ WHERE id=(
SELECT BotOwnerCharacterID FROM bots WHERE BotID=(
SELECT BotID FROM botinventory WHERE ItemID IN('00001','00002'))));

Obviously substitute item numbers 00001 and 00002 for whatever items you're checking for. That should return the account rows for any account where any character owns any bot holding any disallowed item.