Jump to content

(Help) Use getlocalplayer on server


MamadHastam

Recommended Posts

hello so i have TriggerServerEvent on client and my event in server side is :

function()
	local money = getPlayerMoney(client)
		if money >= 000 then
			takePlayerMoney(client, 000)
	setElementPosition ( getLocalPlayer( ), 1552.8505859375, -1675.357421875, 16.1953125)
elseif money < 000 then
	outputChatBox('', client, 255, 255, 255, true)
end
end
addEvent('', true)
addEventHandler('', getRootElement(), )

like code above i want to SetElementPostion with the if i write but GetLocalPlayer isnt work in server side can somebody help me with that?

Link to comment
9 minutes ago, MamadHastam said:

hello so i have TriggerServerEvent on client and my event in server side is :

function()
	local money = getPlayerMoney(client)
		if money >= 000 then
			takePlayerMoney(client, 000)
	setElementPosition ( getLocalPlayer( ), 1552.8505859375, -1675.357421875, 16.1953125)
elseif money < 000 then
	outputChatBox('', client, 255, 255, 255, true)
end
end
addEvent('', true)
addEventHandler('', getRootElement(), )

like code above i want to SetElementPostion with the if i write but GetLocalPlayer isnt work in server side can somebody help me with that?

hello, welcome to forum,You can use getLocalPlayer() only on the client side, if you want to reach the player, use the word client. This is the player on which the event is run.


--serverside:

addEvent("eventNameHere", true)
addEventHandler("eventNameHere", root,
    function()
       --use client word here
       --example: givePlayerMoney(client, 1000) <-- giving 1000 to player
    end
)

--clientside.
 

triggerServerEvent("eventNameHere", localPlayer)

 

  • Thanks 1
Link to comment

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...