[FilterScript] Interactive Trashcans
#1

Interactive Trashcans
by Manyula
Description
This small filterscript contains 89 mapped trashcans (objectid 1345), spread all over Los Santos. You can basically rummage through the trash and find different things that either give you a little bonus or some things that might even hurt you. When you approach a trashcan an info box will pop up, telling you what to do to interact with it. Every trashcan that has already been plundered can be plundered again after 30min. You can change this time by editing the "MINUTE" define on the top of the filterscript. Also, you can cancel the process of plundering the trashcan with the ALT key when you get into a gunfight for example.

Requirements
You're going to need Incognito's streamer plugin as this filterscript uses callbacks out of it.

Plans
I'm planning on mapping trashcans both in San Fierro and Las Venturas too. This might, however, take some time.

Source
Pastebin

Thanks for stopping by!

Regards,

Manyula

_________________________________________________
Edit: Code improvements.
Reply
#2

Good job!
Reply
#3

A couple of things you could do to improve this.

1.) No need for OnFilterScriptExit() the streamer auto deletes anything created.
2.) You are using dynamic areas why bother looping through and doing IsPlayerInRangeOfPoint() checks makes no sense to me when all you need to do is record the current index then check if the player is in that area when doing a key press.
3.) TrashcanNotification[playerid][3] = CreatePlayerTextDraw(playerid, 383.333343, 344.711120, "Press ~r~ALT ~w~to interact~n~with a trashcan."); Use the correct ~k~ code instead of ALT it might be different depending on the players keys.
Reply
#4

Thanks for your positive feedback and for your suggestions.

@Pottus:
1.) Done.
2.) I've replaced the IsPlayerInRangeOfPoint-Check by IsPlayerInDynamicArea(TrashCans_InteractionField[i])".
However, I don't quite get what you mean with "recording the current index and then checking if the player is in that particular area" instead of doing a loop. Sorry for that, I'm still learning. Could you please be a little more precise?
3.) Didn't even consider that, thanks. Done.
Reply
#5

When a player enters an area you loop through to find which area it is when found the iterator value references the index of the trashcan found. Save that value in a variable for instance CurrTrashArea[playerid] = i; then when a key press is made use

pawn Код:
if(IsPlayerInDynamicArea(playerid, TrashCans_InteractionField[CurrTrashArea[playerid]])) { }
No need for any looping now and if you really want to top it off do this.

pawn Код:
if(CurrTrashArea[playerid] > -1)
{
    if(IsPlayerInDynamicArea(playerid, TrashCans_InteractionField[CurrTrashArea[playerid]])) { }
    else CurrTrashArea[playerid] = -1;
}
That way it won't do any extra code if there is consecutive key presses and they are not in the area the area is to -1 so they would have to actually enter the area to have it set again.
Reply
#6

Nice
Reply
#7

Cool one.
Reply
#8

So, I basically save a loop when pressing a key by just storing the area index into a variable. Nice way of doing it, thank you very much.

I've updated the 1st post now.
Reply
#9

Perfect script, good release!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)