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

multiple instaces of the same event handler...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hoboman
Senior Member
Join Date: Jul 2007
Old 03-06-2008 , 15:02   multiple instaces of the same event handler...
Reply With Quote #1

So I am debugging this plugin and I am wonder what will happen if multiple instances of the same event handler get called simultaneously and try to change the same variable.

For example:
Code:
new cheese
.
.
.
public event_money(id)
{
   cheese++
}
where event_money is the handler of the Money event and two users buy stuff at the same time.

Is there something in amxx that would prevent this from happening, and if not then what would likely happen?

I suspect that this thing actually crashes the server, but I am not 100% sure.
__________________

Last edited by hoboman; 03-07-2008 at 01:59.
hoboman is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-07-2008 , 01:16   Re: multiple instaces of the same event handler...
Reply With Quote #2

new cheese[33]

...


cheese[id]++



?????
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hoboman
Senior Member
Join Date: Jul 2007
Old 03-07-2008 , 02:00   Re: multiple instaces of the same event handler...
Reply With Quote #3

oh yes...i know, that is what I changed it to, too

but I am just curious if that was even necessary...
__________________
hoboman is offline
Styles
Veteran Member
Join Date: Jul 2004
Location: California
Old 03-07-2008 , 13:26   Re: multiple instaces of the same event handler...
Reply With Quote #4

Well since we don't know what your trying to do... What you did new cheese[33] will allow it to increment for every USER that it happens to..You basicly made an array. User ID's are from 1 - 32 err mabye 0 - 31 not sure... but anyway..when event_money is called cheese[id] will be the persons ID so if they are #7 and that runs its basicly doing cheese[7]++ // so index 7 in the array is going to be added +1
Styles is offline
Send a message via AIM to Styles
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 03-08-2008 , 02:47   Re: multiple instaces of the same event handler...
Reply With Quote #5

I would have thought that two functions can't be called "simultaneously" because HL is single-threaded.

It's 1-32 styles.
Lee 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 21:47.


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