-
Notifications
You must be signed in to change notification settings - Fork 19
Event functions #51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Event functions #51
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
756ab8a
Event functions
omar-o22 731ff0a
Merge branch 'main' into main
omar-o22 750eff6
Merge branch 'main' into main
Nico8345 f4ef6e2
Merge branch 'main' into main
omar-o22 54850c3
Improvements
omar-o22 4ee4171
Improvements
omar-o22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,44 +1,35 @@ | ||
| # Scraped from: https://wiki.multitheftauto.com/wiki/CancelEvent | ||
| client: | ||
| shared: | ||
| name: cancelEvent | ||
| description: This function is used to stop the automatic internal handling of events, | ||
| for example this can be used to prevent an item being given to a player when they | ||
| walk over a pickup, by canceling the [onPickupUse](/wiki/OnPickupUse "OnPickupUse") | ||
| description: This function is used to stop the automatic internal handling of events | ||
| event. | ||
| parameters: [] | ||
| examples: | ||
| - path: examples/cancelEvent-2.lua | ||
| description: This example prevents any damage to a player clientside by makingcancelEventan | ||
| event handler for theonClientPlayerDamageevent. | ||
| side: client | ||
| returns: | ||
| values: | ||
| - type: bool | ||
| name: value | ||
omar-o22 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| description: Always returns true . | ||
| requires_review: true | ||
| description: Always returns **true**. | ||
|
|
||
| client: | ||
| examples: | ||
| - path: examples/cancelEvent-2.lua | ||
| description: This example prevents any damage to a player clientside by making **cancelEvent** an | ||
| event handler for the [[onClientPlayerDamage]] event. | ||
|
|
||
| server: | ||
| name: cancelEvent | ||
| description: This function is used to stop the automatic internal handling of events, | ||
| for example this can be used to prevent an item being given to a player when they | ||
| walk over a pickup, by canceling the [onPickupUse](/wiki/OnPickupUse "OnPickupUse") | ||
| event. | ||
| parameters: | ||
| - name: cancel | ||
| type: bool | ||
| description: MISSING_PARAM_DESC | ||
| description: True to cancel, false to uncancel. | ||
| default: 'true' | ||
| - name: reason | ||
| type: string | ||
| description: MISSING_PARAM_DESC | ||
| description: The reason for cancelling the event. | ||
| default: '""' | ||
| examples: | ||
| - path: examples/cancelEvent-1.lua | ||
| description: This example stops the player from entering a vehicle. | ||
| side: server | ||
| returns: | ||
| values: | ||
| - type: bool | ||
| name: value | ||
| description: Always returns true . | ||
| requires_review: true | ||
| name: result | ||
| description: Returns **true**, otherwise **false** if parameters are invalid. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,46 +1,37 @@ | ||
| # Scraped from: https://wiki.multitheftauto.com/wiki/CancelLatentEvent | ||
| client: | ||
| shared: | ||
| name: cancelLatentEvent | ||
| description: Stops a latent event from completing | ||
| parameters: | ||
| - name: handle | ||
| type: int | ||
| description: A handle previous got from getLatentEventHandles . | ||
| description: A handle previous got from [[getLatentEventHandles]]. | ||
| examples: | ||
| - path: examples/cancelLatentEvent-1.lua | ||
| description: '' | ||
| side: client | ||
| - path: examples/cancelLatentEvent-4.lua | ||
| description: '' | ||
| side: client | ||
| returns: | ||
| values: | ||
| - type: bool | ||
| name: value | ||
| description: Returns a true if the latent event was successfully cancelled, or | ||
| false if it was not | ||
| requires_review: true | ||
| name: result | ||
| description: Returns a **true** if the latent event was successfully cancelled, otherwise **false**. | ||
|
|
||
| server: | ||
| name: cancelLatentEvent | ||
| description: Stops a latent event from completing | ||
| parameters: | ||
| - name: thePlayer | ||
| type: player | ||
| description: The player who is receiving the event. | ||
| - name: handle | ||
| type: int | ||
| description: A handle previous got from getLatentEventHandles . | ||
| description: A handle previous got from [[getLatentEventHandles]]. | ||
| examples: | ||
| - path: examples/cancelLatentEvent-2.lua | ||
| description: '' | ||
| side: server | ||
| - path: examples/cancelLatentEvent-3.lua | ||
| description: '' | ||
| side: server | ||
| description: "Cancel all my triggerLatentClientEvent's" | ||
| returns: | ||
| values: | ||
| - type: bool | ||
| name: value | ||
| description: Returns a true if the latent event was successfully cancelled, or | ||
| false if it was not | ||
| requires_review: true | ||
| name: result | ||
| description: Returns a **true** if the latent event was successfully cancelled, otherwise **false**. | ||
|
|
||
| client: | ||
| examples: | ||
| - path: examples/cancelLatentEvent-2.lua | ||
| description: "Cancel all my triggerLatentServerEvent's" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| -- Add a new event called onSpecialEvent | ||
| addEvent ( "onSpecialEvent", true ) | ||
|
|
||
| -- Define our handler function, that takes a "text" parameter and outputs it to the chatbox | ||
| function specialEventHandler ( text ) | ||
| outputChatBox ( text ) | ||
| end | ||
|
|
||
| -- Add it as a handler for our event | ||
| addEventHandler ( "onSpecialEvent", root, specialEventHandler ) | ||
| addEventHandler ( "onSpecialEvent", root, specialEventHandler ) | ||
| -- You can then trigger this event later on using: | ||
| triggerEvent ( "onSpecialEvent", root, "test" ) | ||
omar-o22 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| -- This will cause the handler to be triggered, so "test" will be output to the chatbox. | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| function onVehicleStartEnter() | ||
| cancelEvent() | ||
| cancelEvent() | ||
| end | ||
| addEventHandler("onVehicleStartEnter", root, onVehicleStartEnter) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,20 @@ | ||
| -- Cancel triggerLatentServerEvent directly after execution. | ||
| -- ***************************************************************************** | ||
| -- CLIENT CODE | ||
| addCommandHandler("cancelLatentEvent", | ||
| function () | ||
| triggerLatentServerEvent("exampleEvent",3000,false,localPlayer) | ||
|
|
||
| -- Get all your active handles, when you executed the command: /cancelLatentEvent | ||
| local handles = getLatentEventHandles() -- Returns a table. | ||
|
|
||
| local handle = handles[#handles] -- Get the latest handle. | ||
|
|
||
| if cancelLatentEvent(handle) then -- Cancel it! | ||
| outputChatBox("Successfully cancelled!",0,200,0) | ||
| end | ||
| end) | ||
|
|
||
| -- ***************************************************************************** | ||
| -- SERVER CODE | ||
| addEvent("exampleEvent",true) | ||
| addEventHandler("exampleEvent",root, | ||
| function () | ||
| outputChatBox("Warning! The triggerLatentServerEvent wasn't cancelled!",client,255,0,0) -- warn the user. | ||
| end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| addEvent("exampleEvent",true) | ||
| addEventHandler("exampleEvent",root, | ||
| function () | ||
| outputChatBox("Warning! The triggerLatentServerEvent wasn't cancelled!",client,255,0,0) -- warn the user. | ||
| addCommandHandler("cancelLatentEvents", | ||
| function (player) | ||
| local handles = getLatentEventHandles (player) -- Returns a table. | ||
|
|
||
| for index=1,#handles do -- Loop through the table. | ||
| local handle = handles[index] | ||
| cancelLatentEvent(player,handle) -- Cancel it! | ||
| end | ||
| end) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,9 @@ | ||
| -- Cancel all my triggerLatentClientEvent's. | ||
| addCommandHandler("cancelLatentEvents", | ||
| function (player) | ||
|
|
||
| -- Get all active handles from the player that executed the command: /cancelLatentEvents | ||
| local handles = getLatentEventHandles (player) -- Returns a table. | ||
| function () | ||
| local handles = getLatentEventHandles () -- Returns a table. | ||
|
|
||
| for index=1,#handles do -- Loop through the table. | ||
| local handle = handles[index] | ||
| cancelLatentEvent(player,handle) -- Cancel it! | ||
| local handle = handles[index] | ||
| cancelLatentEvent(handle) -- Cancel it! | ||
| end | ||
| end) |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.