[HELP] Why cant I get this client / server trigger working?

top of the client.lua

if player press E do

TriggerServerEvent("fishing:BeginFishing", source)

bottom of client.lua

AddEventHandler("fishing:startFishing", source, function()
		TaskStartScenarioInPlace(player, "WORLD_HUMAN_STAND_FISHING", 0, false)
		fishcaught = true

Then on the server.lua I have at the top:


Then after that I have

AddEventHandler("fishing:BeginFishing", function()

I tried with both source, none, " or ’ nothing works :frowning:

I just want to make it sync when a player presses E then the task starts for fishing…

player press E

what is that ? You should use IsControlJustPressed function

And structure of a if statement is :

if (condition) then

You have put a do after your condition

ifplayer press E

I laughed way too hard at this xD sorry

Youre overcomplicating it, I dont see why you need to communicate with the server for such a simple task, this can all be done locally in the client.

if player press E
TaskStartScenarioInPlace(player, “WORLD_HUMAN_STAND_FISHING”, 0, false)
fishcaught = true

No triggers. No events. No server code.

1 Like


Please stop with that crappy “key” table… It’s getting beyond annoying now.

@maximilious if you want the user to press their pickup control (default to E) then use, IsControlJustPressed(1, 38).

If you want list of possible controls have a look at the wiki: https://wiki.fivem.net/wiki/Controls

1 Like

@Havoc Why is it shitty if it is defined as 38?
Is that not the same as naming GetPlayerPed(-1)?


It’s giving the false impression that the “E” key will always be bound to the control “38”. This is not the case as controls can be bound to any key.

Okay, thank you for the headsup.

	while true do
			if IsControlJustPressed(1, 38) then
				TaskStartScenarioInPlace(player, "WORLD_HUMAN_STAND_FISHING", 0, false)

would start the anim on keypress without an event.

1 Like

I didn’t put my entire code in here, of course if player pressed E is an expression… I have the actual code in my script. I didn’t know tasks didn’t require client / server interaction sorry guys :frowning: and thanks for the heads up @everyone

Only if the source(player) needs to gather/send information to the server, in this case youre only playing an animation and storing a random outcome to an array, thats all locally ( clientside )

Quick question, client sided I already have it so after the “fishing” task is over , a random fish is spawned in front of the player with values such as name, price, hex number, model, etc… if I wanted to make this work client / server then I have to move the fish creation to the server, save it to the db (what user caught) then pass the name, price, hex, and model to the client so he can see what he caught right?

Why do you need to save it in a database? What are you tying to accomplish?

If you want to store what the user has caught (for whatever reason) then you don’t need to “create” the fish on server, you can just send the values to a server event to store in the database.

I guess it’s because I wanted to save having to check if the fish inventory is full or not before creating a fish, so I wanted to move the fish creation to the server and before it does anything check if the count is == 20 on the database first.

the link does not work, it says bad gateway