AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Manipulate Forward (https://forums.alliedmods.net/showthread.php?t=333251)

ConorCC 06-27-2021 17:35

Manipulate Forward
 
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!

fysiks 06-27-2021 20:25

Re: Manipulate Forward
 
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).

ConorCC 06-28-2021 01:43

Re: Manipulate Forward
 
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.

VINAGHOST 06-28-2021 04:17

Re: Manipulate Forward
 
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.

ConorCC 06-28-2021 05:12

Re: Manipulate Forward
 
Yes, It is. I was doing the same and it seems working. Thank you!

fysiks 06-28-2021 22:53

Re: Manipulate Forward
 
Quote:

Originally Posted by ConorCC (Post 2751369)
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.


All times are GMT -4. The time now is 09:04.

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