AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detect related (https://forums.alliedmods.net/showthread.php?t=22147)

Unidentified 12-19-2005 20:41

Detect related
 
I have a few simple questions.

How would you detect If a user Is already using a certain function? Such as telling them that, "You are already using this." or whatever.

Also, how would you detect If the player Is hit while using a function, then do a new function.

Bruno 12-19-2005 21:05

Well for detecting if they are already performing an action, you can use a bool.

Unidentified 12-19-2005 21:07

Quote:

Originally Posted by Bruno
Well for detecting if they are already performing an action, you can use a bool.

If only I understood bools. :oops:

teame06 12-19-2005 21:11

Code:
new bool:g_MyFunctionUse[33] << Global Value. public MyFunction(id) {     if(!g_MyFunctionUse[id])     {         g_MyFunctionUse[id] = true     }         else if(g_MyFunctionUse[id])     {         console_print(id, "You have already activated this command.")     } }

Bruno 12-19-2005 21:17

I am not so sure about detecting if a player is hit, but you can try this http://www.amxmodx.org/doc/source/fu...r_hitzones.htm

Brad 12-19-2005 21:22

Rewritten ever so slightly to follow the rule that you should place the most likely condition at the top of a list of conditionals. Also took of the second condition as a boolean only has two values so you don't need to check it twice. Also added semicolons because that's what I do. Also added a space after each if because damn it, that's how God intended it to be (He also intended programmers to use tabs instead of spaces but I didn't fix that).

Code:
 new bool:g_MyFunctionUsed[33]; // Global Value. public MyFunction(id) {     if (g_MyFunctionUsed[id])     {         console_print(id, "You have already activated this command.");     }         else     {         g_MyFunctionUsed[id] = true;     } }

Bruno 12-19-2005 21:25

Brad can you help me with my problem?

teame06 12-19-2005 21:56

Code:
new bool:g_MyFunctionUsed[33]; // Global Value. public MyFunction(id) {     if (g_MyFunctionUsed[id])     {         console_print(id, "You have already activated this command.");         return PLUGIN_HANDLED     }         else     {         g_MyFunctionUsed[id] = true;     } }

teame06 12-19-2005 23:00

Quote:

Originally Posted by Bruno
I am not so sure about detecting if a player is hit, but you can try this http://www.amxmodx.org/doc/source/fu...r_hitzones.htm


You shouldn't be hijacking people thread. If you want to know when a player is hit. use register_event and Damage event. That will give you the person who is getting hit. But if you are trying to get where they are hit it different.

Brad 12-19-2005 23:21

Unless the function is a forward or you are using the return value elsewhere, you don't need to return anything.

Edit: I didn't not know that the return value also matters when a function is called from a menu (or something like that). Thank you, teame06, for enlightening me.


All times are GMT -4. The time now is 16:10.

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