Raised This Month: $51 Target: $400
 12% 

Solved Manipulate Forward


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConorCC
Member
Join Date: Feb 2014
Old 06-27-2021 , 17:35   Manipulate Forward
Reply With Quote #1

Hello there!

Is it possible to manipulate function output via a forward. For example:
Code:
native do_a_thing(id, data);
forward fw_do_a_thing(id, data);
My plugin call the do_a_thing function that return 1 by default.

In my fw_do_a_thing function I would validate the data. If it is defined as a fix value I want change the final output to 0.

I think it is possible I just want to see an example for custom functions. Like you register a client command. And it disappear from the chat if you return PLUGIN_HANDLED.

Thank you!

Last edited by ConorCC; 06-28-2021 at 05:12.
ConorCC is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-27-2021 , 20:25   Re: Manipulate Forward
Reply With Quote #2

You can create your own custom natives as shown in the tutorial here. Forwards are a bit of a different concept so I think you are confusing them with natives.

If this tutorial doesn't answer your questions, you'll need to provide more details about what you're trying to do. Providing an actual example of what you are trying to do would be best (don't use code, just use english).
__________________

Last edited by fysiks; 06-27-2021 at 20:28.
fysiks is offline
ConorCC
Member
Join Date: Feb 2014
Old 06-28-2021 , 01:43   Re: Manipulate Forward
Reply With Quote #3

Im sure I have to use both of them natives and forwards. I have already used them before but I am not famailiar with this case.

Here is the example I want to use in my code:

So there is an object. Like an item or something. It has several data including an unique item ID. By default this ID is zero. Lets say I want to create a new object, an item. Sice this item doesen't exists I have to insert it into the database. At this point the unique ID still zero. (I am waiting for the database response.) After that I set this ID equal with the last inserted ID. (Received from the query.) So If I want to add an another item I won't create a new one. I just update the existsing one's data (like amount) instead of inserting again.

NOTE: This part is no need to be the part of the code. I am already done with this. I just want you to understand it well.

The problem is when you are trying to give the second item. In localy the item is already exist but it didn't get the unique ID. If it happens I want to catch it.

The main reason I have to use forwards as well cause the scripts are separated in different plugins. In this case one plugin for the items itself. There is a native for giving item. And a forward to follow this event.

A detailed example: My sub plugin call the native. (Create the item.) The forward will reply with the client ID and the item itself. (Even if it has a unique ID or not.) BUT if not I want to tell the forward to change the native's retrurning value to anything else. That will notice me about the failure.

---

After I wrote these sentences I am not quiet sure about my goal. Maybe I try to reach my goal in a very complicated way and probably you can make it more easily.

Thanks!

--- EDIT:

I forgot something important. I also use the sub plugin to store the data in my db. That is why I must use forward. I cannot skip this step.

--- EDIT 2:

I think I found what I was searching for.

ExecuteForward's 2nd parameter can handle this job. I only have to set a specific value and it can be tracked at the right point. Sorry for wasting your time. I hope it can be useful for somebody else.

Last edited by ConorCC; 06-28-2021 at 03:47.
ConorCC is offline
VINAGHOST
Member
Join Date: Aug 2016
Location: Việt Nam
Old 06-28-2021 , 04:17   Re: Manipulate Forward
Reply With Quote #4

I'm not sure
But in Zombie Plauge 5.0, zombie/human class has register system like u said. Maybe u want to look at them.
VINAGHOST is offline
ConorCC
Member
Join Date: Feb 2014
Old 06-28-2021 , 05:12   Re: Manipulate Forward
Reply With Quote #5

Yes, It is. I was doing the same and it seems working. Thank you!
ConorCC is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 06-28-2021 , 22:53   Re: Manipulate Forward
Reply With Quote #6

Quote:
Originally Posted by ConorCC View Post
Sorry for wasting your time.
No need to be sorry. Sometimes just the act of explaining what you want to do can help you realize or discover issues you might have had in your own design. This is often referred to as rubber ducky debugging.
__________________

Last edited by fysiks; 06-28-2021 at 22:54.
fysiks is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:47.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode