Raised This Month: $ Target: $400
 0% 

Detect related


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Unidentified
Senior Member
Join Date: Aug 2005
Location: Compton, L.A. Thug
Old 12-19-2005 , 20:41   Detect related
Reply With Quote #1

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.
Unidentified is offline
Bruno
Member
Join Date: Jun 2005
Old 12-19-2005 , 21:05  
Reply With Quote #2

Well for detecting if they are already performing an action, you can use a bool.
Bruno is offline
Unidentified
Senior Member
Join Date: Aug 2005
Location: Compton, L.A. Thug
Old 12-19-2005 , 21:07  
Reply With Quote #3

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.
Unidentified is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 12-19-2005 , 21:11  
Reply With Quote #4

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.")     } }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Bruno
Member
Join Date: Jun 2005
Old 12-19-2005 , 21:17  
Reply With Quote #5

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
Bruno is offline
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-19-2005 , 21:22  
Reply With Quote #6

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;     } }
Brad is offline
Bruno
Member
Join Date: Jun 2005
Old 12-19-2005 , 21:25  
Reply With Quote #7

Brad can you help me with my problem?
Bruno is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 12-19-2005 , 21:56  
Reply With Quote #8

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;     } }
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 12-19-2005 , 23:00  
Reply With Quote #9

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.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Brad
AMX Mod X Team Member
Join Date: Jun 2004
Old 12-19-2005 , 23:21  
Reply With Quote #10

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.
Brad is offline
Reply


Thread Tools
Display Modes

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 16:10.


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