AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   I have a question [important] (https://forums.alliedmods.net/showthread.php?t=20073)

haimmaik 10-31-2005 22:01

I have a question [important]
 
can i create my own events?
i mean there is "ResetHUD" and "DeathMsg" and i want to know if i can create 1 of my own like "IsUsingKnife"

example:
register_event("IsUsingKnife","func_knifepowe r","a")

and please if the answer is yes.. give me an example ..
thanks alot :)

atambo 10-31-2005 22:11

no you can't create your own events but if you want a function to be called whenever someone uses a knife then you probably want to register the "CurWeapon" event then check to see if they switched to a knife using read_data(2) and comparing it to CSW_KNIFE

Example:

Code:

new wpn = read_data(2)
if(wpn == CSW_KNIFE)
    doStuff(id)


haimmaik 10-31-2005 22:38

and if i have a Variable like
new isgod[33]

and i want an event to give a "god" player his status (speed, gravity and so on) so i need an event

register_event("isgod","func_godstatus","a")
.
.
.

//here i set the god status everytime event isgod is on
public func_godstatus(id)
{
.
.
}


i mean as long as he is a god (isgod[id]=1) i want the function "func_godstatus" to run on him.. and when he isnt a god anymore (isgod[id]=0) i dont want it to run

(all this to prevent the server from lag cuz it lags when a function starts looping all the time)

Hawk552 10-31-2005 22:51

client_PreThink? Or run it in ResetHUD?

XxAvalanchexX 10-31-2005 23:07

You can't create your own events.

haimmaik 10-31-2005 23:07

whats client_PreThink? how i use it? :\

cybermind 10-31-2005 23:47

http://www.amxmodx.org/funcwiki.php?...hink&go=search

Hawk552 11-01-2005 07:14

You just make a function called "public client_PreThink(id)". You need to have Engine included.

It's called every client frame.

v3x 11-01-2005 07:19

Eh, isn't it called more than once every frame?

Hawk552 11-01-2005 07:28

No.


All times are GMT -4. The time now is 23:42.

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