Jump to content

whats the difference between PLAYER and SOURCE?


Recommended Posts

For example:

1. addCommandhandler("test", function(player, command, something )

2. triggerClientEvent(source, "event", source)


Why the hell in first case i have to use player while in the second place, source?

Thank you in advance

Link to post

For first case, you are not forced to use 'player' you may use any variable you wish.

2nd case, you are forced to use 'source' only in case if you are using an event (for example 'onPlayerJoin') so the player is the source of that event.

Link to post

The difference is that only a player can issue a command, though an event's source could be any element type. This is why the wiki uses 'player' for command source variable, but you're free to use whatever name you want.

Edited by Investor
Link to post

In the first case, the first argument is the player who typed the command, and it's up to you to call it whatever you want.

in the second case the source gotta be defined in the parent event/function, also it refers for "which element (player) am i going to trigger this event for?"

also, the source is most likely to be hidden, you will find what it refers to when you search about the parent event in the wiki (would be like "The source of this event is ...")

Edited by savour
  • Like 1
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...